Commit d41be0f4 authored by Astor Bizard's avatar Astor Bizard
Browse files

Merge branch 'test' into 'master'

Added settings overrides, work state summary, temporary token to be sent to execution server.

See merge request !13
parents b1ece6da 57c9e0e4
define(["jquery"],function(a){return{makeSortable:function(b,c=[],d,e=0){var f;null===d&&(d=void 0);var g=a("#"+b+" tbody"),h=a("#"+b+" thead th"),i=h.length;h.each(function(){var b=h.index(this);-1==c.indexOf(b)&&-1==c.indexOf(b-i)&&a(this).append('<i class="icon fa fa-fw sortarrow"></i>')}),a("#"+b+" thead .sortarrow").each(function(){var b=a(this),c=b.closest("th"),d=h.index(c);c.css("cursor","pointer").css("user-select","none").click(function(){b.hasClass("sortarrow-active")?1==(f=-f)?b.removeClass("fa-caret-up").addClass("fa-caret-down"):b.removeClass("fa-caret-down").addClass("fa-caret-up"):(a("i.sortarrow-active").removeClass("sortarrow-active fa-caret-down fa-caret-up"),b.addClass("sortarrow-active fa-caret-down"),f=1);var c=1,h=Array.from(g.children("tr")),i=h.splice(-e,e);h.sort(function(b,c){var e=function(b){return a(b).find(".cell.c"+d+" [value]").attr("value")||a(b).find(".cell.c"+d).text()},g=e(b),h=e(c);return f*(""===g||""===h||isNaN(g)||isNaN(h)?g.toString().localeCompare(h):g-h)}).forEach(function(b){a(b).children("td").first().find(":not(:empty)").addBack(":not(:empty)").each(function(){/^[0-9]+$/.test(a(this).html())&&a(this).html(c)}),c++,g.append(b)}),i.forEach(function(a){g.append(a)})}),c.find("a").click(function(a){a.stopPropagation()})}).eq(d).click()}}});
\ No newline at end of file
define(["jquery"],function(a){return{makeSortable:function(b,c=[],d,e=0){var f;null===d&&(d=void 0);var g=a("#"+b+" tbody"),h=a("#"+b+" thead th"),i=h.length;h.each(function(){var b=h.index(this);-1==c.indexOf(b)&&-1==c.indexOf(b-i)&&a(this).append('<i class="icon fa fa-fw sortarrow"></i>')}),a("#"+b+" thead .sortarrow").each(function(){var b=a(this),c=b.closest("th"),d=h.index(c);c.css("cursor","pointer").css("user-select","none").click(function(){b.hasClass("sortarrow-active")?(f=-f,b.toggleClass("fa-caret-up",1!=f).toggleClass("fa-caret-down",1==f)):(a("i.sortarrow-active").removeClass("sortarrow-active fa-caret-down fa-caret-up"),b.addClass("sortarrow-active fa-caret-down"),f=1);var c=1,h=Array.from(g.children("tr")),i=h.splice(-e,e);h.sort(function(b,c){var e=function(b){return a(b).find(".cell.c"+d+" [value]").attr("value")||a(b).find(".cell.c"+d).text()},g=e(b),h=e(c);return f*(""===g||""===h||isNaN(g)||isNaN(h)?g.toString().localeCompare(h):g-h)}).forEach(function(b){a(b).children("td").first().find(":not(:empty)").addBack(":not(:empty)").each(function(){/^[0-9]+$/.test(a(this).html())&&a(this).html(c)}),c++,g.append(b)}),i.forEach(function(a){g.append(a)})}),c.find("a").click(function(a){a.stopPropagation()})}).eq(d).click()}}});
\ No newline at end of file
define(["jquery"],function(a){return{setup:function(){a('select[name="submitmethod"]').change(function(){a("#id_headersubmitarchive").toggle("archive"==a(this).val()).removeClass("collapsed"),a("#id_headersubmitfiles").toggle("archive"!=a(this).val()).removeClass("collapsed")}).change()}}});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -39,12 +39,7 @@ define(['jquery'], function($){
else {
// Change sorting direction and arrow display.
sortdirection = -sortdirection;
if (sortdirection == 1) {
$arrow.removeClass('fa-caret-up').addClass('fa-caret-down');
}
else {
$arrow.removeClass('fa-caret-down').addClass('fa-caret-up');
}
$arrow.toggleClass('fa-caret-up', sortdirection != 1).toggleClass('fa-caret-down', sortdirection == 1);
}
// Sort rows.
var num = 1;
......
define(['jquery'], function($) {
return {
setup: function() {
$('select[name="submitmethod"]').change(function() {
$('#id_headersubmitarchive').toggle($(this).val() == 'archive').removeClass('collapsed');
$('#id_headersubmitfiles').toggle($(this).val() != 'archive').removeClass('collapsed');
}).change();
}
};
});
\ No newline at end of file
......@@ -1737,6 +1737,44 @@ define(
}
});
var reloadFilesAfterExecution = function() {
$.ajax({
type: "POST",
url: options.loadajaxurl + 'getlastversion',
'data': JSON.stringify(options),
contentType: "application/json; charset=utf-8",
dataType: "json"
}).done(function(outcome) {
if (outcome.success && fileManager.getVersion() < outcome.response.version) {
// A more recent version exists, prompt user to load it.
showMessage(str('morerecentversionloadprompt'), {
title: str('morerecentversionsaved'),
yes: function() {
VPLUtil.requestAction('load', 'loading', options, options.loadajaxurl)
.done(function(response) {
var files = response.files;
for (var i = 0; i < files.length; i++) {
fileManager.addFile(files[i], true, VPLUtil.doNothing, showErrorMessage);
}
fileManager.fileListVisibleIfNeeded();
fileManager.resetModified();
fileManager.setVersion(response.version);
fileManager.fileListVisible(files.length > 5);
tabs.tabs('option', 'active', 0);
VPLUtil.afterAll('AfterLoadFiles', function() {
fileManager.resetModified();
updateMenu();
autoResizeTab();
adjustTabsTitles(false);
});
})
.fail(showErrorMessage);
}
});
}
});
};
var executionActions = {
'getConsole': function() {
return lastConsole;
......@@ -1747,19 +1785,20 @@ define(
if (lastConsole && lastConsole.isOpen()) {
lastConsole.close();
}
var afterExecution = function() {
if (ws.readyState != ws.OPEN) {
reloadFilesAfterExecution();
}
ws.close();
focusCurrentFile();
};
if (type == 'terminal') {
lastConsole = terminal;
terminal.connect(coninfo.executionURL, function() {
ws.close();
focusCurrentFile();
});
terminal.connect(coninfo.executionURL, afterExecution);
} else {
lastConsole = VNCClient;
VNCClient.connect(coninfo.secure, coninfo.server, coninfo.portToUse, coninfo.VNCpassword,
coninfo.executionPath, function() {
ws.close();
focusCurrentFile();
});
coninfo.executionPath, afterExecution);
}
},
'lastAction': false,
......
......@@ -423,6 +423,7 @@ define(
'kt': 'kotlin', 'kts': 'kotlin',
'm': 'matlab',
'md': 'markdown',
'ml': 'ocaml',
'less': 'less',
'lisp': 'lisp', 'lsp': 'lisp',
'lua': 'lua',
......
......@@ -214,6 +214,27 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
'variation'
);
/**
* @var array Overrides table fields list
*/
protected $overridefields = array (
'vpl',
'startdate',
'duedate',
'freeevaluations',
'reductionbyevaluation'
);
/**
* @var array Assigned Overrides table fields list
*/
protected $assioverridefields = array (
'vpl',
'userid',
'groupid',
'override'
);
/**
* Define the full structure of a VPL instance with user data
* {@inheritDoc}
......@@ -241,6 +262,12 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
$asignedvariation = new backup_nested_element( 'asigned_variation',
$idfield,
$this->asivariationfields );
$overrides = new backup_nested_element( 'overrides' );
$override = new backup_nested_element( 'override', $idfield, $this->overridefields );
$assignedoverrides = new backup_nested_element( 'assigned_overrides' );
$assignedoverride = new backup_nested_element( 'assigned_override',
$idfield,
$this->assioverridefields );
$submissions = new backup_nested_element( 'submissions' );
$submission = new backup_nested_element( 'submission', $idfield, $this->submissionfields );
$submissionfiles = new backup_nested_element( 'submission_files' );
......@@ -250,6 +277,8 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
$vpl->add_child( $corrected_files );
$vpl->add_child( $executionfiles );
$vpl->add_child( $variations );
$vpl->add_child( $overrides );
$vpl->add_child( $assignedoverrides );
$vpl->add_child( $submissions );
$requiredfiles->add_child( $requiredfile );
$corrected_files->add_child( $corrected_file );
......@@ -257,6 +286,8 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
$variations->add_child( $variation );
$variation->add_child( $asignedvariations );
$asignedvariations->add_child( $asignedvariation );
$overrides->add_child( $override );
$assignedoverrides->add_child( $assignedoverride );
$submissions->add_child( $submission );
$submission->add_child( $submissionfiles );
$submissionfiles->add_child( $submissionfile );
......@@ -269,8 +300,10 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
$query .= ' WHERE s.id = ?';
$vpl->set_source_sql( $query, array ( backup::VAR_ACTIVITYID ) );
$variation->set_source_table( 'vpl_variations', $parmvplid );
$override->set_source_table( 'vpl_overrides', $parmvplid );
if ($userinfo) {
$asignedvariation->set_source_table( 'vpl_assigned_variations', $parmvplid );
$assignedoverride->set_source_table( 'vpl_assigned_overrides', $parmvplid );
/*
* Uncomment next line and comment nexts to backup all student's submissions, not only last one.
* $submission->set_source_table('vpl_submissions', $parmvplid);
......@@ -287,6 +320,8 @@ class backup_vpl_activity_structure_step extends backup_activity_structure_step
$vpl->annotate_ids( 'scale', 'grade' );
$vpl->annotate_ids( 'vpl', 'basedon' );
$asignedvariation->annotate_ids( 'user', 'userid' );
$assignedoverride->annotate_ids( 'user', 'userid' );
$assignedoverride->annotate_ids( 'group', 'groupid' );
$submission->annotate_ids( 'user', 'userid' );
$submission->annotate_ids( 'user', 'grader' );
$submission->annotate_ids( 'group', 'groupid' );
......
......@@ -80,8 +80,10 @@ class restore_vpl_activity_structure_step extends restore_activity_structure_ste
$paths [] = new restore_path_element ( 'corrected_file', '/activity/vpl/corrected_files/corrected_file' );
$paths [] = new restore_path_element ( 'execution_file', '/activity/vpl/execution_files/execution_file' );
$paths [] = new restore_path_element ( 'variation', '/activity/vpl/variations/variation' );
$paths [] = new restore_path_element ( 'override', '/activity/vpl/overrides/override' );
if ($userinfo) {
$paths [] = new restore_path_element ( 'assigned_variation', '/activity/vpl/assigned_variations/assigned_variation' );
$paths [] = new restore_path_element ( 'assigned_override', '/activity/vpl/assigned_overrides/assigned_override' );
$paths [] = new restore_path_element ( 'submission', '/activity/vpl/submissions/submission' );
$paths [] = new restore_path_element (
'submission_file',
......@@ -192,6 +194,37 @@ class restore_vpl_activity_structure_step extends restore_activity_structure_ste
$DB->insert_record ( 'vpl_assigned_variations', $data );
}
/**
* Restore an override
* @param array $data override instance
*/
protected function process_override($data) {
global $DB;
$data = ( object ) $data;
$data->vpl = $this->get_new_parentid ( 'vpl' );
$data->startdate = $this->apply_date_offset ( $data->startdate );
$data->duedate = $this->apply_date_offset ( $data->duedate );
$newid = $DB->insert_record ( 'vpl_overrides', $data );
$this->set_mapping('override', $data->id, $newid); // Map new id to be used by process_assigned_override().
}
/**
* Restore an override assignation
* @param array $data assigned override instance
*/
protected function process_assigned_override($data) {
global $DB;
$data = ( object ) $data;
$newid = $this->get_mappingid('override', $data->override, null); // Fetch new override id.
if ($newid !== null) {
$data->vpl = $this->get_new_parentid ( 'vpl' );
$data->override = $newid;
$data->userid = $this->get_mappingid ( 'user', $data->userid, null );
$data->groupid = $this->get_mappingid ( 'group', $data->groupid, null );
$DB->insert_record ( 'vpl_assigned_overrides', $data );
}
}
/**
* Restore a submission
* @param array $data submission instance
......
<?php
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for 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.
//
// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for logging of override updated events
*
* @package mod_vpl
* @copyright 2014 onwards Juan Carlos Rodríguez-del-Pino, 2021 Astor Bizard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_vpl\event;
defined( 'MOODLE_INTERNAL' ) || die();
require_once(dirname( __FILE__ ) . '/../../locallib.php');
class override_base extends base {
public static function get_objectid_mapping() {
return array('db' => VPL_OVERRIDES, 'restore' => VPL_OVERRIDES);
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
protected function init() {
$this->data ['crud'] = 'u';
$this->data ['edulevel'] = self::LEVEL_TEACHING;
$this->data ['objecttable'] = VPL_OVERRIDES;
}
public static function log($vpl, $overrideid = null) {
if (is_array($vpl)) {
$info = $vpl;
} else {
$vplinstance = $vpl->get_instance();
$info = array (
'objectid' => $overrideid,
'contextid' => $vpl->get_context()->id,
'courseid' => $vplinstance->course,
'other' => array('vplid' => $vplinstance->id),
);
}
parent::log( $info );
}
public function get_url() {
return $this->get_url_base( 'view.php' );
}
public function get_description_mod($mod) {
$desc = 'The user with id ' . $this->userid . ' ' . $mod;
$desc .= ' override with id ' . $this->objectid . ' of VPL activity with id ' . $this->other['vplid'];
if ($this->relateduserid) {
$desc .= ' for user with id ' . $this->relateduserid;
}
return $desc;
}
}
<?php
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for 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.
//
// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for logging of override created events
*
* @package mod_vpl
* @copyright 2014 onwards Juan Carlos Rodríguez-del-Pino, 2021 Astor Bizard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_vpl\event;
defined( 'MOODLE_INTERNAL' ) || die();
require_once(dirname( __FILE__ ) . '/../../locallib.php');
class override_created extends override_base {
protected function init() {
parent::init();
$this->data ['crud'] = 'c';
$this->legacyaction = 'created override';
}
public function get_description() {
return $this->get_description_mod( 'created' );
}
}
<?php
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for 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.
//
// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for logging of override deleted events
*
* @package mod_vpl
* @copyright 2014 onwards Juan Carlos Rodríguez-del-Pino, 2021 Astor Bizard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_vpl\event;
defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__).'/../../locallib.php');
class override_deleted extends override_base {
protected function init() {
parent::init();
$this->data['crud'] = 'd';
$this->legacyaction = 'deleted override';
}
public function get_description() {
return $this->get_description_mod( 'deleted' );
}
}
<?php
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for 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.
//
// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for logging of override updated events
*
* @package mod_vpl
* @copyright 2014 onwards Juan Carlos Rodríguez-del-Pino, 2021 Astor Bizard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_vpl\event;
defined( 'MOODLE_INTERNAL' ) || die();
require_once(dirname( __FILE__ ) . '/../../locallib.php');
class override_updated extends override_base {
protected function init() {
parent::init();
$this->data ['crud'] = 'u';
$this->legacyaction = 'updated override';
}
public function get_description() {
return $this->get_description_mod( 'updated' );
}
}
......@@ -30,5 +30,9 @@ class variation_added extends variation_base {
protected function init() {
parent::init();
$this->data ['crud'] = 'c';
$this->legacyaction = 'added variation';
}
public function get_description() {
return $this->get_description_mod( 'added' );
}
}
<?php
// This file is part of VPL for Moodle - http://vpl.dis.ulpgc.es/
//
// VPL for 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.
//
// VPL for 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 VPL for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for logging of assigned variation events
*
* @package mod_vpl
* @copyright 2020 onwards Juan Carlos Rodrguez-del-Pino
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Juan Carlos Rodrguez-del-Pino <jcrodriguez@dis.ulpgc.es>
*/
namespace mod_vpl\event;
defined( 'MOODLE_INTERNAL' ) || die();
require_once(dirname( __FILE__ ) . '/../../locallib.php');
class variation_assigned extends variation_base {
protected function init() {
parent::init();
$this->legacyaction = 'assigned variation';
$this->data ['crud'] = 'c';
}
public function get_description() {
return $this->get_description_mod( 'assigned' );
}
public static function log($vpl, $varid = null, $userid = null) {
$vplinstance = $vpl->get_instance();
$info = array (
'objectid' => $varid,
'contextid' => $vpl->get_context()->id,
'relateduserid' => $userid,
'courseid' => $vplinstance->course,
'other' => array('vplid' => $vplinstance->id),
);
parent::log( $info );
}
}
\ No newline at end of file
......@@ -26,20 +26,42 @@ namespace mod_vpl\event;
defined( 'MOODLE_INTERNAL' ) || die();
require_once(dirname( __FILE__ ) . '/../../locallib.php');
class variation_base extends vpl_base {
class variation_base extends base {
public static function get_objectid_mapping() {
return array('db' => VPL_VARIATIONS, 'restore' => VPL_VARIATIONS);
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
protected function init() {
parent::init();
$this->data ['crud'] = 'u';
$this->data ['edulevel'] = self::LEVEL_TEACHING;
$this->data ['objecttable'] = VPL_VARIATIONS;
$this->legacyaction = 'variations form';
}
public function get_description() {
return $this->get_description_mod( 'variation' );
}
public static function log($info) {
if (is_array( $info )) {
parent::log( $info );
public static function log($vpl, $varid = null) {
if (is_array($vpl)) {
$info = $vpl;
} else {
throw new \coding_exception( 'Parameter must be an array' );
$vplinstance = $vpl->get_instance();
$info = array (
'objectid' => $varid,
'contextid' => $vpl->get_context()->id,
'courseid' => $vplinstance->course,
'other' => array('vplid' => $vplinstance->id),
);
}
parent::log( $info );
}
public function get_url() {
return $this->get_url_base( 'view.php' );
}
public function get_description_mod($mod) {
$desc = 'The user with id ' . $this->userid . ' ' . $mod;
$desc .= ' variation with id ' . $this->objectid . ' of VPL activity with id ' . $this->other['vplid'];
if ($this->relateduserid) {
$desc .= ' for user with id ' . $this->relateduserid;
}
return $desc;
}
}
......@@ -28,5 +28,9 @@ class variation_deleted extends variation_base {
protected function init() {
parent::init();
$this->data['crud'] = 'd';
$this->legacyaction = 'deleted variation';
}
public function get_description() {
return $this->get_description_mod( 'deleted' );
}
}
......@@ -30,5 +30,9 @@ class variation_updated extends variation_base {
protected function init() {
parent::init();
$this->data ['crud'] = 'u';
$this->legacyaction = 'updated variation';
}
public function get_description() {
return $this->get_description_mod( 'updated' );
}
}
......@@ -45,7 +45,7 @@ class vpl_base extends base {
} else {
$einfo = array (
'objectid' => $vpl->get_instance()->id,
'context' => $vpl->get_context()
'contextid' => $vpl->get_context()->id
);
parent::log( $einfo );
}
......
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