Skip to content

Commit

Permalink
codecheck-comply - array declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
EJMFarrow committed Apr 16, 2024
1 parent fba9b1a commit f49d45a
Show file tree
Hide file tree
Showing 269 changed files with 46,354 additions and 46,354 deletions.
22 changes: 11 additions & 11 deletions adminui/answertests.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
if ($anstest === 'ALL') {
$tests = stack_answertest_test_data::get_all();
} else if (!$anstest) {
$tests = array();
$tests = [];
} else {
$tests = stack_answertest_test_data::get_tests_for($anstest);
}

// Set up the results table.
$columns = array(
$columns = [
'name' => stack_string('answertest_ab'),
'passed' => stack_string('testsuitecolpassed'),
'studentanswer' => stack_string('studentanswer'),
Expand All @@ -81,7 +81,7 @@
'error' => stack_string('testsuitecolerror'),
'feedback' => stack_string('testsuitefeedback'),
'answernote' => stack_string('answernote'),
);
];

if ($anstest !== 'ALL') {
array_shift($columns);
Expand All @@ -102,7 +102,7 @@

// Run the tests.
$allpassed = true;
$failedtable = array();
$failedtable = [];
$notests = 0;
$start = microtime(true);

Expand All @@ -122,8 +122,8 @@
reset($columns);
$firstcol = key($columns);
// This is a slight cludge to get multiple columns in a row.
$notes = html_writer::tag('td', $test->notes, array('colspan' => '8'));
$table->add_data(array($notes), 'notes');
$notes = html_writer::tag('td', $test->notes, ['colspan' => '8']);
$table->add_data([$notes], 'notes');
}

set_time_limit(30);
Expand Down Expand Up @@ -160,7 +160,7 @@
if ($rawmark !== $test->expectedscore && $test->expectedscore > 0) {
$mark = $rawmark . ' <> ' . $test->expectedscore;
}
$row = array(
$row = [
'name' => $test->name,
'passed' => $passedcol,
'studentanswer' => html_writer::tag('pre', $sans),
Expand All @@ -170,7 +170,7 @@
'error' => $error,
'feedback' => format_text($feedback),
'answernote' => $ansnote,
);
];
if (!$passed) {
$row['answernote'] .= html_writer::tag('pre', $trace);
$failedtable[] = $row;
Expand All @@ -186,9 +186,9 @@
$took = (microtime(true) - $start);
$rtook = round($took, 5);
$pertest = round($took / $notests, 5);
echo '<p>'.stack_string('testsuitenotests', array('no' => $notests));
echo '<br/>'.stack_string('testsuiteteststook', array('time' => $rtook));
echo '<br/>'.stack_string('testsuiteteststookeach', array('time' => $pertest));
echo '<p>'.stack_string('testsuitenotests', ['no' => $notests]);
echo '<br/>'.stack_string('testsuiteteststook', ['time' => $rtook]);
echo '<br/>'.stack_string('testsuiteteststookeach', ['time' => $pertest]);
echo '</p>';

$config = get_config('qtype_stack');
Expand Down
2 changes: 1 addition & 1 deletion adminui/bulktest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
// Calling $PAGE->set_context should be enough, but it seems that it is not.
// Therefore, we get the right $cm and $course, and set things up ourselves.
$cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
$PAGE->set_cm($cm, $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST));
$PAGE->set_cm($cm, $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST));
}

// Create the helper class.
Expand Down
6 changes: 3 additions & 3 deletions adminui/bulktestall.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$startfromcontextid = optional_param('startfromcontextid', 0, PARAM_INT);

$skippreviouspasses = optional_param('skippreviouspasses', false, PARAM_BOOL);
$urlparams = array();
$urlparams = [];
if ($skippreviouspasses) {
$urlparams['skippreviouspasses'] = 1;
}
Expand All @@ -63,7 +63,7 @@
// Create the helper class.
$bulktester = new stack_bulk_tester();
$allpassed = true;
$allfailing = array();
$allfailing = [];
$skipping = $startfromcontextid != 0;

// Release the session, so the user can do other things while this runs.
Expand Down Expand Up @@ -91,7 +91,7 @@
foreach ($failing as $key => $arrvals) {
// Guard clause here to future proof any new fields from the bulk tester.
if (!array_key_exists($key, $allfailing)) {
$allfailing[$key] = array();
$allfailing[$key] = [];
}
$allfailing[$key] = array_merge($allfailing[$key], $arrvals);
}
Expand Down
16 changes: 8 additions & 8 deletions adminui/bulktestindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// Find in which contexts the user can edit questions.
$questionsbycontext = $bulktester->get_num_stack_questions_by_context();
$availablequestionsbycontext = array();
$availablequestionsbycontext = [];
foreach ($questionsbycontext as $contextid => $numquestions) {
$context = context::instance_by_id($contextid);
if (has_capability('moodle/question:editall', $context)) {
Expand All @@ -69,9 +69,9 @@
$name = $course->get_context_name(true, true) . ': ' . $name;
}
}
$availablequestionsbycontext[$name] = array(
$availablequestionsbycontext[$name] = [
'contextid' => $contextid,
'numquestions' => $numquestions);
'numquestions' => $numquestions];
}
}

