Skip to content

Commit

Permalink
Adhere to Moodle coding style more closely.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Nov 9, 2023
1 parent f43c97d commit 90dd4d8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions archive_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class quiz_archive_options extends mod_quiz_attempts_report_options {
/**
* @var array form field name => corresponding quiz_attempt:: state constant.
*/
protected static $statefields = array(
protected static $statefields = [
'stateinprogress' => quiz_attempt::IN_PROGRESS,
'stateoverdue' => quiz_attempt::OVERDUE,
'statefinished' => quiz_attempt::FINISHED,
'stateabandoned' => quiz_attempt::ABANDONED,
);
];

/**
* @var string quiz_attempts_report::ALL_WITH or quiz_attempts_report::ENROLLED_WITH
Expand All @@ -66,8 +66,8 @@ class quiz_archive_options extends mod_quiz_attempts_report_options {
* @var array|null of quiz_attempt::IN_PROGRESS, etc. constants. null means
* no restriction.
*/
public $states = array(quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE,
quiz_attempt::FINISHED, quiz_attempt::ABANDONED);
public $states = [quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE,
quiz_attempt::FINISHED, quiz_attempt::ABANDONED, ];

/**
* @var bool whether to show all finished attmepts, or just the one that gave
Expand Down Expand Up @@ -128,12 +128,12 @@ public function get_url() {
* @return array URL parameter name => value.
*/
protected function get_url_params() {
$params = array(
$params = [
'id' => $this->cm->id,
'mode' => $this->mode,
'attempts' => $this->attempts,
'onlygraded' => $this->onlygraded,
);
];

if ($this->states) {
$params['states'] = implode('-', $this->states);
Expand Down
8 changes: 4 additions & 4 deletions archive_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class quiz_archive_table extends flexible_table {
public function __construct($uniqueid, $quiz) {
parent::__construct($uniqueid);

$tablecolumns = array('template', 'action');
$tableheaders = array(get_string('template', 'feedback'), '');
$tablecolumns = ['template', 'action'];
$tableheaders = [get_string('template', 'feedback'), ''];

$this->set_attribute('class', 'templateslist');

Expand Down Expand Up @@ -73,9 +73,9 @@ public function display($templates) {
$strdeletefeedback = get_string('delete_template', 'feedback');

foreach ($templates as $template) {
$data = array();
$data = [];
$data[] = format_string($template->name);
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id, 'sesskey' => sesskey()));
$url = new moodle_url($this->baseurl, ['deletetempl' => $template->id, 'sesskey' => sesskey()]);
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$data[] = $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdeletefeedback), $deleteaction);
$this->add_data($data);
Expand Down
52 changes: 26 additions & 26 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function display($quiz, $cm, $course) {
$questionid = optional_param('qid', null, PARAM_INT);
$grade = optional_param('grade', null, PARAM_ALPHA);

if (!in_array($grade, array('all', 'needsgrading', 'autograded', 'manuallygraded'))) {
if (!in_array($grade, ['all', 'needsgrading', 'autograded', 'manuallygraded'])) {
$grade = null;
}
$page = optional_param('page', 0, PARAM_INT);
Expand Down Expand Up @@ -128,7 +128,7 @@ public function display($quiz, $cm, $course) {
*/
protected function base_url() {
return new moodle_url('/mod/quiz/report.php',
array('id' => $this->cm->id, 'mode' => 'archive'));
['id' => $this->cm->id, 'mode' => 'archive']);
}

/**
Expand All @@ -155,9 +155,9 @@ protected function quizreportgetstudentandattempts($quiz) {
$sql = "SELECT DISTINCT quiza.id attemptid, u.id userid, u.firstname, u.lastname FROM {user} u " .
"LEFT JOIN {quiz_attempts} quiza " .
"ON quiza.userid = u.id WHERE quiza.quiz = :quizid AND quiza.preview = 0 ORDER BY u.lastname ASC, u.firstname ASC";
$params = array('quizid' => $this->quiz->id);
$params = ['quizid' => $this->quiz->id];
$results = $DB->get_records_sql($sql, $params);
$students = array();
$students = [];
foreach ($results as $result) {
array_push($students, array('userid' => $result->userid, 'attemptid' => $result->attemptid));
}
Expand Down Expand Up @@ -198,45 +198,45 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
}

// Prepare summary information about the whole attempt.
$summarydata = array();
$summarydata = [];
// We want the user information no matter what.
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
$student = $DB->get_record('user', ['id' => $attemptobj->get_userid()]);
$userpicture = new user_picture($student);
$userpicture->courseid = $attemptobj->get_courseid();
$summarydata['user'] = array(
$summarydata['user'] = [
'title' => $userpicture,
'content' => new action_link(new moodle_url('/user/view.php', array(
'id' => $student->id, 'course' => $attemptobj->get_courseid())),
'content' => new action_link(new moodle_url('/user/view.php', [
'id' => $student->id, 'course' => $attemptobj->get_courseid(), ]),
fullname($student, true)),
);
];

// Timing information.
$summarydata['startedon'] = array(
'title' => get_string('startedon', 'quiz'),
'content' => userdate($attempt->timestart),
);

$summarydata['state'] = array(
$summarydata['state'] = [
'title' => get_string('attemptstate', 'quiz'),
'content' => quiz_archive_quiz_attempt::state_name($attempt->state),
);
];

if ($attempt->state == quiz_archive_quiz_attempt::FINISHED) {
$summarydata['completedon'] = array(
$summarydata['completedon'] = [
'title' => get_string('completedon', 'quiz'),
'content' => userdate($attempt->timefinish),
);
$summarydata['timetaken'] = array(
];
$summarydata['timetaken'] = [
'title' => get_string('timetaken', 'quiz'),
'content' => $timetaken,
);
];
}

if (!empty($overtime)) {
$summarydata['overdue'] = array(
$summarydata['overdue'] = [
'title' => get_string('overdue', 'quiz'),
'content' => $overtime,
);
];
}

// Show marks (if the user is allowed to see marks at the moment).
Expand All @@ -247,21 +247,21 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
// Cannot display grade.
echo '';
} else if (is_null($grade)) {
$summarydata['grade'] = array(
$summarydata['grade'] = [
'title' => get_string('grade', 'quiz'),
'content' => quiz_format_grade($quiz, $grade),
);
];

} else {
// Show raw marks only if they are different from the grade (like on the view page).
if ($quiz->grade != $quiz->sumgrades) {
$a = new stdClass();
$a->grade = quiz_format_grade($quiz, $attempt->sumgrades);
$a->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);
$summarydata['marks'] = array(
$summarydata['marks'] = [
'title' => get_string('marks', 'quiz'),
'content' => get_string('outofshort', 'quiz', $a),
);
];
}

// Now the scaled grade.
Expand All @@ -275,10 +275,10 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
} else {
$formattedgrade = get_string('outof', 'quiz', $a);
}
$summarydata['grade'] = array(
$summarydata['grade'] = [
'title' => get_string('grade', 'quiz'),
'content' => $formattedgrade,
);
];
}
}

Expand All @@ -288,10 +288,10 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
// Feedback if there is any, and the user is allowed to see it now.
$feedback = $attemptobj->get_overall_feedback($grade);
if ($options->overallfeedback && $feedback) {
$summarydata['feedback'] = array(
$summarydata['feedback'] = [
'title' => get_string('feedback', 'quiz'),
'content' => $feedback,
);
];
}

// Summary table end.
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/behat_quiz_archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function i_confirm_the_quiz_submission_in_the_modal_dialog() {
} else if (version_compare($currentversion, '3.9', ">=")) {
$xpath = "//div[contains(@class, 'confirmation-dialogue')]/*/input[contains(@class, 'btn-primary')]";
}
$this->execute("behat_general::i_click_on", array($this->escape($xpath), "xpath_element"));
$this->execute("behat_general::i_click_on", [$this->escape($xpath), "xpath_element"]);
}
}

0 comments on commit 90dd4d8

Please sign in to comment.