Skip to content

Commit

Permalink
Merge branch 'MDL-52471-master' of git://github.com/danpoltawski/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Dec 11, 2015
2 parents 206d736 + ef5df7b commit 05178f0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/completionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function completion_can_view_data($userid, $course = null) {

if (!is_object($course)) {
$cid = $course;
$course = new object();
$course = new stdClass();
$course->id = $cid;
}

Expand Down
9 changes: 8 additions & 1 deletion lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since 2.0
*/
class object extends stdClass {};
class object extends stdClass {
/**
* Constructor.
*/
public function __construct() {
debugging("'object' class has been deprecated, please use stdClass instead.", DEBUG_DEVELOPER);
}
};

/**
* Base Moodle Exception class
Expand Down
21 changes: 12 additions & 9 deletions lib/tests/completionlib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,7 @@ protected function setup_data() {
// Create a course with activities.
$this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => true));
$this->user = $this->getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->assertNotEmpty($studentrole);

// Get manual enrolment plugin and enrol user.
require_once($CFG->dirroot.'/enrol/manual/locallib.php');
$manplugin = enrol_get_plugin('manual');
$maninstance = $DB->get_record('enrol', array('courseid' => $this->course->id, 'enrol' => 'manual'), '*', MUST_EXIST);
$manplugin->enrol_user($maninstance, $this->user->id, $studentrole->id);
$this->assertEquals(1, $DB->count_records('user_enrolments'));
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id);

$this->module1 = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id));
$this->module2 = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id));
Expand Down Expand Up @@ -858,6 +850,17 @@ public function test_course_completion_updated_event() {
$expectedlegacylog = array($this->course->id, 'course', 'completion updated', 'completion.php?id='.$this->course->id);
$this->assertEventLegacyLogData($expectedlegacylog, $event);
}

public function test_completion_can_view_data() {
$this->setup_data();

$student = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($student->id, $this->course->id);

$this->setUser($student);
$this->assertTrue(completion_can_view_data($student->id, $this->course->id));
$this->assertFalse(completion_can_view_data($this->user->id, $this->course->id));
}
}

class core_completionlib_fake_recordset implements Iterator {
Expand Down
6 changes: 6 additions & 0 deletions lib/tests/setuplib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,10 @@ public function get_exception_info($ex) {
return get_exception_info($e);
}
}

public function test_object() {
$obj = new object();
$this->assertDebuggingCalled("'object' class has been deprecated, please use stdClass instead.");
$this->assertInstanceOf('stdClass', $obj);
}
}
17 changes: 0 additions & 17 deletions mod/quiz/attemptlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1975,23 +1975,6 @@ protected function fire_state_transition_event($eventclass, $timestamp) {
$event->trigger();
}

/**
* Print the fields of the comment form for questions in this attempt.
* @param $slot which question to output the fields for.
* @param $prefix Prefix to add to all field names.
*/
public function question_print_comment_fields($slot, $prefix) {
// Work out a nice title.
$student = get_record('user', 'id', $this->get_userid());
$a = new object();
$a->fullname = fullname($student, true);
$a->attempt = $this->get_attempt_number();

question_print_comment_fields($this->quba->get_question_attempt($slot),
$prefix, $this->get_display_options(true)->markdp,
get_string('gradingattempt', 'quiz_grading', $a));
}

// Private methods =========================================================

/**
Expand Down
4 changes: 4 additions & 0 deletions mod/quiz/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
This files describes API changes in the quiz code.

=== 3.1 ===
* quiz_attempt::question_print_comment_fields() has been removed. It was broken
since at least Moodle 2.0.

=== 2.9 ===

* There have been changes in classes/output/edit_renderer.php for MDL-40990.
Expand Down

0 comments on commit 05178f0

Please sign in to comment.