Browse Source

Fix: Completion settings

MOODLE_20_STABLE
ubuntu 12 years ago
parent
commit
40df7e9eb8
  1. 35
      lib.php
  2. 4
      version.php
  3. 4
      view.php

35
lib.php

@ -1100,3 +1100,38 @@ function game_reset_userdata($data) {
return $status;
}
/**
* Obtains the automatic completion state for this module based on any conditions
* in game settings.
*
* @param object $course Course
* @param object $cm Course-module
* @param int $userid User ID
* @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
* @return bool True if completed, false if not, $type if conditions not set.
*/
function game_get_completion_state($course, $cm, $userid, $type) {
global $CFG,$DB;
require_once($CFG->dirroot . '/mod/game/locallib.php');
if( ($cm->completion == 0) or ($cm->completion == 1)){
// Completion option is not enabled so just return $type.
return $type;
}
if( $cm->completionview)
{
//Just want to view it. Not needed it
return true;
}
if (! $game = $DB->get_record('game', array('id' => $cm->instance))) {
print_error('invalidcoursemodule');
}
$grade = $DB->get_record_select('game_grades', "userid=$userid AND gameid = $cm->instance", null, 'id,score');
return $grade && $grade->score > 0;
}

4
version.php

@ -11,7 +11,7 @@
defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_game'; // Full name of the plugin (used for diagnostics)
$module->version = 2012122002; // The current module version (Date: YYYYMMDDXX)
$module->version = 2012122701; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2010112400; // Requires Moodle 2.0
$module->cron = 0; // Period for cron to check this module (secs)
$module->release = 'v.2.12.20.2 (2012122002)';
$module->release = 'v.2.12.27 (2012122701)';

4
view.php

@ -50,6 +50,10 @@
/// Log this request.
add_to_log($course->id, 'game', 'view', "view.php?id=$cm->id", $game->id, $cm->id);
// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
/// Initialize $PAGE, compute blocks
$PAGE->set_url('/mod/game/view.php', array('id' => $cm->id));

Loading…
Cancel
Save