mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-79280 mod_quiz: consistently store ->cm as a cm_info
This commit is contained in:
parent
9890e67e6d
commit
83e840b8e7
@ -60,14 +60,14 @@ class edit_override_form extends moodleform {
|
||||
* Constructor.
|
||||
*
|
||||
* @param moodle_url $submiturl the form action URL.
|
||||
* @param cm_info|stdClass $cm course module object.
|
||||
* @param cm_info $cm course module object.
|
||||
* @param stdClass $quiz the quiz settings object.
|
||||
* @param context_module $context the quiz context.
|
||||
* @param bool $groupmode editing group override (true) or user override (false).
|
||||
* @param stdClass|null $override the override being edited, if it already exists.
|
||||
*/
|
||||
public function __construct(moodle_url $submiturl,
|
||||
cm_info|stdClass $cm, stdClass $quiz, context_module $context,
|
||||
cm_info $cm, stdClass $quiz, context_module $context,
|
||||
bool $groupmode, ?stdClass $override) {
|
||||
|
||||
$this->cm = $cm;
|
||||
|
@ -100,7 +100,7 @@ class quiz_attempt {
|
||||
*
|
||||
* @param stdClass $attempt the row of the quiz_attempts table.
|
||||
* @param stdClass $quiz the quiz object for this attempt and user.
|
||||
* @param stdClass|cm_info $cm the course_module object for this quiz.
|
||||
* @param cm_info $cm the course_module object for this quiz.
|
||||
* @param stdClass $course the row from the course table for the course we belong to.
|
||||
* @param bool $loadquestions (optional) if true, the default, load all the details
|
||||
* of the state of each question. Else just set up the basic details of the attempt.
|
||||
@ -349,7 +349,7 @@ class quiz_attempt {
|
||||
/**
|
||||
* Get the course_module for this quiz.
|
||||
*
|
||||
* @return stdClass|cm_info the course_module object.
|
||||
* @return cm_info the course_module object.
|
||||
*/
|
||||
public function get_cm() {
|
||||
return $this->quizobj->get_cm();
|
||||
|
@ -45,7 +45,7 @@ use stdClass;
|
||||
class quiz_settings {
|
||||
/** @var stdClass the course settings from the database. */
|
||||
protected $course;
|
||||
/** @var stdClass the course_module settings from the database. */
|
||||
/** @var cm_info the course_module settings from the database. */
|
||||
protected $cm;
|
||||
/** @var stdClass the quiz settings from the database. */
|
||||
protected $quiz;
|
||||
@ -89,12 +89,12 @@ class quiz_settings {
|
||||
* Helper used by the other factory methods.
|
||||
*
|
||||
* @param stdClass $quiz
|
||||
* @param cm_info|stdClass $cm
|
||||
* @param cm_info $cm
|
||||
* @param stdClass $course
|
||||
* @param int|null $userid the the userid (optional). If passed, relevant overrides are applied.
|
||||
* @return quiz_settings the new quiz settings object.
|
||||
*/
|
||||
protected static function create_helper(stdClass $quiz, cm_info|stdClass $cm, stdClass $course, ?int $userid): self {
|
||||
protected static function create_helper(stdClass $quiz, cm_info $cm, stdClass $course, ?int $userid): self {
|
||||
// Update quiz with override information.
|
||||
if ($userid) {
|
||||
$quiz = quiz_update_effective_access($quiz, $userid);
|
||||
@ -112,8 +112,7 @@ class quiz_settings {
|
||||
*/
|
||||
public static function create(int $quizid, int $userid = null): self {
|
||||
$quiz = access_manager::load_quiz_and_settings($quizid);
|
||||
$course = get_course($quiz->course);
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);
|
||||
[$course, $cm] = get_course_and_cm_from_instance($quiz, 'quiz');
|
||||
|
||||
return self::create_helper($quiz, $cm, $course, $userid);
|
||||
}
|
||||
@ -266,7 +265,7 @@ class quiz_settings {
|
||||
/**
|
||||
* Get the course-module object for this quiz.
|
||||
*
|
||||
* @return stdClass the course_module object.
|
||||
* @return cm_info the course_module object.
|
||||
*/
|
||||
public function get_cm() {
|
||||
return $this->cm;
|
||||
|
@ -4,6 +4,11 @@ This files describes API changes in the quiz code.
|
||||
|
||||
* The method get_questions() has a new parameter 'requirequestionfullyloaded' which can be used to instruct whether the
|
||||
questions should be fully loaded or not.
|
||||
* the quiz_settings and quiz_attempt classes now always store the ->cm property as a cm_info class.
|
||||
In the distant past it was always a stdClass, then at one point there was an undocumented change making
|
||||
it sometimes a stdClass and sometimes a cm_info. Now it is consistently a cm_info. Type hints have been
|
||||
updated to reflect this.
|
||||
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user