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(
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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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.
......
......@@ -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");
......
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