Skip to content

Commit

Permalink
Fix warnings when using PHP 8.2 (#80)
Browse files Browse the repository at this point in the history
Many thanks Tim Hunt for finding and fixing #80 (avoid warnings with PHP 8.2, Update moodle-plugin-ci config)
  • Loading branch information
timhunt authored Dec 6, 2023
1 parent ee5ce75 commit e2c25da
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.0'
- php: '8.2'
moodle-branch: 'master'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
- php: '8.1'
moodle-branch: 'MOODLE_402_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_400_STABLE'
database: 'mariadb'
Expand Down
10 changes: 0 additions & 10 deletions classes/question_hint_ordering.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,4 @@ public static function load_from_record($row) {
return new question_hint_ordering($row->id, $row->hint, $row->hintformat,
$row->shownumcorrect, $row->clearwrong, $row->options);
}

/**
* Adjust this display options according to the hint settings.
*
* @param question_display_options $options
*/
public function adjust_display_options(question_display_options $options) {
parent::adjust_display_options($options);
$options->highlightresponse = $this->highlightresponse;
}
}
18 changes: 18 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ class qtype_ordering_question extends question_graded_automatically {
/** @var int Items are graded relative to their position in the correct answer */
const GRADING_RELATIVE_TO_CORRECT = 7;

/** @var int {@see LAYOUT_VERTICAL} or {@see LAYOUT_HORIZONTAL}. */
public $layouttype;

/** @var int {@see SELECT_ALL}, {@see SELECT_RANDOM} or {@see SELECT_CONTIGUOUS}. */
public $selecttype;

/** @var int if {@see $selecttype} is not SELECT_ALL, then the number to select. */
public $selectcount;

/** @var int Which grading strategy to use. One of the GRADING_... constants. */
public $gradingtype;

/** @var bool Should details of the grading calculation be shown to students. */
public $showgrading;

/** @var string How to number the items. A key from the array returned by {@see get_numbering_styles()}. */
public $numberingstyle;

// Fields from "qtype_ordering_options" table.
/** @var string */
public $correctfeedback;
Expand Down
9 changes: 7 additions & 2 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ public function formulation_and_controls(question_attempt $qa, question_display_
}

// In the multi-tries, the highlight response base on the hint highlight option.
if (isset($options->highlightresponse) && $options->highlightresponse) {
$hint = null;
if (method_exists($qa->get_behaviour(), 'get_applicable_hint')) {
/** @var \qtype_ordering\question_hint_ordering $hint */
$hint = $qa->get_behaviour()->get_applicable_hint();
}
if ($hint && $hint->highlightresponse) {
$sortablelist .= ' notactive';
}

Expand Down Expand Up @@ -152,7 +157,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_
break;
}

if (isset($options->highlightresponse) && $options->highlightresponse) {
if ($hint && $hint->highlightresponse) {
$score = $this->get_ordering_item_score($question, $position, $answerid);
list($score, $maxscore, $fraction, $percent, $class, $img) = $score;
$class = trim("$sortableitem $class");
Expand Down
1 change: 0 additions & 1 deletion tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function get_test_questions() {
public function make_ordering_question_moodle() {
question_bank::load_question_definition_classes('ordering');
$q = new qtype_ordering_question();
$q->questionid = $q->id;
test_question_maker::initialise_a_question($q);
$q->qtype = question_bank::get_qtype('ordering');
$q->name = 'Moodle';
Expand Down

0 comments on commit e2c25da

Please sign in to comment.