Skip to content
Snippets Groups Projects
Commit 7de073df authored by Jonas Lache's avatar Jonas Lache
Browse files

Added Deploy seeds n to m feature from issue #1212

parent d5307b80
No related branches found
No related tags found
No related merge requests found
...@@ -81,7 +81,9 @@ if (!is_null($undeploy) && $question->deployedseeds) { ...@@ -81,7 +81,9 @@ if (!is_null($undeploy) && $question->deployedseeds) {
// Process undeployall if applicable. // Process undeployall if applicable.
$deployfromlist = optional_param('deployfromlist', null, PARAM_INT); $deployfromlist = optional_param('deployfromlist', null, PARAM_INT);
$deploysystematic = optional_param('deploysystematic', 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. // Check data integrity.
$dataproblem = false; $dataproblem = false;
...@@ -89,6 +91,9 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) { ...@@ -89,6 +91,9 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) {
if (!is_null($deployfromlist)) { if (!is_null($deployfromlist)) {
$deploytxt = optional_param('deployfromlist', null, PARAM_TEXT); $deploytxt = optional_param('deployfromlist', null, PARAM_TEXT);
$baseseeds = explode("\n", trim($deploytxt)); $baseseeds = explode("\n", trim($deploytxt));
} elseif (!is_null($deploysystematicfrom) && !is_null($deploysystematicto)) {
$baseseeds = range($deploysystematicfrom, $deploysystematicto);
$usefromtofeature = true;
} else { } else {
$baseseeds = range(1, $deploysystematic); $baseseeds = range(1, $deploysystematic);
} }
...@@ -132,11 +137,20 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) { ...@@ -132,11 +137,20 @@ if (!is_null($deployfromlist) || !is_null($deploysystematic)) {
} }
// Undeploy all existing variants. // Undeploy all existing variants.
// If the deploy-from-to feature is used, only undeploy variants that already exist
if ($question->deployedseeds) { if ($question->deployedseeds) {
if ($usefromtofeature) {
foreach ($question->deployedseeds as $seed) { foreach ($question->deployedseeds as $seed) {
if (in_array($seed,$newseeds)) {
$question->undeploy_variant($seed); $question->undeploy_variant($seed);
} }
} }
} else {
foreach ($question->deployedseeds as $seed) {
$question->undeploy_variant($seed);
}
}
}
// Deploy all new variants. // Deploy all new variants.
foreach ($newseeds as $seed) { foreach ($newseeds as $seed) {
$question->deploy_variant($seed); $question->deploy_variant($seed);
......
...@@ -32,7 +32,7 @@ It is your responsibility to make sure the index remains within range! You can ...@@ -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`. 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 Notes
......
...@@ -532,6 +532,8 @@ $string['deployedvariantsn'] = 'Deployed variants ({$a})'; ...@@ -532,6 +532,8 @@ $string['deployedvariantsn'] = 'Deployed variants ({$a})';
$string['deploymanybtn'] = 'Deploy # of variants:'; $string['deploymanybtn'] = 'Deploy # of variants:';
$string['deploymanyerror'] = 'Error in user input: cannot deploy "{$a->err}" variants.'; $string['deploymanyerror'] = 'Error in user input: cannot deploy "{$a->err}" variants.';
$string['deploysystematicbtn'] = 'Deploy seeds from 1 to: '; $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['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['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.'; $string['deploymanynonew'] = 'Too many repeated existing question notes were generated.';
......
...@@ -429,7 +429,7 @@ if ($question->has_random_variants()) { ...@@ -429,7 +429,7 @@ if ($question->has_random_variants()) {
echo ' ' . stack_string('deploymanynotes'); echo ' ' . stack_string('deploymanynotes');
echo html_writer::end_tag('form'); echo html_writer::end_tag('form');
// Systematic deployment of variants. // Systematic deployment of variants (from 1 to ...).
echo html_writer::start_tag('form', [ echo html_writer::start_tag('form', [
'method' => 'get', 'class' => 'deploysystematic', 'method' => 'get', 'class' => 'deploysystematic',
'action' => new moodle_url('/question/type/stack/deploy.php', $urlparams), 'action' => new moodle_url('/question/type/stack/deploy.php', $urlparams),
...@@ -445,6 +445,27 @@ if ($question->has_random_variants()) { ...@@ -445,6 +445,27 @@ if ($question->has_random_variants()) {
]); ]);
echo html_writer::end_tag('form'); 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. // Deploy many from a CS list of integer seeds.
echo "\n" . html_writer::start_tag('form', [ echo "\n" . html_writer::start_tag('form', [
'method' => 'get', 'class' => 'deployfromlist', 'method' => 'get', 'class' => 'deployfromlist',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment