diff --git a/dta.zip b/dta.zip index bcedf44ce40e8e836a93f87059f9a6f3eb78b6d7..5281b7ce18750addae2502aa0df9ed896949b248 100644 Binary files a/dta.zip and b/dta.zip differ diff --git a/dta/lib.php b/dta/lib.php index 155b3f238b2fa22d1221908d9a2d9676c296af75..7b20a632f69190d4be9bd8ea8683779c59f3a9d1 100644 --- a/dta/lib.php +++ b/dta/lib.php @@ -49,7 +49,9 @@ function assignsubmission_dta_pluginfile( require_login($course, false, $cm); $itemid = (int)array_shift($args); $record = $DB->get_record('assign_submission', - array('id' => $itemid), + [ + 'id' => $itemid, + ], 'userid, assignment, groupid', MUST_EXIST); $userid = $record->userid; diff --git a/dta/locallib.php b/dta/locallib.php index a218bde67434c1715175cfe7a258a54ce1a82aab..c0f9559065e828dbf1b5dc8688d2c8d7ea66eba8 100644 --- a/dta/locallib.php +++ b/dta/locallib.php @@ -100,7 +100,9 @@ class assign_submission_dta extends assign_submission_plugin { self::COMPONENT_NAME, self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST, 0, - array('subdirs' => 0) + [ + 'subdirs' => 0, + ] ); $defaultvalues[self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST] = $draftitemid; @@ -331,10 +333,17 @@ class assign_submission_dta extends assign_submission_plugin { * @return array */ private function get_file_options(bool $settings): array { - $fileoptions = array('subdirs' => 0, - "maxfiles" => 1, - 'accepted_types' => ($settings ? array(".txt") : array(".txt", ".zip")), - 'return_types' => FILE_INTERNAL); + $fileoptions = [ + 'subdirs' => 0, + "maxfiles" => 1, + 'accepted_types' => ($settings + ? [".txt"] + : [ + ".txt", + ".zip", + ]), + 'return_types' => FILE_INTERNAL, + ]; return $fileoptions; } @@ -343,10 +352,10 @@ class assign_submission_dta extends assign_submission_plugin { * @return array - An array of fileareas (keys) and descriptions (values) */ 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_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 { * @return array - return an array of files indexed by filename */ public function get_files(stdClass $submission, stdClass $user) { - $result = array(); + $result = []; $fs = get_file_storage(); $files = $fs->get_area_files($this->assignment->get_context()->id, self::COMPONENT_NAME, diff --git a/dta/models/DtaResult.php b/dta/models/DtaResult.php index 3a3ff30dc0b16e1565e114c349dc390e545ff946..f56b2284f716bc70c9e85bcb4a43bfa6e6e13795 100644 --- a/dta/models/DtaResult.php +++ b/dta/models/DtaResult.php @@ -43,7 +43,7 @@ class DtaResult { /** * @return name of state like defined */ - public static function getStateName(int $state): string { + public static function getstatename(int $state): string { if ($state == 1) { return "success"; } else if ($state == 2) { @@ -88,7 +88,7 @@ class DtaResultSummary { * @return array of DtaResult */ private static function decodejsonresultarray($jsonarray): array { - $ret = array(); + $ret = []; foreach ($jsonarray as $entry) { $value = new DtaResult(); $value->packagename = $entry->packageName; diff --git a/dta/utils/backend.php b/dta/utils/backend.php index 173352b75a0ceaf6d8ce772b22c1224008131a48..9d8e17f5291126e73fc1ca0a6547b31381d401d9 100644 --- a/dta/utils/backend.php +++ b/dta/utils/backend.php @@ -47,10 +47,10 @@ class DtaBackendUtils { $url = $backendaddress . "/v1/unittest"; // Prepare params. - $params = array( + $params = [ "unitTestFile" => $file, - "assignmentId" => $assignment->get_instance()->id - ); + "assignmentId" => $assignment->get_instance()->id, + ]; // If request returned null, return false to indicate failure. if (is_null(self::post($url, $params))) { @@ -97,9 +97,7 @@ class DtaBackendUtils { return false; } - $options = array( - "CURLOPT_RETURNTRANSFER" => true - ); + $options = ["CURLOPT_RETURNTRANSFER" => true]; $curl = new curl(); $response = $curl->post($url, $params, $options); diff --git a/dta/utils/database.php b/dta/utils/database.php index 0eb238097f1583bbbcb998c2d10c541ce2cc24d5..0821d41b3c51628ef971e9efd8a33198bfb065bf 100644 --- a/dta/utils/database.php +++ b/dta/utils/database.php @@ -35,15 +35,15 @@ class DbUtils { global $DB; // Fetch data from database. - $summaryrecord = $DB->get_record(self::TABLE_SUMMARY, array( + $summaryrecord = $DB->get_record(self::TABLE_SUMMARY, [ "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, - "submission_id" => $submissionid - )); + "submission_id" => $submissionid, + ]); // Create a summary instance. $summary = new DtaResultSummary(); @@ -51,7 +51,7 @@ class DbUtils { $summary->globalstacktrace = $summaryrecord->global_stacktrace; $summary->successfultestcompetencies = $summaryrecord->successful_competencies; $summary->overalltestcompetencies = $summaryrecord->tested_competencies; - $summary->results = array(); + $summary->results = []; // Create result instances and add to array of summary instance. foreach ($resultsarray as $rr) { @@ -96,9 +96,9 @@ class DbUtils { $summaryrecord->global_stacktrace = $summary->globalstacktrace; $summaryrecord->successful_competencies = $summary->successfultestcompetencies; $summaryrecord->tested_competencies = $summary->overalltestcompetencies; - + // Prepare results to persist to array. - $resultrecords = array(); + $resultrecords = []; foreach ($summary->results as $r) { $record = new stdClass(); $record->assignment_id = $assignmentid; @@ -117,21 +117,21 @@ class DbUtils { } // 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, - 'submission_id' => $submissionid - )); + 'submission_id' => $submissionid, + ]); if ($submission) { - $DB->delete_records(self::TABLE_RESULT, array( + $DB->delete_records(self::TABLE_RESULT, [ '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, - 'submission_id' => $submissionid - )); + 'submission_id' => $submissionid, + ]); } // Create summary and single result entries. diff --git a/dta/utils/view.php b/dta/utils/view.php index 2193b61aff076c4b26b3a38ae014a26d64f2ab7a..4ac060f459e2b94f7d5caeb11444e3fe574e57ad 100644 --- a/dta/utils/view.php +++ b/dta/utils/view.php @@ -74,8 +74,8 @@ class ViewSubmissionUtils { $html = ""; // Define a few css classes and prepare html attribute arrays to beautify the output. - $tableheaderrowattributes = array("class" => "dtaTableHeaderRow"); - $tablerowattributes = array("class" => "dtaTableRow"); + $tableheaderrowattributes = ["class" => "dtaTableHeaderRow"]; + $tablerowattributes = ["class" => "dtaTableRow"]; $resultrowattributes = $tablerowattributes; $unknownattributes = 'dtaResultUnknown'; $successattributes = 'dtaResultSuccess'; @@ -84,14 +84,14 @@ class ViewSubmissionUtils { // Summary table. $tmp = ""; - $tmp .= html_writer::tag("th", "Summary", array("class" => "dtaTableHeader")); - $tmp .= html_writer::empty_tag("th", array("class" => "dtaTableHeader")); + $tmp .= html_writer::tag("th", "Summary", ["class" => "dtaTableHeader"]); + $tmp .= html_writer::empty_tag("th", ["class" => "dtaTableHeader"]); $header = html_writer::tag("tr", $tmp, $tableheaderrowattributes); $header = html_writer::tag("thead", $header); $body = ""; $tmp = ""; - $attributes = array("class" => "dtaTableData"); + $attributes = ["class" => "dtaTableData"]; $tmp .= html_writer::tag( "td", "result items in sum", @@ -189,17 +189,17 @@ class ViewSubmissionUtils { $body .= html_writer::tag("tr", $tmp, $resultrowattributes); $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; // 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. $tmp = ""; - $tmp .= html_writer::tag("th", "Details", array("class" => "dtaTableHeader")); - $tmp .= html_writer::empty_tag("th", array("class" => "dtaTableHeader")); + $tmp .= html_writer::tag("th", "Details", ["class" => "dtaTableHeader"]); + $tmp .= html_writer::empty_tag("th", ["class" => "dtaTableHeader"]); $header = html_writer::tag("tr", $tmp, $tableheaderrowattributes); $header = html_writer::tag("thead", $header); @@ -291,31 +291,31 @@ class ViewSubmissionUtils { } if (!is_null($r->columnNumber) && $r->columnNumber > 0) { - $tmp = ""; - $tmp .= html_writer::tag( - "td", - "column number", - $attributes); + $tmp = ""; + $tmp .= html_writer::tag( + "td", + "column number", + $attributes); - $tmp .= html_writer::tag( - "td", - $r->columnNumber, - $attributes); - $body .= html_writer::tag("tr", $tmp, $resultrowattributes); + $tmp .= html_writer::tag( + "td", + $r->columnNumber, + $attributes); + $body .= html_writer::tag("tr", $tmp, $resultrowattributes); } if (!is_null($r->position) && $r->position > 0) { - $tmp = ""; - $tmp .= html_writer::tag( - "td", - "position", - $attributes); + $tmp = ""; + $tmp .= html_writer::tag( + "td", + "position", + $attributes); - $tmp .= html_writer::tag( - "td", - $r->position, - $attributes); - $body .= html_writer::tag("tr", $tmp, $resultrowattributes); + $tmp .= html_writer::tag( + "td", + $r->position, + $attributes); + $body .= html_writer::tag("tr", $tmp, $resultrowattributes); } $tmp = ""; @@ -326,17 +326,17 @@ class ViewSubmissionUtils { $tmp .= html_writer::tag( "td", - html_writer::tag("details", $r->stacktrace, array("class" => "dtaStacktraceDetails")), + html_writer::tag("details", $r->stacktrace, ["class" => "dtaStacktraceDetails"]), $attributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes); } // Set spacerrow value if null for next rount separation. 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. $html = html_writer::div($html, "dtaSubmissionDetails");