Expand All @@ -86,24 +86,24 @@
$contextid = $info['contextid'];
$numquestions = $info['numquestions'];

$testallurl = new moodle_url('/question/type/stack/adminui/bulktest.php', array('contextid' => $contextid));
$testallurl = new moodle_url('/question/type/stack/adminui/bulktest.php', ['contextid' => $contextid]);
$testalllink = html_writer::link($testallurl,
get_string('bulktestallincontext', 'qtype_stack'), array('title' => get_string('testalltitle', 'qtype_stack')));
get_string('bulktestallincontext', 'qtype_stack'), ['title' => get_string('testalltitle', 'qtype_stack')]);
$litext = $name . ' (' . $numquestions . ') ' . $testalllink;

echo html_writer::start_tag('details');
echo html_writer::tag('summary', $litext);

$categories = $bulktester->get_categories_for_context($contextid);
echo html_writer::start_tag('ul', array('class' => 'expandable'));
echo html_writer::start_tag('ul', ['class' => 'expandable']);
foreach ($categories as $cat) {
if ($cat->count > 0) {
$url = new moodle_url('/question/type/stack/adminui/bulktest.php',
array('contextid' => $contextid, 'categoryid' => $cat->id));
['contextid' => $contextid, 'categoryid' => $cat->id]);
$linktext = $cat->name . ' (' . $cat->count . ')';
$link = html_writer::link($url, $linktext);
echo html_writer::tag('li', $link,
array('title' => get_string('testallincategory', 'qtype_stack')));
['title' => get_string('testallincategory', 'qtype_stack')]);
}
}
echo html_writer::end_tag('ul');
Expand Down
4 changes: 2 additions & 2 deletions adminui/cascacheview.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$context = context_system::instance();
require_capability('qtype/stack:usediagnostictools', $context);

$urlparams = array();
$urlparams = [];

