Commit 2bb60caf authored by Lückemeyer's avatar Lückemeyer
Browse files

enhanced PHP doc comments

parent 900a01e6
Pipeline #8895 passed with stage
No preview for this file type
...@@ -30,11 +30,11 @@ require_once($CFG->dirroot . '/mod/assign/submission/dta/utils/view.php'); ...@@ -30,11 +30,11 @@ require_once($CFG->dirroot . '/mod/assign/submission/dta/utils/view.php');
*/ */
class assign_submission_dta extends assign_submission_plugin { class assign_submission_dta extends assign_submission_plugin {
/** /**
* Broadly used in logic, parametrized for easier change. * Broadly used in logic, parametrized for easier change.
*/ */
const COMPONENT_NAME = "assignsubmission_dta"; const COMPONENT_NAME = "assignsubmission_dta";
/** /**
* Draft file area for dta tests to be uploaded by the teacher. * Draft file area for dta tests to be uploaded by the teacher.
*/ */
const ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST = "tests_draft_dta"; const ASSIGNSUBMISSION_DTA_DRAFT_FILEAREA_TEST = "tests_draft_dta";
...@@ -168,11 +168,11 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -168,11 +168,11 @@ class assign_submission_dta extends assign_submission_plugin {
/** /**
* Add elements to submission form * Add elements to submission form
* *
* @param mixed $submission stdClass|null * @param mixed $submissionorgrade stdClass|null submission or grade to show in the form
* @param MoodleQuickForm $mform * @param MoodleQuickForm $mform form for adding elements
* @param stdClass $data * @param stdClass $data data for filling the elements
* @param int $userid * @param int $userid current user
* @return bool * @return bool form elements added
*/ */
public function get_form_elements_for_user($submissionorgrade, MoodleQuickForm $mform, stdClass $data, $userid): bool { public function get_form_elements_for_user($submissionorgrade, MoodleQuickForm $mform, stdClass $data, $userid): bool {
// Prepare submission filearea. // Prepare submission filearea.
...@@ -213,6 +213,7 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -213,6 +213,7 @@ class assign_submission_dta extends assign_submission_plugin {
} }
/** /**
* Determines if a submission file area contains any files.
* @param stdClass $submission submission to check * @param stdClass $submission submission to check
* @return bool true if file count is zero * @return bool true if file count is zero
*/ */
...@@ -221,7 +222,7 @@ class assign_submission_dta extends assign_submission_plugin { ...@@ -221,7 +222,7 @@ class assign_submission_dta extends assign_submission_plugin {
} }
/** /**
* Count the number of files in a filearea * Counts the number of files in a filearea
* *
* @param int $submissionid submission id to check * @param int $submissionid submission id to check
* @param string $areaid filearea id to count * @param string $areaid filearea id to count
......
...@@ -25,28 +25,28 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -25,28 +25,28 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class DtaResult { class DtaResult {
/** /**
* Broadly used in logic, parametrized for easier change. * Broadly used in logic, parametrized for easier change.
*/ */
const COMPONENT_NAME = "assignsubmission_dta"; const COMPONENT_NAME = "assignsubmission_dta";
/** /**
* Package name of the test. * @var $packagename Package name of the test.
*/ */
public $packagename; public $packagename;
/** /**
* Unit name of the test. * @var $classname Unit name of the test.
*/ */
public $classname; public $classname;
/** /**
* Name of the test. * @var $name Name of the test.
*/ */
public $name; public $name;
/** /**
* State is defined like below * @var $state State is defined like below
* *
* 0 UNKNOWN * 0 UNKNOWN
* 1 SUCCESS * 1 SUCCESS
...@@ -55,32 +55,32 @@ class DtaResult { ...@@ -55,32 +55,32 @@ class DtaResult {
*/ */
public $state; public $state;
/** /**
* Type of test failure if applicable, "" otherwise. * @var $failuretype Type of test failure if applicable, "" otherwise.
*/ */
public $failuretype; public $failuretype;
/** /**
* Reason of test failure if applicable, "" otherwise. * @var $failurereason Reason of test failure if applicable, "" otherwise.
*/ */
public $failurereason; public $failurereason;
/** /**
* Stack trace of test failure if applicable, "" otherwise. * @var $stacktrace Stack trace of test failure if applicable, "" otherwise.
*/ */
public $stacktrace; public $stacktrace;
/** /**
* Column number of compile failure if applicable, "" otherwise. * @var $columnnumber Column number of compile failure if applicable, "" otherwise.
*/ */
public $columnnumber; public $columnnumber;
/** /**
* Line number of compile failure if applicable, "" otherwise. * @var $linenumber Line number of compile failure if applicable, "" otherwise.
*/ */
public $linenumber; public $linenumber;
/** /**
* Position of compile failure if applicable, "" otherwise. * @var $position Position of compile failure if applicable, "" otherwise.
*/ */
public $position; public $position;
/** /**
...@@ -109,32 +109,32 @@ class DtaResult { ...@@ -109,32 +109,32 @@ class DtaResult {
*/ */
class DtaResultSummary { class DtaResultSummary {
/** /**
* Result timestamp for chronological ordering and deletion of previous results. * @var $timestamp Result timestamp for chronological ordering and deletion of previous results.
*/ */
public $timestamp; public $timestamp;
/** /**
* Global stack trace if applicable, "" otherwise. * @var $globalstacktrace Global stack trace if applicable, "" otherwise.
*/ */
public $globalstacktrace; public $globalstacktrace;
/** /**
* Successfully tested competencies according to tests and weights, "" otherwise. * @var $successfultestcompetencies Successfully tested competencies according to tests and weights, "" otherwise.
*/ */
public $successfultestcompetencies; public $successfultestcompetencies;
/** /**
* Overall tested competencies according to tests and weights, "" otherwise. * @var overalltestcompetencies Overall tested competencies according to tests and weights, "" otherwise.
*/ */
public $overalltestcompetencies; public $overalltestcompetencies;
/** /**
* List of detail results. * @var results List of detail results.
*/ */
public $results; public $results;
/** /**
* Decodes the JSON result summary returned by the backend service call into the plugin PHP data structure. * Decodes the JSON result summary returned by the backend service call into the plugin PHP data structure.
* @param string $jsonString jsonString containing DtaResultSummary * @param string $jsonstring jsonString containing DtaResultSummary
* @return DtaResultSummary * @return DtaResultSummary
*/ */
public static function decodejson($jsonstring): DtaResultSummary { public static function decodejson($jsonstring): DtaResultSummary {
...@@ -154,7 +154,7 @@ class DtaResultSummary { ...@@ -154,7 +154,7 @@ class DtaResultSummary {
/** /**
* Decodes the array of JSON detail results returned by the backend service call into the plugin PHP data structure. * Decodes the array of JSON detail results returned by the backend service call into the plugin PHP data structure.
* @param array $jsonArray decoded json array of results array * @param array $jsonarray decoded json array of results array
* @return array of DtaResult * @return array of DtaResult
*/ */
private static function decodejsonresultarray($jsonarray): array { private static function decodejsonresultarray($jsonarray): array {
......
...@@ -14,9 +14,25 @@ ...@@ -14,9 +14,25 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the backend webservice contact functionality for the DTA plugin
*
* @package assignsubmission_dta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright Gero Lueckemeyer and student project teams
*/
/**
* backend webservice contact utility class
*
* @package assignsubmission_dta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright Gero Lueckemeyer and student project teams
*/
class DtaBackendUtils { class DtaBackendUtils {
/** /**
* Returns the base url of the backend webservice as configured in the administration settings.
* @return string backend host base url * @return string backend host base url
*/ */
private static function getbackendbaseurl(): string { private static function getbackendbaseurl(): string {
...@@ -30,11 +46,10 @@ class DtaBackendUtils { ...@@ -30,11 +46,10 @@ class DtaBackendUtils {
} }
/** /**
* Sends the configuration textfile uploaded by prof to the backend * Sends the configuration textfile uploaded by prof to the backend.
* *
* @param $assignment assignment this test-config belongs to * @param $assignment assignment this test-config belongs to
* @param $file uploaded test-config * @param $file uploaded test-config
*
* @return bool true if no error occurred * @return bool true if no error occurred
*/ */
public static function sendtestconfigtobackend($assignment, $file): bool { public static function sendtestconfigtobackend($assignment, $file): bool {
...@@ -61,11 +76,10 @@ class DtaBackendUtils { ...@@ -61,11 +76,10 @@ class DtaBackendUtils {
} }
/** /**
* Sends sumbission config or archive to backend to be tested * Sends sumbission config or archive to backend to be tested.
* *
* @param $assignment assignment this submission is done for * @param $assignment assignment this submission is done for
* @param $file submission config file or archive with submission * @param $file submission config file or archive with submission
*
* @return string json string with testresults or null on error * @return string json string with testresults or null on error
*/ */
public static function sendsubmissiontobackend($assignment, $file): ?string { public static function sendsubmissiontobackend($assignment, $file): ?string {
...@@ -87,6 +101,7 @@ class DtaBackendUtils { ...@@ -87,6 +101,7 @@ class DtaBackendUtils {
} }
/** /**
* Posts the given params to the given url and returns the response as a string.
* @param string $url full url to request to * @param string $url full url to request to
* @param array $params parameters for http-request * @param array $params parameters for http-request
* *
......
...@@ -14,11 +14,22 @@ ...@@ -14,11 +14,22 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* persistence layer utility class
*
* @package assignsubmission_dta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright Gero Lueckemeyer and student project teams
*/
class DbUtils { class DbUtils {
// Summary database table name. /**
* Summary database table name.
*/
private const TABLE_SUMMARY = "assignsubmission_dta_summary"; private const TABLE_SUMMARY = "assignsubmission_dta_summary";
// Result database table name. /**
* Result database table name.
*/
private const TABLE_RESULT = "assignsubmission_dta_result"; private const TABLE_RESULT = "assignsubmission_dta_result";
/** /**
...@@ -77,9 +88,9 @@ class DbUtils { ...@@ -77,9 +88,9 @@ class DbUtils {
* save given result summary and single results to database * save given result summary and single results to database
* under given assignment and submission id * under given assignment and submission id
* *
* @param int assignmentid assigment this is submission is linked to * @param $assignmentid assigment this is submission is linked to
* @param int submissionid submission of this result * @param $submissionid submission of this result
* @param DttResultSummary instance to persist * @param $summary instance to persist
*/ */
public static function storeresultsummarytodatabase( public static function storeresultsummarytodatabase(
int $assignmentid, int $assignmentid,
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
class view_submission_utils { class view_submission_utils {
/** /**
* Broadly used in logic, parametrized for easier change. * Broadly used in logic, parametrized for easier change.
*/ */
const COMPONENT_NAME = "assignsubmission_dta"; const COMPONENT_NAME = "assignsubmission_dta";
...@@ -31,8 +31,8 @@ class view_submission_utils { ...@@ -31,8 +31,8 @@ class view_submission_utils {
/** /**
* generates a short summary html * generates a short summary html
* *
* @param int assignmentid assignment * @param $assignmentid assignment
* @param int submissionid submission to create a report for * @param $submissionid submission to create a report for
* @return string html * @return string html
*/ */
public static function generatesummaryhtml( public static function generatesummaryhtml(
...@@ -67,17 +67,18 @@ class view_submission_utils { ...@@ -67,17 +67,18 @@ class view_submission_utils {
$showncompetencies = explode(";", $summary->successfultestcompetencies); $showncompetencies = explode(";", $summary->successfultestcompetencies);
$overallcompetencies = explode(";", $summary->overalltestcompetencies); $overallcompetencies = explode(";", $summary->overalltestcompetencies);
$tmp = ""; $tmp = "";
for ($index = 0, $size = count($showncompetencies); $index < $size; $index++) { for ($index = 0, $size = count($showncompetencies); $index < $size; $index++) {
$shown = $showncompetencies[$index]; $shown = $showncompetencies[$index];
$comp = $overallcompetencies[$index]; $comp = $overallcompetencies[$index];
// If the competency was actually assessed by the assignment and tests, add a summary entry. // If the competency was actually assessed by the assignment and tests, add a summary entry.
if($shown!="0") { if ($shown != "0") {
$tmp .= get_string("comp" . $index, self::COMPONENT_NAME) . " " . 100*floatval($shown)/floatval($comp) . "% " . "<br />"; $tmp .= get_string("comp" . $index, self::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::COMPONENT_NAME) . "<br />" . $tmp . "<br />";
return html_writer::div($html, "dtaSubmissionSummary"); return html_writer::div($html, "dtaSubmissionSummary");
...@@ -86,8 +87,8 @@ class view_submission_utils { ...@@ -86,8 +87,8 @@ class view_submission_utils {
/** /**
* generates detailed view html * generates detailed view html
* *
* @param int assignmentid assignment * @param $assignmentid assignment
* @param int submissionid submission to create a report for * @param $submissionid submission to create a report for
*/ */
public static function generatedetailhtml( public static function generatedetailhtml(
int $assignmentid, int $assignmentid,
...@@ -220,7 +221,7 @@ class view_submission_utils { ...@@ -220,7 +221,7 @@ class view_submission_utils {
// Add empty div for spacing between summary and compentency table. // Add empty div for spacing between summary and compentency table.
$html .= html_writer::empty_tag("div", ["class" => "dtaSpacer"]); $html .= html_writer::empty_tag("div", ["class" => "dtaSpacer"]);
// Competency assessment table. // Competency assessment table.
$body = ""; $body = "";
$tmp = ""; $tmp = "";
...@@ -228,10 +229,10 @@ class view_submission_utils { ...@@ -228,10 +229,10 @@ class view_submission_utils {
$tmp .= html_writer::empty_tag("th", ["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);
$showncompetencies = explode(";", $summary->successfultestcompetencies); $showncompetencies = explode(";", $summary->successfultestcompetencies);
$overallcompetencies = explode(";", $summary->overalltestcompetencies); $overallcompetencies = explode(";", $summary->overalltestcompetencies);
for ($index = 0, $size = count($overallcompetencies); $index < $size; $index++) { for ($index = 0, $size = count($overallcompetencies); $index < $size; $index++) {
$comp = $overallcompetencies[$index]; $comp = $overallcompetencies[$index];
$shown = $showncompetencies[$index]; $shown = $showncompetencies[$index];
...@@ -241,10 +242,10 @@ class view_submission_utils { ...@@ -241,10 +242,10 @@ class view_submission_utils {
$resultrowattributes = $tablerowattributes; $resultrowattributes = $tablerowattributes;
$tmp = ""; $tmp = "";
$tmp .= html_writer::tag("td", get_string("comp" . $index, self::COMPONENT_NAME), $resultrowattributes); $tmp .= html_writer::tag("td", get_string("comp" . $index, self::COMPONENT_NAME), $resultrowattributes);
$tmp .= html_writer::tag("td", 100*floatval($shown)/floatval($comp) . "% " . $tmp .= html_writer::tag("td", 100 * floatval($shown) / floatval($comp) . "% " .
"(" . $shown . " / " . $comp . ")", $resultrowattributes); "(" . $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::COMPONENT_NAME), $resultrowattributes);
$body .= html_writer::tag("tr", $tmp, $resultrowattributes); $body .= html_writer::tag("tr", $tmp, $resultrowattributes);
} }
} }
...@@ -288,7 +289,7 @@ class view_submission_utils { ...@@ -288,7 +289,7 @@ class view_submission_utils {
"td", "td",
get_string("package_name", self::COMPONENT_NAME), get_string("package_name", self::COMPONENT_NAME),
$attributes); $attributes);
$tmp .= html_writer::tag( $tmp .= html_writer::tag(
"td", "td",
$r->packagename, $r->packagename,
......
Markdown is supported
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