function CourseObjectBook::grade in Course 7
Same name and namespace in other branches
- 6 modules/course_book/course_book.classes.inc \CourseObjectBook::grade()
- 7.2 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() {
if (course_book_count($this->node->nid) == 0) {
// Book has no pages. Complete object.
$this
->getFulfillment()
->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->node->nid, 99));
$fulfillment = $this
->getFulfillment()
->getOption('book_fulfillment');
$viewed = $fulfillment ? array_keys(array_filter($fulfillment)) : array();
if (!array_diff($mlids, $viewed)) {
$this
->getFulfillment()
->setComplete(1)
->save();
}
}
elseif ($this
->getOption('book_tracking') == 'one') {
$this
->getFulfillment()
->setComplete(1)
->save();
}
}