Commit 0e5e6553 authored by Kurzenberger's avatar Kurzenberger
Browse files

changed all functionnames to assignsubmission_dta_*

parent 3f495ebe
1 merge request!1Coding style and recommendations
Pipeline #10744 passed with stage
Showing with 158 additions and 142 deletions
+158 -142
......@@ -145,11 +145,11 @@ The "assign_submission_plugin" class serves as an abstract foundation that all a
The following provides brief descriptions of a selection of functions to illustrate the types of hooks available:
• get_settings(): This function comes into play during the creation of the assignment settings page. For the MoDTA plugin, this involves adding a file manager that permits teachers to upload their test repo and docker Image URI as a textfile. This function is overridden from the assign_plugin class.
assignsubmission_dta_get_settings(): This function comes into play during the creation of the assignment settings page. For the MoDTA plugin, this involves adding a file manager that permits teachers to upload their test repo and docker Image URI as a textfile. This function is overridden from the assign_plugin class.
save_settings(): The save_settings function is invoked when the assignment settings page is submitted, whether for a new assignment or the modification of an existing one. In the MoDTA plugin, this function is responsible for preserving the text file chosen by the teacher and transmitting the file to the backend web service. Like the previous function, this one is overridden from the assign_plugin class.
assignsubmission_dta_save_settings(): The assignsubmission_dta_save_settings function is invoked when the assignment settings page is submitted, whether for a new assignment or the modification of an existing one. In the MoDTA plugin, this function is responsible for preserving the text file chosen by the teacher and transmitting the file to the backend web service. Like the previous function, this one is overridden from the assign_plugin class.
• get_form_elements_for_user(): During the construction of the submission form, this function plays a similar role to the get_settings() function for settings. In the context of the MoDTA plugin, it adds a file manager to enable students to upload their text or zip file. Once again, this function is overridden from the assign_plugin class.
• get_form_elements_for_user(): During the construction of the submission form, this function plays a similar role to the assignsubmission_dta_get_settings() function for settings. In the context of the MoDTA plugin, it adds a file manager to enable students to upload their text or zip file. Once again, this function is overridden from the assign_plugin class.
• save():This function is invoked to save a user's submission. Within the MoDTA plugin, this function sends the student's submission to the backend and receives the result as the response. For details see the technical details section above.
......
......@@ -145,11 +145,11 @@ The "assign_submission_plugin" class serves as an abstract foundation that all a
The following provides brief descriptions of a selection of functions to illustrate the types of hooks available:
• get_settings(): This function comes into play during the creation of the assignment settings page. For the MoDTA plugin, this involves adding a file manager that permits teachers to upload their test repo and docker Image URI as a textfile. This function is overridden from the assign_plugin class.
assignsubmission_dta_get_settings(): This function comes into play during the creation of the assignment settings page. For the MoDTA plugin, this involves adding a file manager that permits teachers to upload their test repo and docker Image URI as a textfile. This function is overridden from the assign_plugin class.
save_settings(): The save_settings function is invoked when the assignment settings page is submitted, whether for a new assignment or the modification of an existing one. In the MoDTA plugin, this function is responsible for preserving the text file chosen by the teacher and transmitting the file to the backend web service. Like the previous function, this one is overridden from the assign_plugin class.
assignsubmission_dta_save_settings(): The assignsubmission_dta_save_settings function is invoked when the assignment settings page is submitted, whether for a new assignment or the modification of an existing one. In the MoDTA plugin, this function is responsible for preserving the text file chosen by the teacher and transmitting the file to the backend web service. Like the previous function, this one is overridden from the assign_plugin class.
• get_form_elements_for_user(): During the construction of the submission form, this function plays a similar role to the get_settings() function for settings. In the context of the MoDTA plugin, it adds a file manager to enable students to upload their text or zip file. Once again, this function is overridden from the assign_plugin class.
• get_form_elements_for_user(): During the construction of the submission form, this function plays a similar role to the assignsubmission_dta_get_settings() function for settings. In the context of the MoDTA plugin, it adds a file manager to enable students to upload their text or zip file. Once again, this function is overridden from the assign_plugin class.
• save():This function is invoked to save a user's submission. Within the MoDTA plugin, this function sends the student's submission to the backend and receives the result as the response. For details see the technical details section above.
......
......@@ -24,29 +24,29 @@ namespace assignsubmission_dta;
*/
use assignsubmission_dta\dta_backend_utils;
use assignsubmission_dta\view_submission_utils;
use assignsubmission_dta\dta_view_submission_utils;
use assignsubmission_dta\models\dta_result;
use assignsubmission_dta\models\dta_result_summary;
use assignsubmission_dta\models\dta_recommendation;
class db_utils {
class dta_db_utils {
/**
* Summary database table name.
*/
private const TABLE_SUMMARY = "assignsubmission_dta_summary";
private const ASSIGNSUBMISSION_DTA_TABLE_SUMMARY = "assignsubmission_dta_summary";
/**
* Result database table name.
*/
private const TABLE_RESULT = "assignsubmission_dta_result";
private const ASSIGNSUBMISSION_DTA_TABLE_RESULT = "assignsubmission_dta_result";
private const TABLE_RECOMMENDATIONS = "assignsubmission_dta_recommendations";
private const ASSIGNSUBMISSION_DTA_TABLE_RECOMMENDATIONS = "assignsubmission_dta_recommendations";
public static function get_recommendations_from_database(int $assignmentid, int $submissionid): array {
public static function assignsubmission_dta_get_recommendations_from_database(int $assignmentid, int $submissionid): array {
global $DB,$USER;
$userid = $USER->id;
// Schritt 1: Alle Empfehlungen abrufen
$records = $DB->get_records(self::TABLE_RECOMMENDATIONS, [
$records = $DB->get_records(self::ASSIGNSUBMISSION_DTA_TABLE_RECOMMENDATIONS, [
'assignment_id' => $assignmentid,
'submission_id' => $submissionid,
]);
......@@ -102,19 +102,19 @@ class db_utils {
* @param int $submissionid submission id to search for
* @return DttResultSummary representing given submission
*/
public static function get_result_summary_from_database(
public static function assignsubmission_dta_get_result_summary_from_database(
int $assignmentid,
int $submissionid
): dta_result_summary {
global $DB;
// Fetch data from database.
$summaryrecord = $DB->get_record(self::TABLE_SUMMARY, [
$summaryrecord = $DB->get_record(self::ASSIGNSUBMISSION_DTA_TABLE_SUMMARY, [
"assignment_id" => $assignmentid,
"submission_id" => $submissionid,
]);
$resultsarray = $DB->get_records(self::TABLE_RESULT, [
$resultsarray = $DB->get_records(self::ASSIGNSUBMISSION_DTA_TABLE_RESULT, [
"assignment_id" => $assignmentid,
"submission_id" => $submissionid,
]);
......@@ -146,7 +146,7 @@ class db_utils {
return $summary;
}
public static function store_recommendations_to_database(
public static function assignsubmission_dta_store_recommendations_to_database(
int $assignmentid,
int $submissionid,
array $recommendations
......@@ -196,7 +196,7 @@ class db_utils {
* @param int $submissionid submission of this result
* @param dta_result_summary $summary instance to persist
*/
public static function store_result_summary_to_database(
public static function assignsubmission_dta_store_result_summary_to_database(
int $assignmentid,
int $submissionid,
dta_result_summary $summary
......@@ -232,39 +232,39 @@ class db_utils {
}
// If results already exist, delete old values beforehand.
$submission = $DB->get_record(self::TABLE_SUMMARY, [
$submission = $DB->get_record(self::ASSIGNSUBMISSION_DTA_TABLE_SUMMARY, [
'assignment_id' => $assignmentid,
'submission_id' => $submissionid,
]);
if ($submission) {
$DB->delete_records(self::TABLE_RESULT, [
$DB->delete_records(self::ASSIGNSUBMISSION_DTA_TABLE_RESULT, [
'assignment_id' => $assignmentid,
'submission_id' => $submissionid,
]);
$DB->delete_records(self::TABLE_SUMMARY, [
$DB->delete_records(self::ASSIGNSUBMISSION_DTA_TABLE_SUMMARY, [
'assignment_id' => $assignmentid,
'submission_id' => $submissionid,
]);
}
// Create summary and single result entries.
$DB->insert_record(self::TABLE_SUMMARY, $summaryrecord);
$DB->insert_record(self::ASSIGNSUBMISSION_DTA_TABLE_SUMMARY, $summaryrecord);
foreach ($resultrecords as $rr) {
$DB->insert_record(self::TABLE_RESULT, $rr);
$DB->insert_record(self::ASSIGNSUBMISSION_DTA_TABLE_RESULT, $rr);
}
}
/**
* cleans up database if plugin is uninstalled
*/
public static function uninstall_plugin_cleaup(): void {
public static function assignsubmission_dta_uninstall_plugin_cleaup(): void {
global $DB;
$DB->delete_records(self::TABLE_RESULT, null);
$DB->delete_records(self::TABLE_SUMMARY, null);
$DB->delete_records(self::TABLE_RECOMMENDATIONS, null);
$DB->delete_records(self::ASSIGNSUBMISSION_DTA_TABLE_RESULT, null);
$DB->delete_records(self::ASSIGNSUBMISSION_DTA_TABLE_SUMMARY, null);
$DB->delete_records(self::ASSIGNSUBMISSION_DTA_TABLE_RECOMMENDATIONS, null);
}
......
......@@ -39,17 +39,17 @@ class dta_backend_utils {
/**
* Component name for the plugin.
*/
const COMPONENT_NAME = 'assignsubmission_dta';
const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = 'assignsubmission_dta';
/**
* Returns the base URL of the backend webservice as configured in the administration settings.
* @return string Backend host base URL
*/
private static function get_backend_baseurl(): string {
$backendaddress = get_config(self::COMPONENT_NAME, 'backendHost');
private static function assignsubmission_dta_get_backend_baseurl(): string {
$backendaddress = get_config(self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME, 'backendHost');
if (empty($backendaddress)) {
\core\notification::error(get_string('backendHost_not_set', self::COMPONENT_NAME));
\core\notification::error(get_string('backendHost_not_set', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
}
return $backendaddress;
......@@ -62,8 +62,8 @@ class dta_backend_utils {
* @param \stored_file $file Uploaded test-config
* @return bool True if no error occurred
*/
public static function send_testconfig_to_backend($assignment, $file): bool {
$backendaddress = self::get_backend_baseurl();
public static function assignsubmission_dta_send_testconfig_to_backend($assignment, $file): bool {
$backendaddress = self::assignsubmission_dta_get_backend_baseurl();
if (empty($backendaddress)) {
return true;
}
......@@ -78,7 +78,7 @@ class dta_backend_utils {
];
// If request returned null, return false to indicate failure.
if (is_null(self::post($url, $params))) {
if (is_null(self::dta_post($url, $params))) {
return false;
} else {
return true;
......@@ -93,8 +93,8 @@ class dta_backend_utils {
* @param \stored_file $file Submission config file or archive with submission
* @return string|null JSON string with test results or null on error
*/
public static function send_submission_to_backend($assignment, $submissionid, $file): ?string {
$backendaddress = self::get_backend_baseurl();
public static function assignsubmission_dta_send_submission_to_backend($assignment, $submissionid, $file): ?string {
$backendaddress = self::assignsubmission_dta_get_backend_baseurl();
if (empty($backendaddress)) {
return null;
}
......@@ -108,7 +108,7 @@ class dta_backend_utils {
'assignmentId' => $assignment->get_instance()->id,
];
return self::post($url, $params);
return self::assignsubmission_dta_post($url, $params);
}
/**
......@@ -118,7 +118,7 @@ class dta_backend_utils {
*
* @return string|null Received body on success or null on error
*/
private static function post($url, $params): ?string {
private static function assignsubmission_dta_post($url, $params): ?string {
if (!isset($url) || !isset($params)) {
return null;
}
......@@ -135,16 +135,16 @@ class dta_backend_utils {
}
// Something went wrong, return null and give an error message.
debugging(self::COMPONENT_NAME . ': Post file to server was not successful: http_code=' . $info['http_code']);
debugging(self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME . ': Post file to server was not successful: http_code=' . $info['http_code']);
if ($info['http_code'] >= 400 && $info['http_code'] < 500) {
\core\notification::error(get_string('http_client_error_msg', self::COMPONENT_NAME));
\core\notification::error(get_string('http_client_error_msg', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
return null;
} else if ($info['http_code'] >= 500 && $info['http_code'] < 600) {
\core\notification::error(get_string('http_server_error_msg', self::COMPONENT_NAME));
\core\notification::error(get_string('http_server_error_msg', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
return null;
} else {
\core\notification::error(get_string('http_unknown_error_msg', self::COMPONENT_NAME) . $info['http_code'] . $response);
\core\notification::error(get_string('http_unknown_error_msg', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) . $info['http_code'] . $response);
return null;
}
}
......
......@@ -21,18 +21,18 @@ namespace assignsubmission_dta;
* @package assignsubmission_dta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use assignsubmission_dta\db_utils;
use assignsubmission_dta\dta_db_utils;
use assignsubmission_dta\dta_backend_utils;
use assignsubmission_dta\models\dta_result;
use assignsubmission_dta\models\dta_result_summary;
use assignsubmission_dta\models\dta_recommendation;
class view_submission_utils {
class dta_view_submission_utils {
/**
* Broadly used in logic, parametrized for easier change.
*/
const COMPONENT_NAME = "assignsubmission_dta";
const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = "assignsubmission_dta";
/**
* generates a short summary html
......@@ -41,13 +41,13 @@ class view_submission_utils {
* @param int $submissionid submission to create a report for
* @return string html
*/
public static function generate_summary_html(
public static function assignsubmission_dta_generate_summary_html(
int $assignmentid,
int $submissionid
): string {
// Fetch data.
$summary = db_utils::get_Result_Summary_From_Database($assignmentid, $submissionid);
$summary = dta_db_utils::assignsubmission_dta_get_result_summary_from_database($assignmentid, $submissionid);
$html = "";
// Calculate success rate, if no unknown result states or compilation errors.
......@@ -61,14 +61,14 @@ class view_submission_utils {
$html .= ($summary->compilation_error_count() == 0 && $summary->unknown_count() == 0)
? $summary->result_Count() . " (" . $successrate . "%)"
: "?";
$html .= get_string("tests_successful", self::COMPONENT_NAME) . "<br />";
$html .= get_string("tests_successful", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) . "<br />";
if ($summary->compilation_error_count() > 0) {
$html .= $summary->compilation_error_count() . get_string("compilation_errors", self::COMPONENT_NAME) . "<br />";
$html .= $summary->compilation_error_count() . get_string("compilation_errors", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) . "<br />";
}
if ($summary->unknown_count() > 0) {
$html .= $summary->unknown_count() . get_string("unknown_state", self::COMPONENT_NAME) . "<br />";
$html .= $summary->unknown_count() . get_string("unknown_state", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) . "<br />";
}
$showncompetencies = explode(";", $summary->successfultestcompetencies);
......@@ -80,12 +80,12 @@ class view_submission_utils {
$comp = $overallcompetencies[$index];
// If the competency was actually assessed by the assignment and tests, add a summary entry.
if ($shown != "0") {
$tmp .= get_string("comp" . $index, self::COMPONENT_NAME) .
$tmp .= get_string("comp" . $index, self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) .
" " . 100 * floatval($shown) / floatval($comp) . "% " . "<br />";
}
}
$html .= get_string("success_competencies", self::COMPONENT_NAME) . "<br />" . $tmp . "<br />";
$html .= get_string("success_competencies", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME) . "<br />" . $tmp . "<br />";
return \html_writer::div($html, "dtaSubmissionSummary");
}
......@@ -96,14 +96,14 @@ class view_submission_utils {
* @param int $assignmentid assignment
* @param int $submissionid submission to create a report for
*/
public static function generate_detail_html(
public static function assignsubmission_dta_generate_detail_html(
int $assignmentid,
int $submissionid
): string {
// Fetch data.
$summary = db_utils::get_result_summary_from_database($assignmentid, $submissionid);
$recommendations = db_utils::get_recommendations_from_database($assignmentid, $submissionid);
$summary = dta_db_utils::assignsubmission_dta_get_result_summary_from_database($assignmentid, $submissionid);
$recommendations = dta_db_utils::assignsubmission_dta_get_recommendations_from_database($assignmentid, $submissionid);
$html = "";
......@@ -122,7 +122,7 @@ public static function generate_detail_html(
// ***************
$tmp = "";
$tmp .= \html_writer::tag("th", get_string("summary", self::COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::tag("th", get_string("summary", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::empty_tag("th", ["class" => "dtaTableHeader"]);
$header = \html_writer::tag("tr", $tmp, $tableheaderrowattributes);
$header = \html_writer::tag("thead", $header);
......@@ -131,7 +131,7 @@ public static function generate_detail_html(
// Total items.
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("total_items", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("total_items", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $summary->result_count(), $attributes);
$resultrowattributes = $tablerowattributes;
$resultrowattributes['class'] .= " " . $unknownattributes;
......@@ -139,7 +139,7 @@ public static function generate_detail_html(
// Tests successful.
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("tests_successful", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("tests_successful", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $summary->successful_count(), $attributes);
$resultrowattributes = $tablerowattributes;
$successrate = "?";
......@@ -159,7 +159,7 @@ public static function generate_detail_html(
// Failures.
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("failures", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("failures", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $summary->failed_count(), $attributes);
$resultrowattributes = $tablerowattributes;
if ($summary->failed_count() > 0) {
......@@ -171,7 +171,7 @@ public static function generate_detail_html(
// Compilation errors.
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("compilation_errors", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("compilation_errors", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $summary->compilation_error_count(), $attributes);
$resultrowattributes = $tablerowattributes;
if ($summary->compilation_error_count() > 0) {
......@@ -183,7 +183,7 @@ public static function generate_detail_html(
// Unknown state.
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("unknown_state", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("unknown_state", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $summary->unknown_count(), $attributes);
$resultrowattributes = $tablerowattributes;
if ($summary->unknown_count() > 0) {
......@@ -195,7 +195,7 @@ public static function generate_detail_html(
// Success rate.
$tmp = "";
$tmp .= \html_writer::tag("td", \html_writer::tag("b", get_string("success_rate", self::COMPONENT_NAME)), $attributes);
$tmp .= \html_writer::tag("td", \html_writer::tag("b", get_string("success_rate", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME)), $attributes);
$tmp .= \html_writer::tag(
"td",
\html_writer::tag("b", $summary->successful_count() . "/" .
......@@ -266,7 +266,7 @@ public static function generate_detail_html(
}
});
$html .= \html_writer::tag('h3', get_string('recommendations', self::COMPONENT_NAME));
$html .= \html_writer::tag('h3', get_string('recommendations', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
$generate_sortable_header = function($column_name, $display_name) use ($sortby, $sortdir) {
$new_sortdir = ($sortby == $column_name && $sortdir == 'asc') ? 'desc' : 'asc';
......@@ -305,11 +305,11 @@ public static function generate_detail_html(
// Table header for recommendations.
$tableheader = "";
$tableheader .= $generate_sortable_header('topic', get_string("topic", self::COMPONENT_NAME));
$tableheader .= $generate_sortable_header('exercise_name', get_string("exercise_name", self::COMPONENT_NAME));
$tableheader .= \html_writer::tag("th", get_string("url", self::COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tableheader .= $generate_sortable_header('difficulty', get_string("difficulty", self::COMPONENT_NAME));
$tableheader .= $generate_sortable_header('score', get_string("score", self::COMPONENT_NAME));
$tableheader .= $generate_sortable_header('topic', get_string("topic", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
$tableheader .= $generate_sortable_header('exercise_name', get_string("exercise_name", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
$tableheader .= \html_writer::tag("th", get_string("url", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tableheader .= $generate_sortable_header('difficulty', get_string("difficulty", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
$tableheader .= $generate_sortable_header('score', get_string("score", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
$tableheader = \html_writer::tag("tr", $tableheader, ["class" => "dtaTableHeaderRow"]);
$tableheader = \html_writer::tag("thead", $tableheader);
......@@ -339,7 +339,7 @@ public static function generate_detail_html(
// ***************
$body = "";
$tmp = "";
$tmp .= \html_writer::tag("th", get_string("competencies", self::COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::tag("th", get_string("competencies", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::empty_tag("th", ["class" => "dtaTableHeader"]);
$header = \html_writer::tag("tr", $tmp, $tableheaderrowattributes);
$header = \html_writer::tag("thead", $header);
......@@ -354,9 +354,9 @@ public static function generate_detail_html(
if ($comp != "0") {
$resultrowattributes = $tablerowattributes;
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("comp" . $index, self::COMPONENT_NAME), $resultrowattributes);
$tmp .= \html_writer::tag("td", get_string("comp" . $index, self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $resultrowattributes);
$tmp .= \html_writer::tag("td", (100 * floatval($shown) / floatval($comp)) . "% (" . $shown . " / " . $comp . ")", $resultrowattributes);
$tmp .= \html_writer::tag("td", get_string("comp_expl" . $index, self::COMPONENT_NAME), $resultrowattributes);
$tmp .= \html_writer::tag("td", get_string("comp_expl" . $index, self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $resultrowattributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
}
}
......@@ -371,7 +371,7 @@ public static function generate_detail_html(
// ***************
$tmp = "";
$tmp .= \html_writer::tag("th", get_string("details", self::COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::tag("th", get_string("details", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), ["class" => "dtaTableHeader"]);
$tmp .= \html_writer::empty_tag("th", ["class" => "dtaTableHeader"]);
$header = \html_writer::tag("tr", $tmp, $tableheaderrowattributes);
$header = \html_writer::tag("thead", $header);
......@@ -398,54 +398,54 @@ public static function generate_detail_html(
}
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("package_name", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("package_name", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->packagename, $attributes);
$tmp .= \html_writer::tag("td", get_string("unit_name", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("unit_name", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->classname, $attributes);
$tmp .= \html_writer::tag("td", get_string("test_name", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("test_name", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->name, $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("status", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", dta_result::get_statename($r->state), $attributes);
$tmp .= \html_writer::tag("td", get_string("status", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", dta_result::assignsubmission_dta_get_statename($r->state), $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
// If state is different than successful, show additional info.
if ($r->state != 1) {
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("failure_type", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("failure_type", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->failureType, $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("failure_reason", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("failure_reason", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->failureReason, $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
if (!is_null($r->lineNumber) && $r->lineNumber > 0) {
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("line_no", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("line_no", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->lineNumber, $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
}
if (!is_null($r->columnNumber) && $r->columnNumber > 0) {
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("col_no", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("col_no", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$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", get_string("pos", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("pos", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", $r->position, $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
}
$tmp = "";
$tmp .= \html_writer::tag("td", get_string("stacktrace", self::COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", get_string("stacktrace", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME), $attributes);
$tmp .= \html_writer::tag("td", \html_writer::tag("details", $r->stacktrace, ["class" => "dtaStacktraceDetails"]), $attributes);
$body .= \html_writer::tag("tr", $tmp, $resultrowattributes);
}
......
......@@ -66,7 +66,7 @@ class dta_recommendation {
* @param string $jsonstring JSON string containing recommendations
* @return array Array of DtaRecommendation objects
*/
public static function decode_json_recommendations(string $jsonstring): array {
public static function assignsubmission_dta_decode_json_recommendations(string $jsonstring): array {
$response = json_decode($jsonstring);
$recommendations = [];
......
......@@ -38,7 +38,7 @@ class dta_result {
/**
* Broadly used in logic, parametrized for easier change.
*/
const COMPONENT_NAME = 'assignsubmission_dta';
const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = 'assignsubmission_dta';
/**
* @var string $packagename Package name of the test.
......@@ -100,15 +100,15 @@ class dta_result {
* @param int $state Number of the state
* @return string Name of state as defined
*/
public static function get_statename(int $state): string {
public static function assignsubmission_dta_get_statename(int $state): string {
if ($state == 1) {
return get_string('tests_successful', self::COMPONENT_NAME);
return get_string('tests_successful', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
} else if ($state == 2) {
return get_string('failures', self::COMPONENT_NAME);
return get_string('failures', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
} else if ($state == 3) {
return get_string('compilation_errors', self::COMPONENT_NAME);
return get_string('compilation_errors', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
} else {
return get_string('unknown_state', self::COMPONENT_NAME);
return get_string('unknown_state', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
}
}
}
......@@ -66,7 +66,7 @@ class dta_result_summary {
* @param string $jsonstring JSON string containing DtaResultSummary
* @return DtaResultSummary The result summary
*/
public static function decode_json(string $jsonstring): dta_result_summary {
public static function assignsubmission_dta_decode_json(string $jsonstring): dta_result_summary {
$response = json_decode($jsonstring);
$summary = new dta_result_summary();
......@@ -76,7 +76,7 @@ class dta_result_summary {
$summary->successfultestcompetencies = $response->successfulTestCompetencyProfile ?? '';
$summary->overalltestcompetencies = $response->overallTestCompetencyProfile ?? '';
$summary->results = self::decode_json_result_array($response->results);
$summary->results = self::assignsubmission_dta_decode_json_result_array($response->results);
return $summary;
}
......@@ -87,7 +87,7 @@ class dta_result_summary {
* @param array $jsonarray Decoded JSON array of results
* @return array Array of DtaResult
*/
private static function decode_json_result_array(array $jsonarray): array {
private static function assignsubmission_dta_decode_json_result_array(array $jsonarray): array {
$ret = [];
foreach ($jsonarray as $entry) {
$value = new dta_result();
......@@ -115,7 +115,7 @@ class dta_result_summary {
*
* @return int Count of occurrences
*/
public function result_count(): int {
public function assignsubmission_dta_result_count(): int {
return count($this->results);
}
......@@ -125,7 +125,7 @@ class dta_result_summary {
* @param int $state State ordinal number
* @return int Count of occurrences for the provided state
*/
public function state_occurence_count(int $state): int {
public function assignsubmission_dta_state_occurence_count(int $state): int {
$num = 0;
foreach ($this->results as $r) {
if ($r->state == $state) {
......@@ -140,8 +140,8 @@ class dta_result_summary {
*
* @return int Count of occurrences
*/
public function compilation_error_count(): int {
return $this->state_occurence_count(3);
public function assignsubmission_dta_compilation_error_count(): int {
return $this->assignsubmission_dta_state_occurence_count(3);
}
/**
......@@ -149,8 +149,8 @@ class dta_result_summary {
*
* @return int Count of occurrences
*/
public function failed_count(): int {
return $this->state_occurence_count(2);
public function assignsubmission_dta_failed_count(): int {
return $this->assignsubmission_dta_state_occurence_count(2);
}
/**
......@@ -158,8 +158,8 @@ class dta_result_summary {
*
* @return int Count of occurrences
*/
public function successful_count(): int {
return $this->state_occurence_count(1);
public function assignsubmission_dta_successful_count(): int {
return $this->assignsubmission_dta_state_occurence_count(1);
}
/**
......@@ -167,7 +167,7 @@ class dta_result_summary {
*
* @return int Count of occurrences
*/
public function unknown_count(): int {
return $this->state_occurence_count(0);
public function assignsubmission_dta_unknown_count(): int {
return $this->assignsubmission_dta_state_occurence_count(0);
}
}
......@@ -16,6 +16,8 @@
namespace assignsubmission_dta\privacy;
use assign_submission_dta;
use assignsubmission_dta\dta_db_utils;
use core_privacy\local\metadata\collection;
use core_privacy\local\request\writer;
use core_privacy\local\request\contextlist;
......@@ -81,6 +83,20 @@ class provider implements \core_privacy\local\metadata\provider,
'privacy:metadata:assignsubmission_dta_result'
);
$collection->add_database_table(
'assignsubmission_dta_recommendations',
[
'assignmentid' => 'privacy:metadata:assignsubmission_dta_summary:assignmentid',
'submissionid' => 'privacy:metadata:assignsubmission_dta_summary:submissionid',
'topic' => 'privacy:metadata:assignsubmission_dta_recommendations:topic',
'exercise_name' => 'privacy:metadata:assignsubmission_dta_recommendations:exercise_name',
'url' => 'privacy:metadata:assignsubmission_dta_recommendations:url',
'difficulty' => 'privacy:metadata:assignsubmission_dta_recommendations:difficulty',
'score' => 'privacy:metadata:assignsubmission_dta_recommendations:score',
],
'privacy:metadata:assignsubmission_dta_recommendations'
);
$collection->add_external_location_link('dta_backend', [
'assignmentid' => 'privacy:metadata:assignsubmission_dta_summary:assignmentid',
'submissionid' => 'privacy:metadata:assignsubmission_dta_summary:submissionid',
......@@ -139,7 +155,7 @@ class provider implements \core_privacy\local\metadata\provider,
$files = get_files($submission, $user);
foreach ($files as $file) {
$userid = $exportdata->get_pluginobject()->userid;
$dtaresultsummary = DBUtils::getresultsummaryfromdatabase($assign->id, $submission->id);
$dtaresultsummary = dta_db_utils::dta_get_result_summary_from_database($assign->id, $submission->id);
// Submitted file.
writer::with_context($exportdata->get_context())->export_file($exportdata->get_subcontext(), $file)
// DTA result.
......
......@@ -16,9 +16,9 @@
defined('MOODLE_INTERNAL') || die();
use assignsubmission_dta\db_utils;
use assignsubmission_dta\dta_db_utils;
use assignsubmission_dta\dta_backend_utils;
use assignsubmission_dta\view_submission_utils;
use assignsubmission_dta\dta_view_submission_utils;
use assignsubmission_dta\models\dta_result;
use assignsubmission_dta\models\dta_result_summary;
use assignsubmission_dta\models\dta_recommendation;
......@@ -34,7 +34,7 @@ class assign_submission_dta extends assign_submission_plugin {
/**
* Broadly used in logic, parametrized for easier change.
*/
const COMPONENT_NAME = "assignsubmission_dta";
const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = "assignsubmission_dta";
/**
* Draft file area for DTA tests to be uploaded by the teacher.
*/
......@@ -52,8 +52,8 @@ class assign_submission_dta extends assign_submission_plugin {
* Get plugin name
* @return string
*/
public function get_name(): string {
return get_string("pluginname", self::COMPONENT_NAME);
public function assignsubmission_dta_get_name(): string {
return get_string("pluginname", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
}
/**
......@@ -62,12 +62,12 @@ class assign_submission_dta extends assign_submission_plugin {
* @param MoodleQuickForm $mform form to add elements to
* @return void
*/
public function get_settings(MoodleQuickForm $mform): void {
public function assignsubmission_dta_get_settings(MoodleQuickForm $mform): void {
// Add draft filemanager to form.
$mform->addElement(
"filemanager",
self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST,
get_string("submission_settings_label", self::COMPONENT_NAME),
get_string("submission_settings_label", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME),
null,
$this->get_file_options(true)
);
......@@ -79,7 +79,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Key.
"submission_settings_label",
// Language file to use.
self::COMPONENT_NAME
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME
);
// Only show filemanager if plugin is enabled.
......@@ -87,7 +87,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Form-unique element id to hide.
self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST,
// Condition to check.
self::COMPONENT_NAME . '_enabled',
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME . '_enabled',
// State to match for hiding.
'notchecked'
);
......@@ -107,7 +107,7 @@ class assign_submission_dta extends assign_submission_plugin {
file_prepare_draft_area(
$draftitemid,
$this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST,
0,
['subdirs' => 0]
......@@ -122,7 +122,7 @@ class assign_submission_dta extends assign_submission_plugin {
* @param stdClass $data
* @return bool
*/
public function save_settings(stdClass $data): bool {
public function assignsubmission_dta_save_settings(stdClass $data): bool {
// If the assignment has no filemanager for our plugin just leave.
$draftfilemanagerid = self::ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST;
......@@ -136,7 +136,7 @@ class assign_submission_dta extends assign_submission_plugin {
$data->$draftfilemanagerid,
// Id of the assignment in edit.
$this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST,
0
);
......@@ -146,7 +146,7 @@ class assign_submission_dta extends assign_submission_plugin {
$files = $fs->get_area_files(
// Id of the current assignment.
$this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST,
0,
'id',
......@@ -155,7 +155,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Check if a file was uploaded.
if (empty($files)) {
\core\notification::error(get_string("no_testfile_warning", self::COMPONENT_NAME));
\core\notification::error(get_string("no_testfile_warning", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
return true;
}
......@@ -163,7 +163,7 @@ class assign_submission_dta extends assign_submission_plugin {
$file = reset($files);
// Send file to backend.
return dta_backend_utils::send_testconfig_to_backend($this->assignment, $file);
return dta_backend_utils::assignsubmission_dta_send_testconfig_to_backend($this->assignment, $file);
}
/**
......@@ -182,7 +182,7 @@ class assign_submission_dta extends assign_submission_plugin {
'tasks',
$this->get_file_options(false),
$this->assignment->get_context(),
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION,
$submissionorgrade ? $submissionorgrade->id : 0
);
......@@ -193,7 +193,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Form-unique identifier.
'tasks_filemanager',
// Label to show next to the filemanager.
get_string("submission_label", self::COMPONENT_NAME),
get_string("submission_label", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME),
// Attributes.
null,
// Options.
......@@ -207,7 +207,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Key.
"submission_label",
// Language file.
self::COMPONENT_NAME
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME
);
return true;
......@@ -218,8 +218,8 @@ class assign_submission_dta extends assign_submission_plugin {
* @param stdClass $submission submission to check
* @return bool true if file count is zero
*/
public function is_empty(stdClass $submission): bool {
return $this->count_files($submission->id, self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION) == 0;
public function assignsubmission_dta_is_empty(stdClass $submission): bool {
return $this->assignsubmission_dta_count_files($submission->id, self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION) == 0;
}
/**
......@@ -229,10 +229,10 @@ class assign_submission_dta extends assign_submission_plugin {
* @param string $areaid filearea id to count
* @return int number of files submitted in the filearea
*/
private function count_files(int $submissionid, $areaid) {
private function assignsubmission_dta_count_files(int $submissionid, $areaid) {
$fs = get_file_storage();
$files = $fs->get_area_files($this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
$areaid,
$submissionid,
'id',
......@@ -254,13 +254,13 @@ class assign_submission_dta extends assign_submission_plugin {
'tasks',
$this->get_file_options(false),
$this->assignment->get_context(),
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION,
$submission->id
);
// If submission is empty, leave directly.
if ($this->is_empty($submission)) {
if ($this->assignsubmission_dta_is_empty($submission)) {
return true;
}
......@@ -269,7 +269,7 @@ class assign_submission_dta extends assign_submission_plugin {
$files = $fs->get_area_files(
// Id of current assignment.
$this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION,
$submission->id,
'id',
......@@ -278,7 +278,7 @@ class assign_submission_dta extends assign_submission_plugin {
// Check if a file is uploaded.
if (empty($files)) {
\core\notification::error(get_string("no_submissionfile_warning", self::COMPONENT_NAME));
\core\notification::error(get_string("no_submissionfile_warning", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME));
return true;
}
......@@ -286,7 +286,7 @@ class assign_submission_dta extends assign_submission_plugin {
$file = reset($files);
// Send file to backend.
$response = \assignsubmission_dta\dta_backend_utils::send_submission_to_backend($this->assignment, $submission->id, $file);
$response = \assignsubmission_dta\dta_backend_utils::assignsubmission_dta_send_submission_to_backend($this->assignment, $submission->id, $file);
// With a null response, return an error.
if (is_null($response)) {
......@@ -294,18 +294,18 @@ class assign_submission_dta extends assign_submission_plugin {
}
// Convert received JSON to valid class instances.
$resultsummary = dta_result_summary::decode_json($response);
$resultsummary = dta_result_summary::assignsubmission_dta_decode_json($response);
// Decode recommendations from response.
$recommendations = dta_recommendation::decode_json_recommendations($response);
$recommendations = dta_recommendation::assignsubmission_dta_decode_json_recommendations($response);
error_log(print_r($recommendations, true));
// Persist new results to database.
db_utils::store_result_summary_to_database($this->assignment->get_instance()->id, $submission->id, $resultsummary);
dta_db_utils::assignsubmission_dta_store_result_summary_to_database($this->assignment->get_instance()->id, $submission->id, $resultsummary);
// Store the array of recommendations in the database.
db_utils::store_recommendations_to_database($this->assignment->get_instance()->id, $submission->id, $recommendations);
dta_db_utils::assignsubmission_dta_store_recommendations_to_database($this->assignment->get_instance()->id, $submission->id, $recommendations);
return true;
}
......@@ -322,7 +322,7 @@ class assign_submission_dta extends assign_submission_plugin {
public function view_summary(stdClass $submission, & $showviewlink) {
$showviewlink = true;
return view_submission_utils::generate_summary_html(
return dta_view_submission_utils::assignsubmission_dta_generate_summary_html(
$this->assignment->get_instance()->id,
$submission->id
);
......@@ -335,7 +335,7 @@ class assign_submission_dta extends assign_submission_plugin {
* @return string detailed results html
*/
public function view(stdClass $submission) {
return view_submission_utils::generate_detail_html(
return dta_view_submission_utils::assignsubmission_dta_generate_detail_html(
$this->assignment->get_instance()->id,
$submission->id
);
......@@ -370,8 +370,8 @@ class assign_submission_dta extends assign_submission_plugin {
*/
public function get_file_areas() {
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_SUBMISSION => get_string("dta_submissions_fa", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME),
self::ASSIGNSUBMISSION_DTA_FILEAREA_TEST => get_string("dta_tests_fa", self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME),
];
}
......@@ -386,7 +386,7 @@ class assign_submission_dta extends assign_submission_plugin {
$result = [];
$fs = get_file_storage();
$files = $fs->get_area_files($this->assignment->get_context()->id,
self::COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME,
self::ASSIGNSUBMISSION_DTA_FILEAREA_SUBMISSION,
$submission->id,
'timemodified',
......@@ -409,7 +409,7 @@ class assign_submission_dta extends assign_submission_plugin {
* @return bool
*/
public function delete_instance() {
db_utils::uninstall_plugin_cleanup();
dta_db_utils::assignsubmission_dta_uninstall_plugin_cleaup();
return true;
}
......
......@@ -62,7 +62,7 @@ foreach ($list->good as $component) {
foreach ($collection->get_collection() as $item) {
if ($item instanceof \core_privacy\local\metadata\types\user_preference) {
$userprefdescribed = true;
echo " ".$item->get_name()." : ".get_string($item->get_summary(), $component) . "\n";
echo " ".$item->assignsubmission_dta_get_name()." : ".get_string($item->get_summary(), $component) . "\n";
}
}
if (!$userprefdescribed) {
......
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