function CourseObjectBook::grade in Course 7.2
Same name and namespace in other branches
- 6 modules/course_book/course_book.classes.inc \CourseObjectBook::grade()
- 7 modules/course_book/course_book.classes.inc \CourseObjectBook::grade()
Grade (track) the book based on the fulfillment data.
File
- modules/
course_book/ course_book.classes.inc, line 78
Class
Code
function grade($user) {
if (course_book_count($this
->getInstanceId()) == 0) {
// Book has no pages. Complete object.
$this
->getFulfillment($user)
->setComplete(1)
->save();
return;
}
if ($this
->getOption('book_tracking') == 'all') {
// Possibly a bug here. book_toc doesn't return inaccessible book pages.
$mlids = array_keys(book_toc($this
->getInstanceId(), 99));
$fulfillment = $this
->getFulfillment($user)
->getOption('book_fulfillment');
$viewed = $fulfillment ? array_keys(array_filter($fulfillment)) : array();
if (!array_diff($mlids, $viewed)) {
$this
->getFulfillment($user)
->setComplete(1)
->save();
}
}
elseif ($this
->getOption('book_tracking') == 'one') {
$this
->getFulfillment($user)
->setComplete(1)
->save();
}
}