$context = context_system::instance();
$PAGE->set_context($context);
Expand All @@ -57,7 +57,7 @@
// Ends with $ which is bad.
// Now can contain $ signs elsewhere as well...
$ast = maxima_parser_utils::parse(str_replace('$', ';', $item->command));
$str = $ast->toString(array('pretty' => true));
$str = $ast->toString(['pretty' => true]);
$str = str_replace('&', '&amp;', $str);
$str = str_replace('<', '&lt;', $str);
$str = str_replace('>', '&gt;', $str);
Expand Down
42 changes: 21 additions & 21 deletions adminui/caschat.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$context = context_system::instance();
$PAGE->set_context($context);
require_capability('qtype/stack:usediagnostictools', $context);
$urlparams = array();
$urlparams = [];
} else {
// Load the necessary data.
if ($qubaid !== '') {
Expand All @@ -57,7 +57,7 @@
} else {
$question = question_bank::load_question($questionid);
}
$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
$questiondata = $DB->get_record('question', ['id' => $questionid], '*', MUST_EXIST);

// Process any other URL parameters, and do require_login.
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($question);
Expand All @@ -73,7 +73,7 @@
$displaytext = '';
$debuginfo = '';
$errs = '';
$varerrs = array();
$varerrs = [];

if ($qubaid !== '' && optional_param('initialise', '', PARAM_RAW)) {
// ISS-1110 Handle calls from questiontestrun.php.
Expand Down Expand Up @@ -124,14 +124,14 @@
$options->set_site_defaults();
$options->set_option('simplify', $simp);

$session = new stack_cas_session2(array(), $options);
$session = new stack_cas_session2([], $options);
if ($vars || $inps) {
$keyvals = new stack_cas_keyval($vars . "\n" . $inps, $options, 0);
$keyvals->get_valid();
$varerrs = $keyvals->get_errors();
if ($keyvals->get_valid()) {
$kvcode = $keyvals->compile('test');
$statements = array();
$statements = [];
if ($kvcode['contextvariables']) {
$statements[] = new stack_secure_loader($kvcode['contextvariables'], 'caschat');
}
Expand All @@ -155,7 +155,7 @@
$errs = array_merge($errs, $session->get_errors(false));
if ($errs) {
$errs = stack_string_error('errors') . ': ' . implode(' ', array_unique($errs));
$errs = html_writer::tag('div', $errs, array('class' => 'error'));
$errs = html_writer::tag('div', $errs, ['class' => 'error']);
} else {
$errs = '';
}
Expand All @@ -164,10 +164,10 @@
// Save updated data in the DB when everything is valid.
if ($questionid && $savedb) {
$DB->set_field('question', 'generalfeedback', $string,
array('id' => $questionid));
['id' => $questionid]);
$DB->set_field('qtype_stack_options', 'questionvariables', $vars,
array('questionid' => $questionid));
$DB->set_field('qtype_stack_options', 'compiledcache', null, array('questionid' => $questionid));
['questionid' => $questionid]);
$DB->set_field('qtype_stack_options', 'compiledcache', null, ['questionid' => $questionid]);
// Invalidate the question definition cache.
stack_clear_vle_question_cache($questionid);

Expand All @@ -184,15 +184,15 @@

$qtype = new qtype_stack();
$qtestlink = html_writer::link($qtype->get_question_test_url($question), stack_string('runquestiontests'),
array('class' => 'nav-link'));
echo html_writer::tag('nav', $qtestlink, array('class' => 'nav'));
['class' => 'nav-link']);
echo html_writer::tag('nav', $qtestlink, ['class' => 'nav']);

if ($savedmsg) {
echo html_writer::tag('p', $savedmsg, array('class' => 'overallresult pass'));
echo html_writer::tag('p', $savedmsg, ['class' => 'overallresult pass']);
}

$out = html_writer::tag('summary', stack_string('questiontext'));
$out .= html_writer::tag('pre', $question->questiontext, array('class' => 'questiontext'));
$out .= html_writer::tag('pre', $question->questiontext, ['class' => 'questiontext']);
echo html_writer::tag('details', $out);
}

Expand All @@ -207,17 +207,17 @@
$fout .= html_writer::tag('p', implode($varerrs));
$varlen = substr_count($vars, "\n") + 3;
$fout .= html_writer::tag('p', html_writer::tag('textarea', $vars,
array('cols' => 100, 'rows' => $varlen, 'name' => 'maximavars')));
['cols' => 100, 'rows' => $varlen, 'name' => 'maximavars']));
if ($questionid) {
$inplen = substr_count($inps, "\n");
$fout .= html_writer::tag('p', html_writer::tag('textarea', $inps,
array('cols' => 100, 'rows' => $inplen, 'name' => 'inputs')));
['cols' => 100, 'rows' => $inplen, 'name' => 'inputs']));
}
if ($simp) {
$fout .= stack_string('autosimplify').' '.
html_writer::empty_tag('input', array('type' => 'checkbox', 'checked' => $simp, 'name' => 'simp'));
html_writer::empty_tag('input', ['type' => 'checkbox', 'checked' => $simp, 'name' => 'simp']);
} else {
$fout .= stack_string('autosimplify').' '.html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'simp'));
$fout .= stack_string('autosimplify').' '.html_writer::empty_tag('input', ['type' => 'checkbox', 'name' => 'simp']);
}
if ($questionid) {
$fout .= html_writer::tag('h2', stack_string('generalfeedback'));
Expand All @@ -227,16 +227,16 @@
$fout .= html_writer::tag('p', $errs);
$stringlen = max(substr_count($string, "\n") + 3, 8);
$fout .= html_writer::tag('p', html_writer::tag('textarea', $string,
array('cols' => 100, 'rows' => $stringlen, 'name' => 'cas')));
['cols' => 100, 'rows' => $stringlen, 'name' => 'cas']));
$fout .= html_writer::start_tag('p');
$fout .= html_writer::empty_tag('input',
array('type' => 'submit', 'name' => 'action', 'value' => stack_string('chat')));
['type' => 'submit', 'name' => 'action', 'value' => stack_string('chat')]);
if ($questionid && !$varerrs) {
$fout .= html_writer::empty_tag('input',
array('type' => 'submit', 'name' => 'action', 'value' => stack_string('savechat')));
['type' => 'submit', 'name' => 'action', 'value' => stack_string('savechat')]);
}
$fout .= html_writer::end_tag('p');
echo html_writer::tag('form', $fout, array('action' => $PAGE->url, 'method' => 'post'));
echo html_writer::tag('form', $fout, ['action' => $PAGE->url, 'method' => 'post']);

if ('' != trim($debuginfo)) {
echo $OUTPUT->box($debuginfo);
Expand Down
2 changes: 1 addition & 1 deletion adminui/compiledquestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$context = context_system::instance();
require_capability('qtype/stack:usediagnostictools', $context);

$urlparams = array();
$urlparams = [];

$context = context_system::instance();
$PAGE->set_context($context);
Expand Down
16 changes: 8 additions & 8 deletions adminui/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$context = context_system::instance();
require_capability('qtype/stack:usediagnostictools', $context);

$urlparams = array();
$urlparams = [];

$context = context_system::instance();
$PAGE->set_context($context);
Expand Down Expand Up @@ -87,25 +87,25 @@
' questions that have not been succesfully compiled.</p>';

echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('includes' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['includes' => 1, 'sesskey' => sesskey()]),
'Find "includes"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('jsxgraphs' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['jsxgraphs' => 1, 'sesskey' => sesskey()]),
'Find "jsxgraphs"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('geogebras' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['geogebras' => 1, 'sesskey' => sesskey()]),
'Find "geogebra"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('script' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['script' => 1, 'sesskey' => sesskey()]),
'Find "<script"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('PLUGINFILE' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['PLUGINFILE' => 1, 'sesskey' => sesskey()]),
'Find "@@PLUGINFILE@@"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('langs' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['langs' => 1, 'sesskey' => sesskey()]),
'Find "langs"');
echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('todo' => 1, 'sesskey' => sesskey())),
new moodle_url($PAGE->url, ['todo' => 1, 'sesskey' => sesskey()]),
'Find "todo"');

if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) {
Expand Down
Loading

0 comments on commit f49d45a

Please sign in to comment.