function CourseObjectBook::grade in Course 6
Same name and namespace in other branches
- 7.2 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 61
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') {
$mlids = array_keys(book_toc($this->node->nid, array(), 99));
$viewed = array_keys(array_filter($this
->getFulfillment()
->getOption('book_fulfillment')));
if (!array_diff($mlids, $viewed)) {
$this
->getFulfillment()
->setComplete(1)
->save();
}
}
elseif ($this
->getOption('book_tracking') == 'one') {
$this
->getFulfillment()
->setComplete(1)
->save();
}
}