Skip to content

Commit

Permalink
MDL-32188 question CBM: minimal handling of certainty -1
Browse files Browse the repository at this point in the history
Certainty -1 has never been used in standard Moodle, but is
used in Tony-Gardiner Medwin's patches to mean 'No idea' which
we intend to implement: MDL-42077. In the mean time, these changes
avoid errors for people who have used TGM's patches.
  • Loading branch information
timhunt committed Oct 4, 2013
1 parent e74aa0a commit 2bf83cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions question/behaviour/behaviourbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,13 @@ public static function default_certainty() {
* @return number the adjusted fraction taking the certainty into account.
*/
public static function adjust_fraction($fraction, $certainty) {
if ($certainty == -1) {
// Certainty -1 has never been used in standard Moodle, but is
// used in Tony-Gardiner Medwin's patches to mean 'No idea' which
// we intend to implement: MDL-42077. In the mean time, avoid
// errors for people who have used TGM's patches.
return 0;
}
if ($fraction <= 0.00000005) {
return self::$wrongscore[$certainty];
} else {
Expand Down
6 changes: 5 additions & 1 deletion question/behaviour/deferredcbm/behaviourtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public function summarise_usage(question_usage_by_activity $quba, question_displ
}

$certainty = $qa->get_last_behaviour_var('certainty');
if (is_null($certainty)) {
if (is_null($certainty) || $certainty == -1) {
// Certainty -1 has never been used in standard Moodle, but is
// used in Tony-Gardiner Medwin's patches to mean 'No idea' which
// we intend to implement: MDL-42077. In the mean time, avoid
// errors for people who have used TGM's patches.
$certainty = question_cbm::default_certainty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
Best marks are gained by acknowledging uncertainty. For example, if you think there is more than a 1 in 3 chance of being wrong, you should enter C=1 and avoid the risk of a negative mark.
';
$string['certainty_link'] = 'qbehaviour/deferredcbm/certainty';
$string['certainty-1'] = 'No Idea';
$string['certainty1'] = 'C=1 (Unsure: <67%)';
$string['certainty2'] = 'C=2 (Mid: >67%)';
$string['certainty3'] = 'C=3 (Quite sure: >80%)';
$string['certaintyshort-1'] = 'No Idea';
$string['certaintyshort1'] = 'C=1';
$string['certaintyshort2'] = 'C=2';
$string['certaintyshort3'] = 'C=3';
Expand Down

0 comments on commit 2bf83cb

Please sign in to comment.