Commit ee0c7e20 authored by Lückemeyer's avatar Lückemeyer
Browse files

fixed short array declaration and last element comma according to moodle approval guidelines

parent 4322671d
Showing with 77 additions and 68 deletions
+77 -68
No preview for this file type
...@@ -49,7 +49,9 @@ function assignsubmission_dta_pluginfile( ...@@ -49,7 +49,9 @@ function assignsubmission_dta_pluginfile(
require_login($course, false, $cm); require_login($course, false, $cm);
$itemid = (int)array_shift($args); $itemid = (int)array_shift($args);
$record = $DB->get_record('assign_submission', $record = $DB->get_record('assign_submission',
array('id' => $itemid), [
'id' => $itemid,
],
'userid, assignment, groupid', 'userid, assignment, groupid',
MUST_EXIST); MUST_EXIST);
$userid = $record->userid; $userid = $record->userid;
......
...@@ -100,7 +100,9 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -100,7 +100,9 @@ class assign_submission_dta extends assign_submission_plugin {
self::COMPONENT_NAME, self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST, self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST,
0, 0,
array('subdirs' => 0) [
'subdirs' => 0,
]
); );
$defaultvalues[self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST] = $draftitemid; $defaultvalues[self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST] = $draftitemid;
...@@ -331,10 +333,17 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -331,10 +333,17 @@ class assign_submission_dta extends assign_submission_plugin {
* @return array * @return array
*/ */
private function get_file_options(bool $settings): array { private function get_file_options(bool $settings): array {
$fileoptions = array('subdirs' => 0, $fileoptions = [
"maxfiles" => 1, 'subdirs' => 0,
'accepted_types' => ($settings ? array(".txt") : array(".txt", ".zip")), "maxfiles" => 1,
'return_types' => FILE_INTERNAL); 'accepted_types' => ($settings
? [".txt"]
: [
".txt",
".zip",
]),
'return_types' => FILE_INTERNAL,
];
return $fileoptions; return $fileoptions;
} }
...@@ -343,10 +352,10 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -343,10 +352,10 @@ class assign_submission_dta extends assign_submission_plugin {
* @return array - An array of fileareas (keys) and descriptions (values) * @return array - An array of fileareas (keys) and descriptions (values)
*/ */
public function get_file_areas() { public function get_file_areas() {
return array( return [
self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION => get_string("dta_submissions_fa", self::COMPONENT_NAME), self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION => get_string("dta_submissions_fa", self::COMPONENT_NAME),
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST => get_string("dta_tests_fa", self::COMPONENT_NAME) self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST => get_string("dta_tests_fa", self::COMPONENT_NAME),
); ];
} }
/** /**
...@@ -357,7 +366,7 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -357,7 +366,7 @@ class assign_submission_dta extends assign_submission_plugin {
* @return array - return an array of files indexed by filename * @return array - return an array of files indexed by filename
*/ */
public function get_files(stdClass $submission, stdClass $user) { public function get_files(stdClass $submission, stdClass $user) {
$result = array(); $result = [];
$fs = get_file_storage(); $fs = get_file_storage();
$files = $fs->get_area_files($this->assignment->get_context()->id, $files = $fs->get_area_files($this->assignment->get_context()->id,
self::COMPONENT_NAME, self::COMPONENT_NAME,
......
...@@ -43,7 +43,7 @@ class DtaResult { ...@@ -43,7 +43,7 @@ class DtaResult {
/** /**
* @return name of state like defined * @return name of state like defined
*/ */
public static function getStateName(int $state): string { public static function getstatename(int $state): string {
if ($state == 1) { if ($state == 1) {
return "success"; return "success";
} else if ($state == 2) { } else if ($state == 2) {
...@@ -88,7 +88,7 @@ class DtaResultSummary { ...@@ -88,7 +88,7 @@ class DtaResultSummary {
* @return array of DtaResult * @return array of DtaResult
*/ */
private static function decodejsonresultarray($jsonarray): array { private static function decodejsonresultarray($jsonarray): array {
$ret = array(); $ret = [];
foreach ($jsonarray as $entry) { foreach ($jsonarray as $entry) {
$value = new DtaResult(); $value = new DtaResult();
$value->packagename = $entry->packageName; $value->packagename = $entry->packageName;
......
...@@ -47,10 +47,10 @@ class DtaBackendUtils { ...@@ -47,10 +47,10 @@ class DtaBackendUtils {
$url = $backendaddress . "/v1/unittest"; $url = $backendaddress . "/v1/unittest";
// Prepare params. // Prepare params.
$params = array( $params = [
"unitTestFile" => $file, "unitTestFile" => $file,
"assignmentId" => $assignment->get_instance()->id "assignmentId" => $assignment->get_instance()->id,
); ];
// If request returned null, return false to indicate failure. // If request returned null, return false to indicate failure.
if (is_null(self::post($url, $params))) { if (is_null(self::post($url, $params))) {
...@@ -97,9 +97,7 @@ class DtaBackendUtils { ...@@ -97,9 +97,7 @@ class DtaBackendUtils {
return false; return false;
} }
$options = array( $options = ["CURLOPT_RETURNTRANSFER" => true];
"CURLOPT_RETURNTRANSFER" => true
);
$curl = new curl(); $curl = new curl();
$response = $curl->post($url, $params, $options); $response = $curl->post($url, $params, $options);
......
...@@ -35,15 +35,15 @@ class DbUtils { ...@@ -35,15 +35,15 @@ class DbUtils {
global $DB; global $DB;
// Fetch data from database. // Fetch data from database.
$summaryrecord = $DB->get_record(self::TABLE_SUMMARY, array( $summaryrecord = $DB->get_record(self::TABLE_SUMMARY, [
"assignment_id" => $assignmentid, "assignment_id" => $assignmentid,
"submission_id" => $submissionid "submission_id" => $submissionid,
)); });
$resultsarray = $DB->get_records(self::TABLE_RESULT, array( $resultsarray = $DB->get_records(self::TABLE_RESULT, [
"assignment_id" => $assignmentid, "assignment_id" => $assignmentid,
"submission_id" => $submissionid "submission_id" => $submissionid,
)); ]);
// Create a summary instance. // Create a summary instance.
$summary = new DtaResultSummary(); $summary = new DtaResultSummary();
...@@ -51,7 +51,7 @@ class DbUtils { ...@@ -51,7 +51,7 @@ class DbUtils {
$summary->globalstacktrace = $summaryrecord->global_stacktrace; $summary->globalstacktrace = $summaryrecord->global_stacktrace;
$summary->successfultestcompetencies = $summaryrecord->successful_competencies; $summary->successfultestcompetencies = $summaryrecord->successful_competencies;
$summary->overalltestcompetencies = $summaryrecord->tested_competencies; $summary->overalltestcompetencies = $summaryrecord->tested_competencies;
$summary->results = array(); $summary->results = [];
// Create result instances and add to array of summary instance. // Create result instances and add to array of summary instance.
foreach ($resultsarray as $rr) { foreach ($resultsarray as $rr) {
...@@ -96,9 +96,9 @@ class DbUtils { ...@@ -96,9 +96,9 @@ class DbUtils {
$summaryrecord->global_stacktrace = $summary->globalstacktrace; $summaryrecord->global_stacktrace = $summary->globalstacktrace;
$summaryrecord->successful_competencies = $summary->successfultestcompetencies; $summaryrecord->successful_competencies = $summary->successfultestcompetencies;
$summaryrecord->tested_competencies = $summary->overalltestcompetencies; $summaryrecord->tested_competencies = $summary->overalltestcompetencies;
// Prepare results to persist to array. // Prepare results to persist to array.
$resultrecords = array(); $resultrecords = [];
foreach ($summary->results as $r) { foreach ($summary->results as $r) {
$record = new stdClass(); $record = new stdClass();
$record->assignment_id = $assignmentid; $record->assignment_id = $assignmentid;
...@@ -117,21 +117,21 @@ class DbUtils { ...@@ -117,21 +117,21 @@ class DbUtils {
} }
// If results already exist, delete old values beforehand. // If results already exist, delete old values beforehand.
$submission = $DB->get_record(self::TABLE_SUMMARY, array( $submission = $DB->get_record(self::TABLE_SUMMARY, [
'assignment_id' => $assignmentid, 'assignment_id' => $assignmentid,
'submission_id' => $submissionid 'submission_id' => $submissionid,
)); ]);
if ($submission) { if ($submission) {
$DB->delete_records(self::TABLE_RESULT, array( $DB->delete_records(self::TABLE_RESULT, [
'assignment_id' => $assignmentid, 'assignment_id' => $assignmentid,
'submission_id' => $submissionid 'submission_id' => $submissionid,
)); ]);
$DB->delete_records(self::TABLE_SUMMARY, array( $DB->delete_records(self::TABLE_SUMMARY, [
'assignment_id' => $assignmentid, 'assignment_id' => $assignmentid,
'submission_id' => $submissionid 'submission_id' => $submissionid,
)); ]);
} }
// Create summary and single result entries. // Create summary and single result entries.
......
...@@ -74,8 +74,8 @@ class ViewSubmissionUtils { ...@@ -74,8 +74,8 @@ class ViewSubmissionUtils {
$html = ""; $html = "";
// Define a few css classes and prepare html attribute arrays to beautify the output. // Define a few css classes and prepare html attribute arrays to beautify the output.
$tableheaderrowattributes = array("class" => "dtaTableHeaderRow"); $tableheaderrowattributes = ["class" => "dtaTableHeaderRow"];
$tablerowattributes = array("class" => "dtaTableRow"); $tablerowattributes = ["class" => "dtaTableRow"];
$resultrowattributes = $tablerowattributes; $resultrowattributes = $tablerowattributes;
$unknownattributes = 'dtaResultUnknown'; $unknownattributes = 'dtaResultUnknown';
$successattributes = 'dtaResultSuccess'; $successattributes = 'dtaResultSuccess';
...@@ -84,14 +84,14 @@ class ViewSubmissionUtils { ...@@ -84,14 +84,14 @@ class ViewSubmissionUtils {
// Summary table. // Summary table.
$tmp = ""; $tmp = "";
$tmp .= html_writer::tag("th", "Summary", array("class" => "dtaTableHeader")); $tmp .= html_writer::tag("th", "Summary", ["class" => "dtaTableHeader"]);
$tmp .= html_writer::empty_tag("th", array("class" => "dtaTableHeader")); $tmp .= html_writer::empty_tag("th", ["class" => "dtaTableHeader"]);
$header = html_writer::tag("tr", $tmp, $tableheaderrowattributes); $header = html_writer::tag("tr", $tmp, $tableheaderrowattributes);
$header = html_writer::tag("thead", $header); $header = html_writer::tag("thead", $header);
$body = ""; $body = "";
$tmp = ""; $tmp = "";
$attributes = array("class" => "dtaTableData"); $attributes = ["class" => "dtaTableData"];
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
"result items in sum", "result items in sum",
...@@ -189,17 +189,17 @@ class ViewSubmissionUtils { ...@@ -189,17 +189,17 @@ class ViewSubmissionUtils {
$body .= html_writer::tag("tr", $tmp, $resultrowattributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes);
$body = html_writer::tag("tbody", $body); $body = html_writer::tag("tbody", $body);
$table = html_writer::tag("table", $header . $body, array("class" => "dtaTable")); $table = html_writer::tag("table", $header . $body, ["class" => "dtaTable"]);
$html .= $table; $html .= $table;
// Add empty div for spacing between summary and details table. // Add empty div for spacing between summary and details table.
$html .= html_writer::empty_tag("div", array("class" => "dtaSpacer")); $html .= html_writer::empty_tag("div", ["class" => "dtaSpacer"]);
// Details table. // Details table.
$tmp = ""; $tmp = "";
$tmp .= html_writer::tag("th", "Details", array("class" => "dtaTableHeader")); $tmp .= html_writer::tag("th", "Details", ["class" => "dtaTableHeader"]);
$tmp .= html_writer::empty_tag("th", array("class" => "dtaTableHeader")); $tmp .= html_writer::empty_tag("th", ["class" => "dtaTableHeader"]);
$header = html_writer::tag("tr", $tmp, $tableheaderrowattributes); $header = html_writer::tag("tr", $tmp, $tableheaderrowattributes);
$header = html_writer::tag("thead", $header); $header = html_writer::tag("thead", $header);
...@@ -291,31 +291,31 @@ class ViewSubmissionUtils { ...@@ -291,31 +291,31 @@ class ViewSubmissionUtils {
} }
if (!is_null($r->columnNumber) && $r->columnNumber > 0) { if (!is_null($r->columnNumber) && $r->columnNumber > 0) {
$tmp = ""; $tmp = "";
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
"column number", "column number",
$attributes); $attributes);
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
$r->columnNumber, $r->columnNumber,
$attributes); $attributes);
$body .= html_writer::tag("tr", $tmp, $resultrowattributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes);
} }
if (!is_null($r->position) && $r->position > 0) { if (!is_null($r->position) && $r->position > 0) {
$tmp = ""; $tmp = "";
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
"position", "position",
$attributes); $attributes);
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
$r->position, $r->position,
$attributes); $attributes);
$body .= html_writer::tag("tr", $tmp, $resultrowattributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes);
} }
$tmp = ""; $tmp = "";
...@@ -326,17 +326,17 @@ class ViewSubmissionUtils { ...@@ -326,17 +326,17 @@ class ViewSubmissionUtils {
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
html_writer::tag("details", $r->stacktrace, array("class" => "dtaStacktraceDetails")), html_writer::tag("details", $r->stacktrace, ["class" => "dtaStacktraceDetails"]),
$attributes); $attributes);
$body .= html_writer::tag("tr", $tmp, $resultrowattributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes);
} }
// Set spacerrow value if null for next rount separation. // Set spacerrow value if null for next rount separation.
if (is_null($spacerrow)) { if (is_null($spacerrow)) {
$spacerrow = html_writer::empty_tag("tr", array("class" => "dtaTableSpacer")); $spacerrow = html_writer::empty_tag("tr", ["class" => "dtaTableSpacer"]);
} }
} }
$html .= html_writer::tag("table", $header . $body, array("class" => "dtaTable")); $html .= html_writer::tag("table", $header . $body, ["class" => "dtaTable"]);
// Wrap generated html into final div. // Wrap generated html into final div.
$html = html_writer::div($html, "dtaSubmissionDetails"); $html = html_writer::div($html, "dtaSubmissionDetails");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment