diff --git a/deploy.php b/deploy.php index 071c25bb6a0cf98ed2586031294398fc82c092c9..ea3f95fe277c647e051cbec56948d5e7b1a40752 100644 --- a/deploy.php +++ b/deploy.php @@ -81,7 +81,9 @@ if (!is_null($undeploy) && $question->deployedseeds) { // Process undeployall if applicable. $deployfromlist = optional_param('deployfromlist', null, PARAM_INT); $deploysystematic = optional_param('deploysystematic', null, PARAM_INT); -if (!is_null($deployfromlist) || !is_null($deploysystematic)) { +$deploysystematicfrom = optional_param('deploysystematicfrom', null, PARAM_INT); +$deploysystematicto = optional_param('deploysystematicto', null, PARAM_INT); +if (!is_null($deployfromlist) || !is_null($deploysystematic) || (!is_null($deploysystematicfrom) && !is_null($deploysystematicto))) { // Check data integrity. $dataproblem = false; @@ -89,6 +91,9 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) { if (!is_null($deployfromlist)) { $deploytxt = optional_param('deployfromlist', null, PARAM_TEXT); $baseseeds = explode("\n", trim($deploytxt)); + } elseif (!is_null($deploysystematicfrom) && !is_null($deploysystematicto)) { + $baseseeds = range($deploysystematicfrom, $deploysystematicto); + $usefromtofeature = true; } else { $baseseeds = range(1, $deploysystematic); } @@ -132,9 +137,18 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) { } // Undeploy all existing variants. + // If the deploy-from-to feature is used, only undeploy variants that already exist if ($question->deployedseeds) { - foreach ($question->deployedseeds as $seed) { - $question->undeploy_variant($seed); + if ($usefromtofeature) { + foreach ($question->deployedseeds as $seed) { + if (in_array($seed,$newseeds)) { + $question->undeploy_variant($seed); + } + } + } else { + foreach ($question->deployedseeds as $seed) { + $question->undeploy_variant($seed); + } } } // Deploy all new variants. diff --git a/doc/en/CAS/Systematic_deployment.md b/doc/en/CAS/Systematic_deployment.md index 90e6fd9f62f5180ff794f905ca25c8679ee07607..f98864acd61dc92a013a19c6844512e81c2f83a2 100644 --- a/doc/en/CAS/Systematic_deployment.md +++ b/doc/en/CAS/Systematic_deployment.md @@ -32,7 +32,7 @@ It is your responsibility to make sure the index remains within range! You can It is sensible to always ensure your `stack_seed` does not create run-time errors. Notice that although the `mod` function does return `0` we have avoided possible zero indexes when defining `n1`. -Of course, there are many other ways to map deployed seeds onto systematic deployment of variants. Using consecutive integers from \(1, \ldots, n\) as the starting point is probably simplest and easiest to maintain. For this reason there is a special option to do this on the deploy variants page. +Of course, there are many other ways to map deployed seeds onto systematic deployment of variants. Using consecutive integers from \(1, \ldots, n\) as the starting point is probably simplest and easiest to maintain. For this reason there is a special option to do this on the deploy variants page. There is also an option to use consecutive integers from \(n, \ldots, m\). Notes diff --git a/lang/en/qtype_stack.php b/lang/en/qtype_stack.php index 7106219ad7d0def1503e28e63f7d8107f55f1cbe..946e5a53f195784033bf200356394672fc5607d9 100644 --- a/lang/en/qtype_stack.php +++ b/lang/en/qtype_stack.php @@ -532,6 +532,8 @@ $string['deployedvariantsn'] = 'Deployed variants ({$a})'; $string['deploymanybtn'] = 'Deploy # of variants:'; $string['deploymanyerror'] = 'Error in user input: cannot deploy "{$a->err}" variants.'; $string['deploysystematicbtn'] = 'Deploy seeds from 1 to: '; +$string['deploysystematicfrombtn'] = 'Deploy seeds from: '; +$string['deploysystematicto'] = 'to: '; $string['deployduplicateerror'] = 'Duplicate question notes detected in the deployed variants. We strongly recommend each question note is only deployed once, otherwise you will have difficulty collecting meaningful stats when grouping by variant. Please consider deleting some variants with duplicate notes.'; $string['deploytoomanyerror'] = 'STACK will try to deploy up to at most 100 new variants in any one request. No new variants deployed.'; $string['deploymanynonew'] = 'Too many repeated existing question notes were generated.'; diff --git a/questiontestrun.php b/questiontestrun.php index a4ff85d8f3a9f891ee13f55db87c793f4296c216..af54fcb8da9206355a3d2a307bc80c299d789faa 100644 --- a/questiontestrun.php +++ b/questiontestrun.php @@ -429,7 +429,7 @@ if ($question->has_random_variants()) { echo ' ' . stack_string('deploymanynotes'); echo html_writer::end_tag('form'); - // Systematic deployment of variants. + // Systematic deployment of variants (from 1 to ...). echo html_writer::start_tag('form', [ 'method' => 'get', 'class' => 'deploysystematic', 'action' => new moodle_url('/question/type/stack/deploy.php', $urlparams), @@ -445,6 +445,27 @@ if ($question->has_random_variants()) { ]); echo html_writer::end_tag('form'); + // Systematic deployment of variants (from ... to ...). + echo html_writer::start_tag('form', [ + 'method' => 'get', 'class' => 'deploysystematicfromto', + 'action' => new moodle_url('/question/type/stack/deploy.php', $urlparams), + ]); + echo html_writer::input_hidden_params(new moodle_url($PAGE->url, ['sesskey' => sesskey()]), ['seed']); + echo ' ' . html_writer::empty_tag('input', [ + 'type' => 'submit', 'class' => 'btn btn-secondary', + 'value' => stack_string('deploysystematicfrombtn'), + ]); + echo ' ' . html_writer::empty_tag('input', [ + 'type' => 'text', 'size' => 3, + 'id' => 'deploysystematicfromfield', 'name' => 'deploysystematicfrom', 'value' => '', + ]); + echo ' ' . stack_string('deploysystematicto'); + echo ' ' . html_writer::empty_tag('input', [ + 'type' => 'text', 'size' => 3, + 'id' => 'deploysystematictofield', 'name' => 'deploysystematicto', 'value' => '', + ]); + echo html_writer::end_tag('form'); + // Deploy many from a CS list of integer seeds. echo "\n" . html_writer::start_tag('form', [ 'method' => 'get', 'class' => 'deployfromlist',