function course_ajax_fulfullment_check in Course 7.2
Fulfillment check callback.
This function is polled from nav.js to check remote fulfillments for external learning objects.
1 string reference to 'course_ajax_fulfullment_check'
- course_menu in ./
course.module - Implements hook_menu().
File
- ./
course.module, line 382 - course.module Core functionality for Courses.
Code
function course_ajax_fulfullment_check($node, $courseObject, $js = FALSE) {
global $user;
// Run the course object's method for evaluating completion from a 3rd party.
$courseObject
->poll();
if (course_node_is_course($node)) {
// We have to set context because we're in an AJAX callback with no course
// context. Without this, re-rendering the navigation links won't work.
course_set_context($node);
}
if ($js) {
if ($courseObject
->getFulfillment($user)
->isComplete()) {
// Object is complete. AJAX redirect to next location.
// Render new navigation.
module_load_include('inc', 'course', 'includes/course.block');
$block = block_load('course', 'navigation');
$block_rend = _block_render_blocks(array(
$block,
));
$commands[] = ajax_command_replace('#course-nav', render($block_rend['course_navigation']->content));
$commands[] = [
'command' => 'course_nav_next',
];
}
else {
$commands[] = [
'command' => 'course_nav_popup',
];
}
print ajax_render($commands);
exit;
}
else {
if (!$courseObject
->getFulfillment($user)
->isComplete()) {
drupal_set_message(t('You have not yet been marked as complete.'), 'error');
}
else {
drupal_set_message(t('You have been marked as complete.'));
}
drupal_goto($courseObject
->getUrl());
}
}