MDL-21687 Completion 'on view' not working on resource types after resource was rewritten

This commit is contained in:
Sam Marshall 2010-02-23 13:10:45 +00:00
parent 6d6b454aca
commit c15a60e6be
6 changed files with 32 additions and 0 deletions

View File

@ -45,6 +45,10 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'folder', 'view', 'view.php?id='.$cm->id, $folder->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/folder/view.php', array('id' => $cm->id));
$PAGE->set_title($course->shortname.': '.$folder->name);

View File

@ -45,6 +45,10 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'imscp', 'view', 'view.php?id='.$cm->id, $imscp->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/imscp/view.php', array('id' => $cm->id));
$PAGE->requires->js('/mod/imscp/dummyapi.js', true);

View File

@ -52,6 +52,10 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'page', 'view', 'view.php?id='.$cm->id, $page->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/page/view.php', array('id' => $cm->id));
$options = empty($page->displayoptions) ? array() : unserialize($page->displayoptions);

View File

@ -304,6 +304,18 @@ function resource_get_coursemodule_info($coursemodule) {
$context = get_context_instance(CONTEXT_MODULE, $coursemodule->id);
$path = '/'.$context->id.'/resource_content/'.$resource->revision.$resource->mainfile;
$fullurl = addslashes_js(file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, true));
// When completion information is enabled for download files, make
// the JavaScript version go to the view page with redirect set,
// instead of directly to the file, otherwise we can't make it tick
// the box for them
if (!$course = $DB->get_record('course', array('id'=>$coursemodule->course), 'id, enablecompletion')) {
return NULL;
}
$completion = new completion_info($course);
if ($completion->is_enabled($coursemodule) == COMPLETION_TRACKING_AUTOMATIC) {
$fullurl = "$CFG->wwwroot/mod/resource/view.php?id=$coursemodule->id&redirect=1";
}
$info->extra = "onclick=\"window.open('$fullurl'); return false;\"";
}

View File

@ -52,6 +52,10 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'resource', 'view', 'view.php?id='.$cm->id, $resource->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/resource/view.php', array('id' => $cm->id));
if ($resource->tobemigrated) {

View File

@ -46,6 +46,10 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'url', 'view', 'view.php?id='.$cm->id, $url->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/url/view.php', array('id' => $cm->id));
if ($redirect) {