From 9994b49c513b96b75d544b2f44a2c1fe230d6785 Mon Sep 17 00:00:00 2001 From: Astor Bizard <astor.bizard@grenoble-inp.fr> Date: Tue, 26 May 2020 10:38:30 +0200 Subject: [PATCH] Now supports basedon mechanism with VPLs on which user doesnt have rights. --- forms/executionoptions.php | 8 +++++++- lang/en/vpl.php | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/forms/executionoptions.php b/forms/executionoptions.php index 344f375f..20591a9c 100644 --- a/forms/executionoptions.php +++ b/forms/executionoptions.php @@ -109,6 +109,12 @@ class mod_vpl_executionoptions_form extends moodleform { } asort( $basedonlist ); $basedonlist [0] = get_string( 'select' ); + if (!in_array($instance->basedon, array_keys($basedonlist))) { + $basedonvpl = new mod_vpl(null, $instance->basedon); + $basedonlist[$instance->basedon] = $basedonvpl->get_printable_name(); + $warning = '<i class="icon fa fa-warning text-warning fa-fw" title="' . get_string('basedonwarning', VPL) . '"></i>'; + $strbasedon .= '<span class="float-sm-right">' . $warning . '</span>'; + } $mform->addElement( 'select', 'basedon', $strbasedon, $basedonlist ); $mform->setDefault( 'basedon', $instance->basedon ); @@ -167,7 +173,7 @@ if ($fromform = $mform->get_data()) { $instance->evaluateonsubmission = $fromform->evaluate && $fromform->evaluateonsubmission; $instance->automaticgrading = $fromform->evaluate && $fromform->automaticgrading; if ( $vpl->update() ) { - vpl_notice( get_string( 'optionssaved', VPL ) ); + vpl_redirect( vpl_mod_href('view.php', 'id', $id), get_string( 'optionssaved', VPL ), 'success' ); } else { vpl_notice( get_string( 'optionsnotsaved', VPL ), 'error' ); } diff --git a/lang/en/vpl.php b/lang/en/vpl.php index 9a93fdd4..da11daa3 100644 --- a/lang/en/vpl.php +++ b/lang/en/vpl.php @@ -34,6 +34,9 @@ $string ['automaticgrading'] = 'Automatic grade'; $string ['averageperiods'] = 'Average periods {$a}'; $string ['averagetime'] = 'Average time {$a}'; $string ['basedon'] = 'Based on'; +$string ['basedonwarning'] = 'It seems you do not have the rights on the VPL this VPL is based on. +The based on mechanism will still work. +However, please note that if you change it, you will not be able to change it back to its current state.'; $string ['basic'] = 'Basic'; $string ['binaryfile'] = 'Binary File'; $string ['browserupdate'] = 'Please update your browser to the last version<br />or use another that supports Websocket.'; -- GitLab