Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-32386 completion: Fix incorrect method parameters

  • Loading branch information...
commit 40efa28d9e7dde3dc9fcce5300235d2ac783d17e 1 parent 4ff0f02
@srynot4sale srynot4sale authored
Showing with 8 additions and 3 deletions.
  1. +5 −1 lib/completionlib.php
  2. +3 −2 lib/simpletest/testcompletionlib.php
View
6 lib/completionlib.php
@@ -614,16 +614,20 @@ public function set_module_viewed($cm, $userid=0) {
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;
}
+
// Get current completion state
- $data = $this->get_data($cm, $userid);
+ $data = $this->get_data($cm, false, $userid);
+
// If we already viewed it, don't do anything
if ($data->viewed == COMPLETION_VIEWED) {
return;
}
+
// OK, change state, save it, and update completion
$data->viewed = COMPLETION_VIEWED;
$this->internal_set_data($cm, $data);
View
5 lib/simpletest/testcompletionlib.php
@@ -265,7 +265,7 @@ function test_set_module_viewed() {
// viewed, still do nothing
$c->expectAt(1,'is_enabled',array($cm));
$c->setReturnValueAt(1,'is_enabled',true);
- $c->expectAt(0,'get_data',array($cm,0));
+ $c->expectAt(0,'get_data',array($cm,false,0));
$hasviewed=(object)array('viewed'=>COMPLETION_VIEWED);
$c->setReturnValueAt(0,'get_data',$hasviewed);
$c->set_module_viewed($cm);
@@ -275,7 +275,7 @@ function test_set_module_viewed() {
$c->expectAt(2,'is_enabled',array($cm));
$c->setReturnValueAt(2,'is_enabled',true);
$notviewed=(object)array('viewed'=>COMPLETION_NOT_VIEWED);
- $c->expectAt(1,'get_data',array($cm,1337));
+ $c->expectAt(1,'get_data',array($cm,false,1337));
$c->setReturnValueAt(1,'get_data',$notviewed);
$c->expectOnce('internal_set_data',array($cm,$hasviewed));
$c->expectOnce('update_state',array($cm,COMPLETION_COMPLETE,1337));
@@ -434,6 +434,7 @@ function test_get_data() {
cm.course=? AND cmc.userid=?"),array(42,314159)));
// There are two CMids in total, the one we had data for and another one
+ $modinfo = new stdClass();
$modinfo->cms=array((object)array('id'=>13),(object)array('id'=>14));
$result=$c->get_data($cm,true,0,$modinfo);
Please sign in to comment.
Something went wrong with that request. Please try again.