Skip to content

Commit

Permalink
mod_hotpot fix updaing of completion status when using COMPLETION_TRA…
Browse files Browse the repository at this point in the history
…CKING_MANUAL
  • Loading branch information
gbateson committed Apr 20, 2016
1 parent de4860f commit 3c14b0c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ function hotpot_get_completion_state($course, $cm, $userid, $type) {

// get grade, if necessary
$grade = false;
if ($hotpot->completionmingrade || $hotpot->completionpass) {
if ($hotpot->completionmingrade > 0.0 || $hotpot->completionpass) {
require_once($CFG->dirroot.'/lib/gradelib.php');
$params = array('courseid' => $course->id,
'itemtype' => 'mod',
Expand Down
14 changes: 14 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2220,4 +2220,18 @@ public function get_gradeitem() {
}
return $this->gradeitem;
}

/**
* update_completion_state
*
* @param object $completion
* @return void, but may updated completion status
*/
public function update_completion_state($completion) {
if ($this->completionmingrade > 0.0 || $this->completionpass || $this->completioncompleted) {
if ($completion->is_enabled($this->cm) && ($this->cm->completion==COMPLETION_TRACKING_AUTOMATIC)) {
$completion->update_state($this->cm);
}
}
}
}
31 changes: 31 additions & 0 deletions reportclicktrail/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Hotpot report version
*
* @package hotpotreport
* @subpackage clicktrail
* @copyright 2015 Gordon Bateson <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') or die();

$plugin->component = 'hotpotreport_clicktrail';
$plugin->requires = 2010112400;
$plugin->version = 2010112400;
6 changes: 2 additions & 4 deletions submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
$class = 'mod_hotpot_'.$subtype.'_storage';
$storage = call_user_func(array($class, 'store'), $hotpot);

if ($hotpot->completionmingrade || $hotpot->completionpass || $hotpot->completioncompleted) {
$completion = new completion_info($course);
$completion->update_state($cm);
}
$completion = new completion_info($course);
$hotpot->update_completion_state($completion);

// redirect the browser (only if necessary)
if ($response = $output->require_response($hotpot)) {
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
$plugin->component = 'mod_hotpot';
$plugin->maturity = MATURITY_STABLE; // ALPHA=50, BETA=100, RC=150, STABLE=200
$plugin->requires = 2010112400; // Moodle 2.0
$plugin->release = '2016-01-12 (87)';
$plugin->version = 2016011287;
$plugin->release = '2016-04-20 (88)';
$plugin->version = 2016042088;

if ($moodle_26) {
$module = clone($plugin);
Expand Down
2 changes: 1 addition & 1 deletion view.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
require_sesskey();
if ($confirmed) {
$hotpot->delete_attempts($selected);
$completion->update_state($cm);
$hotpot->update_completion_state($completion);
} else {
// show a confirm button ?
}
Expand Down

0 comments on commit 3c14b0c

Please sign in to comment.