Merge branch 'MDL-26778-master' of git://github.com/sammarshallou/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-04-11 17:48:29 +02:00
commit 9ff913b716
11 changed files with 51 additions and 41 deletions

View File

@ -592,6 +592,9 @@ class completion_info {
* Should be called whenever a module is 'viewed' (it is up to the module how to
* determine that). Has no effect if viewing is not set as a completion condition.
*
* Note that this function must be called before you print the page header because
* it is possible that the navigation block may depend on it. If you call it after
* printing the header, it shows a developer debug warning.
* @uses COMPLETION_VIEW_NOT_REQUIRED
* @uses COMPLETION_VIEWED
* @uses COMPLETION_COMPLETE
@ -600,6 +603,11 @@ class completion_info {
* @return void
*/
public function set_module_viewed($cm, $userid=0) {
global $PAGE;
if ($PAGE->headerprinted) {
debugging('set_module_viewed must be called before header is printed',
DEBUG_DEVELOPER);
}
// Don't do anything if view condition is not turned on
if ($cm->completionview == COMPLETION_VIEW_NOT_REQUIRED || !$this->is_enabled($cm)) {
return;
@ -932,6 +940,8 @@ class completion_info {
if ($data->userid == $USER->id) {
$SESSION->completioncache[$cm->course][$cm->id] = $data;
$reset = 'reset';
get_fast_modinfo($reset);
}
}

View File

@ -79,6 +79,10 @@ $strnextsession = get_string('nextsession', 'chat');
$title = $course->shortname . ': ' . format_string($chat->name);
// Mark viewed by user (if required)
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
// Initialize $PAGE
$PAGE->set_url('/mod/chat/view.php', array('id' => $cm->id));
$PAGE->set_title($title);
@ -178,7 +182,4 @@ if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
echo $OUTPUT->box_end();
}
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer();

View File

@ -50,6 +50,10 @@
$PAGE->set_title(format_string($choice->name));
$PAGE->set_heading($course->fullname);
// Mark viewed by user (if required)
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// Submit any new data if there is any
if (data_submitted() && is_enrolled($context, NULL, 'mod/choice:choose') && confirm_sesskey()) {
$timenow = time();
@ -168,8 +172,3 @@
}
echo $OUTPUT->footer();
/// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);

View File

@ -289,6 +289,10 @@
$PAGE->requires->js('/mod/data/js.php?d='.$data->id, true);
}
// Mark as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// Print the page header
// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
@ -730,11 +734,6 @@ if ($showactivity) {
if (($maxcount || $mode == 'asearch') && $mode != 'single') {
data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
}
/// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
}
echo $OUTPUT->footer();

View File

@ -121,6 +121,10 @@
print_error('error');
}
// Mark activity viewed for completion-tracking
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
@ -502,9 +506,5 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Mark activity viewed for completion-tracking
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer();

View File

@ -97,6 +97,10 @@
rss_add_http_header($context, 'mod_forum', $forum, $rsstitle);
}
// Mark viewed if required
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// Print header.
/// Add ajax-related libs for ratings if required MDL-20119
$PAGE->requires->yui2_lib('event');
@ -239,8 +243,7 @@
break;
}
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer($course);

View File

@ -125,6 +125,10 @@ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $con
}
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", $glossary->id, $cm->id);
// Mark as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// stablishing flag variables
if ( $sortorder = strtolower($sortorder) ) {
if ($sortorder != 'asc' and $sortorder != 'desc') {
@ -495,8 +499,3 @@ glossary_print_tabbed_table_end();
/// Finish the page
echo $OUTPUT->footer();
/// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);

View File

@ -45,6 +45,10 @@ if ($backtocourse) {
redirect(new moodle_url('/course/view.php', array('id'=>$course->id)));
}
// Mark as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$url = new moodle_url('/mod/lesson/view.php', array('id'=>$id));
if ($pageid !== null) {
$url->param('pageid', $pageid);
@ -564,7 +568,3 @@ if ($pageid != LESSON_EOL) {
echo $lessoncontent;
echo $lessonoutput->footer();
}
/// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);

View File

@ -55,6 +55,10 @@
/// Log this request.
add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", $quiz->id, $cm->id);
// Mark module as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
/// Initialize $PAGE, compute blocks
$PAGE->set_url('/mod/quiz/view.php', array('id' => $cm->id));
@ -382,10 +386,4 @@
}
echo $OUTPUT->box_end();
// Mark module as viewed (note, we do this here and not in finish_page,
// otherwise the 'not enrolled' error conditions would result in marking
// 'viewed', I think it's better if they don't.)
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer();

View File

@ -146,6 +146,10 @@
$SESSION->scorm_mode = $mode;
$SESSION->scorm_attempt = $attempt;
// Mark module viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
//
// Print the page header
//
@ -249,10 +253,6 @@ if (!isset($result->toctitle)) {
$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $sco->id));
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
if (!empty($forcejs)) {
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
}

View File

@ -51,6 +51,10 @@ require_capability('mod/workshop:view', $PAGE->context);
$workshop = new workshop($workshop, $cm, $course);
$workshop->log('view');
// Mark viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
if (!is_null($editmode) && $PAGE->user_allowed_editing()) {
$USER->editing = $editmode;
}
@ -538,7 +542,4 @@ case workshop::PHASE_CLOSED:
default:
}
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
echo $output->footer();