Skip to content
Snippets Groups Projects
Commit 71f506a0 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Fix to issue #619.

parent e277b122
No related branches found
No related tags found
No related merge requests found
......@@ -471,13 +471,15 @@ class qtype_stack extends question_type {
}
$totalvalue = 0;
$allformative = true;
foreach ($questiondata->prts as $name => $prtdata) {
// At this point we do not have the PRT method is_formative() available to us.
if ($prtdata->feedbackstyle > 0) {
$totalvalue += $prtdata->value;
$allformative = false;
}
}
if ($questiondata->prts && $totalvalue < 0.0000001) {
if ($questiondata->prts && !$allformative && $totalvalue < 0.0000001) {
throw new coding_exception('There is an error authoring your question. ' .
'The $totalvalue, the marks available for the question, must be positive in question ' .
$question->name);
......@@ -522,8 +524,12 @@ class qtype_stack extends question_type {
$feedbackvariables = null;
}
$prtvalue = 0;
if (!$allformative) {
$prtvalue = $prtdata->value / $totalvalue;
}
$question->prts[$name] = new stack_potentialresponse_tree($name, '',
(bool) $prtdata->autosimplify, $prtdata->value / $totalvalue,
(bool) $prtdata->autosimplify, $prtvalue,
$feedbackvariables, $nodes, (string) $prtdata->firstnodename, (int) $prtdata->feedbackstyle);
}
......
......@@ -35,7 +35,7 @@ class stack_potentialresponse_tree {
/** @var bool Should this PRT simplify when its arguments are evaluated? */
private $simplify;
/** @var float total amount of fraction available from this PRT. */
/** @var float total amount of fraction available from this PRT. Zero is possible for formative PRT questions. */
private $value;
/** @var stack_cas_session2 Feeback variables. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment