Commit f2b1f509 authored by Dominik Vayhinger's avatar Dominik Vayhinger
Browse files

Initial Commit

parents
pipeline {
agent any
tools {
jdk 'Java11'
}
stages {
stage('Checkout') {
steps {
git branch: 'master',
//Link anpassen auf Finalem Repo
url: 'https://gitlab.rz.hft-stuttgart.de/swp2-lc/moodle-assignsubmission_mojec.git'
}
}
stage('Build') {
steps {
sh 'chmod 744 update_plugin_script.sh && ./update_plugin_script.sh'
}
}
}
}
This diff is collapsed.
# Moodle Dockerized Code Testing (MoDoCoT) Plugin
A Moodle plugin to assist teachers correcting JUnit exercises.
This plugin allows students to submit their Java exercises, let them be tested against
a set of JUnit tests (that have been priorly provided by the teacher) and receive immediate feedback
on the test results.
For this to work, the plugin communicates with an external webservice providing essentially the following services on the given paths:
* POST **/v1/unittest**: Expects the assignment id and a zip file containing the unit test files as http post parameters.
* POST **/v1/tasks**: Expects the assignment id and a zip file containing the java files that should be tested as http post parameters. Extracts the zip file, compiles the java files and runs the tests (provided via /v1/unittest). Returns the results in form of JSON.
* DELETE **/v1/unittest?assignmentId={id}**: Triggers the deletion of the test files.
See here for an implementation of the webservice: [MoDoCoT Backend](!!!!!!!!!!!!!!!!https://github.com/HFTSoftwareProject/MoJEC-Backend)
## Installation/Configuration
* Install this plugin by using the Moodle web installer, or by extracting the plugin archive to {Moodle_Root}/mod/assign/submission/modocot and visting the admins notifications page.
* Visit the plugin's settings and configure the base URL of the web service to use. (You need a running webservice to use, see [MoDoCoT Backend](!!!!!!!!!!!!!!!!https://github.com/HFTSoftwareProject/MoJEC-Backend) for a working solution)
* Done!
## Usage (Teacher)
* Create an Assignment
* In the Assignment settings: Scroll to the section **Submission types** and check the type **Dockerized Code Testing**
* Once **Dockerized Code Testing** is checked, upload a *single* ZIP file containing your repository URL in the corresponding Excercise repository ZIP upload environment.
* View aggregated test results in the grading table column **Dockerized Code Testing**
* View detailed results of a particular submission by clicking the magnifyer icon in the respective cell of the Dockerized Code Testing column of the grading table
## Usage (Student)
* Navigate to the assignment
* Press **Add Submission** respectively **Edit Submission**
* Upload a *single* ZIP file containing your repository URL that you will to be tested and click **Save changes**
* View your test results in the **Dockerized Code Testing** row of the submission status table.
## Technical Details
For the communication between the plugin and the webservice the data is en/decoded as JSON.
Here is an example JSON response after uploading the task Java file.
```JSON
{
"testResults": [
{
"testName": "CalculatorTest",
"testCount": 5,
"failureCount": 0,
"successfulTests": [
"div",
"mult",
"sub",
"add",
"sum"
],
"testFailures": []
},
{
"testName": "CalculatorSecondTest",
"testCount": 5,
"failureCount": 1,
"successfulTests": [
"add2",
"sub2",
"div2",
"sum2"
],
"testFailures": [
{
"testHeader": "mult2(CalculatorSecondTest)",
"message": "expected:<15.0> but was:<10.0>",
"trace": "stacktrace (if existent)"
}
]
}
```
The above shows the result of two JUnit test files (CalculatorTest and CalculatorSecondTest). The field “test count” indicates the number of test methods within the test file. The field “Failure count” indicates how many tests have failed and the field “successful test” indicates the method names of passed tests. In case a test failed, the necessary information can be found as an entry in the "testFailures" array.
If there was an compilation error the relevant information is part of the "compilationErrors" array as shown below.
```JSON
"compilationErrors": [
{
"code": "compiler.err.expected",
"columnNumber": 0,
"kind": "ERROR",
"lineNumber": 0,
"message": "';' expected",
"position": 46,
"filePath": "/tmp/TaskNotCompilable.java",
"startPosition": 46,
"endPosition": 46
}
]
}
```
## Bugs and Improvements?
If you've found a bug or if you've made an improvement to this plugin and want to share your code, please
open an issue in our Github project:
!!!!!!!!!!!!!!!!!!!!! https://github.com/HFTSoftwareProject/moodle-assignsubmission_mojec/issues
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/assign/submission/modocot/db" VERSION="20161201" COMMENT="XMLDB file for Moodle mod/assign/submission/modocot"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="assignsubmission_modocot" COMMENT="Info about JUnit executor submissions for assignments.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="assignment_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="submission_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this submission info."/>
<KEY NAME="fk_assignment" TYPE="foreign" FIELDS="assignment_id" REFTABLE="assign" REFFIELDS="id" COMMENT="The assignment instance this submission relates to"/>
<KEY NAME="fk_submission" TYPE="foreign" FIELDS="submission_id" REFTABLE="assign_submission" REFFIELDS="id" COMMENT="The submission this file submission relates to."/>
</KEYS>
</TABLE>
<TABLE NAME="modocot_testresult" COMMENT="Info about the JUnit executor test results.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="testname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The name of the test, corresponds to the filename of the Junit test file"/>
<FIELD NAME="testcount" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="The overall number of tests, inclusively the failed ones."/>
<FIELD NAME="modocot_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="succtests" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Comma separated list of the successful test names"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_modocot" TYPE="foreign" FIELDS="modocot_id" REFTABLE="assignsubmission_modocot" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="modocot_testfailure" COMMENT="Info about the failures occured during test execution.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="testresult_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="testheader" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="message" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="trace" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_testresult" TYPE="foreign" FIELDS="testresult_id" REFTABLE="modocot_testresult" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="modocot_compilationerror" COMMENT="Info about compilation errors while trying to compile the test classes.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="modocot_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="columnnumber" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="linenumber" TYPE="int" LENGTH="5" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="message" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="position" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The character offset from the beginning of the source object that indicates the location of the problem."/>
<FIELD NAME="filename" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_modocot" TYPE="foreign" FIELDS="modocot_id" REFTABLE="assignsubmission_modocot" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Upgrade code for install
*
* @package assignsubmission_modocot
* @copyright 2020 hft ip2
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignsubmission_modocot_upgrade($oldversion) {
global $CFG;
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component "assignsubmission_modocot", language "en"
*
* @package assignsubmission_modocot
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string["pluginname"] = "Dockerized Code Testing";
$string["modocot"] = "Dockerized Code Testing";
$string["modocot_submissions_fa"] = "Dockerized Code Testing Submissions";
$string["modocot_tests_fa"] = "Dockerized Code Testing Tests";
$string['enabled'] = "Dockerized Code Testing";
$string['enabled_help'] = "If enabled, students are able to upload one ZIP file containing their repository with JUnit tasks which will then be tested against a teacher provided set of JUnit tests.";
$string["setting_unittests"] = "JUnit tests";
$string["setting_unittests_help"] = "A single ZIP file containg the JUnit tests, the students' submissions should be tested against.";
$string["wsbase_not_set"] = "The Dockerized Code Testing web service base URL is not configured.";
$string["unexpectederror"] = "An unexpected error occured.";
$string["badrequesterror"] = "The server could not process the request. Probably the submitted ZIP file is corrupted.";
$string["modocot_submission"] = "Excercise repository ZIP";
$string["modocot_submission_help"] = "A single ZIP file containing the repository with all the relevant java files and resources for this exercise.";
$string["no_testfile_warning"] = "Submission type is \"Dockerized Code Testing\" but no testfiles are uploaded.";
// Admin Settings.
$string["default"] = "Enabled by default";
$string["default_help"] = "If set, this submission method will be enabled by default for all new assignments.";
$string["wsbase"] = "Base URL to the web service";
$string["wsbase_help"] = "The base URL to the web service, where all the tests and submissions will be sent and evaluated.";
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the moodle hooks for the submission modocot plugin
*
* @package assignsubmission_modocot
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Serves assignment submissions and other files.
*
* @param mixed $course course or id of the course
* @param mixed $cm course module or id of the course module
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @return bool false if file not found, does not return if found - just send the file
*/
function assignsubmission_modocot_pluginfile($course,
$cm,
context $context,
$filearea,
$args,
$forcedownload) {
global $DB, $CFG;
if ($context->contextlevel != CONTEXT_MODULE) {
return false;
}
require_login($course, false, $cm);
$itemid = (int)array_shift($args);
$record = $DB->get_record('assign_submission',
array('id' => $itemid),
'userid, assignment, groupid',
MUST_EXIST);
$userid = $record->userid;
$groupid = $record->groupid;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$assign = new assign($context, $cm, $course);
if ($assign->get_instance()->id != $record->assignment) {
return false;
}
if ($assign->get_instance()->teamsubmission &&
!$assign->can_view_group_submission($groupid)) {
return false;
}
if (!$assign->get_instance()->teamsubmission &&
!$assign->can_view_submission($userid)) {
return false;
}
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/assignsubmission_modocot/$filearea/$itemid/$relativepath";
$fs = get_file_storage();
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) || $file->is_directory()) {
return false;
}
// Download MUST be forced - security!
send_stored_file($file, 0, 0, true);
}
\ No newline at end of file
This diff is collapsed.
<?php
/**
* This file defines the admin settings for this plugin
*
* @package assignsubmission_modocot
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_configcheckbox("assignsubmission_modocot/default",
new lang_string("default", "assignsubmission_modocot"),
new lang_string("default_help", "assignsubmission_modocot"), 0));
$settings->add(new admin_setting_configtext("assignsubmission_modocot/wsbase",
new lang_string("wsbase", "assignsubmission_modocot"),
new lang_string("wsbase_help", "assignsubmission_modocot"), ""));
/* Prevent word breaking in the grading table */
div.submissionmodocotgrading {
white-space: nowrap;
}
/****************************************************************
* Layout for the Detail view
****************************************************************/
div.failedTestWrapper {
overflow: auto;
}
div.failedtestcontent {
float: right;
width: 85%;
}
div.failedtestsidebar {
float: left;
width: 15%;
}
/****************************************************************
* Collapser for the stacktrace
****************************************************************/
.collapsible {
cursor: pointer;
display: block;
text-decoration: underline;
}
.collapsible + input{
display: none; /* hide the checkboxes */
}
.collapsible + input + div{
display:none;
}
.collapsible + input:checked + div{
display:block;
}
#!/bin/bash
docker exec -i moodle_compose bash <<EOF
git -C /bitnami/moodle/mod/assign/submission/modocot pull
echo "Updated"
exit
EOF
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the version information for the onlinetext modocot plugin
*
* @package assignsubmission_modocot
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2020061500;
$plugin->requires = 2019111800; // Moodle 3.8.
$plugin->component = 'assignsubmission_modocot';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = "1.0";
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