Skip to content

Commit 28ed00c

Browse files
committed
Resolve errors with PHP 8.4, resolves#538.
1 parent afa3345 commit 28ed00c

5 files changed

Lines changed: 24 additions & 24 deletions

File tree

classes/local/studentquiz_progress.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ class studentquiz_progress {
5353
* @param int $userid
5454
* @param int $studentquizid
5555
* @param int $sqqid
56-
* @param int $lastanswercorrect
57-
* @param int $attempts
58-
* @param int $correctattempts
59-
* @param int $lastreadprivatecomment
60-
* @param int $lastreadpubliccomment
56+
* @param int|null $lastanswercorrect
57+
* @param int|null $attempts
58+
* @param int|null $correctattempts
59+
* @param int|null $lastreadprivatecomment
60+
* @param int|null $lastreadpubliccomment
6161
* @param int|null $id
6262
*/
63-
public function __construct(int $questionid, int $userid, int $studentquizid, int $sqqid, int $lastanswercorrect = 0,
64-
int $attempts = 0, int $correctattempts = 0, int $lastreadprivatecomment = 0, int $lastreadpubliccomment = 0,
65-
int $id = null) {
63+
public function __construct(int $questionid, int $userid, int $studentquizid, int $sqqid, ?int $lastanswercorrect = 0,
64+
?int $attempts = 0, ?int $correctattempts = 0, ?int $lastreadprivatecomment = 0, ?int $lastreadpubliccomment = 0,
65+
?int $id = null) {
6666
$this->questionid = $questionid;
6767
$this->userid = $userid;
6868
$this->studentquizid = $studentquizid;

classes/local/studentquiz_question.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class studentquiz_question {
5858
* @param mixed|null $cm
5959
* @param mixed|null $context
6060
*/
61-
public function __construct(int $studentquizquestionid, question_definition $question = null,
62-
stdClass $studentquiz = null, $cm = null, $context = null) {
61+
public function __construct(int $studentquizquestionid, ?question_definition $question = null,
62+
?stdClass $studentquiz = null, $cm = null, $context = null) {
6363
$this->id = $studentquizquestionid;
6464
$this->load_studentquiz_question();
6565
$this->question = $question;
@@ -167,8 +167,8 @@ public function is_hidden(): bool {
167167
* @param mixed $context
168168
* @return studentquiz_question StudentQuiz question object.
169169
*/
170-
public static function get_studentquiz_question_from_question(question_definition $question, stdClass $studentquiz = null,
171-
$cm = null, $context = null): studentquiz_question {
170+
public static function get_studentquiz_question_from_question(question_definition $question, ?stdClass $studentquiz = null,
171+
mixed $cm = null, mixed $context = null): studentquiz_question {
172172
global $DB;
173173
$params = [
174174
'questionid1' => $question->id,
@@ -314,11 +314,11 @@ public function change_pin_status(int $pin): void {
314314
* Saving the action change state.
315315
*
316316
* @param int $state The state of the question in the StudentQuiz.
317-
* @param int $userid
318-
* @param int $timecreated The time do action.
317+
* @param int|null $userid
318+
* @param int|null $timecreated The time do action.
319319
* @return bool|int True or new id
320320
*/
321-
public function save_action(int $state, ?int $userid, int $timecreated = null) {
321+
public function save_action(int $state, ?int $userid, ?int $timecreated = null) {
322322
global $DB;
323323

324324
$data = new \stdClass();

classes/utils.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,11 @@ public static function get_user_profile_url(int $userid, int $courseid): moodle_
580580
* @param int $studentquizquestionid Id of studentquizquestion.
581581
* @param int|null $userid
582582
* @param int $state The state of the question in the StudentQuiz.
583-
* @param int $timecreated The time do action.
583+
* @param int|null $timecreated The time do action.
584584
* @return bool|int True or new id
585585
*/
586586
public static function question_save_action(int $studentquizquestionid, ?int $userid, int $state,
587-
int $timecreated = null) {
587+
?int $timecreated = null) {
588588
global $DB;
589589

590590
$data = new \stdClass();
@@ -778,7 +778,7 @@ public static function ensure_question_version_status_is_correct(int $questionid
778778
* @return void
779779
*/
780780
public static function require_access_to_a_relevant_group(object $cm, \context $context, string $title = '',
781-
studentquiz_question $studentquizquestion = null): void {
781+
?studentquiz_question $studentquizquestion = null): void {
782782
global $COURSE, $PAGE, $USER;
783783
$groupmode = (int) groups_get_activity_groupmode($cm, $COURSE);
784784
$currentgroup = groups_get_activity_group($cm, true);

lib.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function studentquiz_after_require_login() {
9393
* of the new instance.
9494
*
9595
* @param stdClass $studentquiz Submitted data from the form in mod_form.php
96-
* @param mod_studentquiz_mod_form $mform The form instance itself (if needed)
96+
* @param mod_studentquiz_mod_form|null $mform The form instance itself (if needed)
9797
* @return int The id of the newly inserted studentquiz record
9898
*/
99-
function studentquiz_add_instance(stdClass $studentquiz, mod_studentquiz_mod_form $mform = null) {
99+
function studentquiz_add_instance(stdClass $studentquiz, ?mod_studentquiz_mod_form $mform = null) {
100100
global $DB;
101101

102102
$studentquiz->timecreated = time();
@@ -164,10 +164,10 @@ function studentquiz_add_instance(stdClass $studentquiz, mod_studentquiz_mod_for
164164
* will update an existing instance with new data.
165165
*
166166
* @param stdClass $studentquiz An object from the form in mod_form.php
167-
* @param mod_studentquiz_mod_form $mform The form instance itself (if needed)
167+
* @param mod_studentquiz_mod_form|null $mform The form instance itself (if needed)
168168
* @return boolean Success/Fail
169169
*/
170-
function studentquiz_update_instance(stdClass $studentquiz, mod_studentquiz_mod_form $mform = null) {
170+
function studentquiz_update_instance(stdClass $studentquiz, ?mod_studentquiz_mod_form $mform = null) {
171171
global $DB;
172172

173173
// For checkboxes, when deselected, $1 still contains the data from the database, because browser doesn't

tests/generator/lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public function reset() {
5353
/**
5454
* Create StudentQuiz instance
5555
* @param stdClass $record
56-
* @param array $options
56+
* @param array|null $options
5757
* @return stdClass
5858
*/
59-
public function create_instance($record = null, array $options = null) {
59+
public function create_instance($record = null, ?array $options = null) {
6060
$record = (object)(array)$record;
6161

6262
// TODO for behats I think this is the reason for studentquiz 0!

0 commit comments

Comments
 (0)