Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Short-answer fixes:

As the wild card feature makes it possible for a response to match more than one answer alternative, I made sure that the alternative with the
highest grade would count.
I also fixed bug #945 for the short answer case.
  • Loading branch information...
commit 5276dc48877ffb57855f394b762915f204a49205 1 parent 0226a97
authored

Showing 1 changed file with 12 additions and 11 deletions. Show diff stats Hide diff stats

  1. 23  mod/quiz/lib.php
23  mod/quiz/lib.php
@@ -1613,31 +1613,32 @@ function quiz_grade_attempt_question_result($question,
1613 1613
                 $question->answer = "";
1614 1614
             }
1615 1615
             $response[0] = $question->answer;
1616  
-            $bestshortanswer = 0;
  1616
+            $feedback[0] = '';  // Default
1617 1617
             foreach ($answers as $answer) {  // There might be multiple right answers
1618 1618
 
1619 1619
                 $answer->answer = trim($answer->answer);  // Just in case
1620 1620
 
1621  
-                if ($answer->fraction > $bestshortanswer) {
1622  
-                    $correct[$answer->id] = $answer->answer;
1623  
-                    $bestshortanswer = $answer->fraction;
  1621
+                if ($answer->fraction >= 1.0) {
  1622
+                    $correct[] = $answer->answer;
1624 1623
                 }
1625 1624
                 if (!$answer->usecase) {       // Don't compare case
1626 1625
                     $answer->answer = strtolower($answer->answer);
1627 1626
                     $question->answer = strtolower($question->answer);
1628 1627
                 }
1629 1628
 
1630  
-                if ((strpos(' '.$answer->answer, '*'))) {
  1629
+                $potentialgrade = (float)$answer->fraction * $question->grade;
  1630
+
  1631
+                if ($potentialgrade >= $grade
  1632
+                        and (strpos(' '.$answer->answer, '*'))) {
1631 1633
                     $answer->answer = eregi_replace('\*','.*',$answer->answer);
1632 1634
                     if (eregi('^'.$answer->answer.'$', $question->answer)) {
1633 1635
                         $feedback[0] = $answer->feedback;
1634  
-                        $grade = (float)$answer->fraction * $question->grade;
1635  
-                    }
1636  
-                } else {
1637  
-                    if ($answer->answer == $question->answer) {
1638  
-                        $feedback[0] = $answer->feedback;
1639  
-                        $grade = (float)$answer->fraction * $question->grade;
  1636
+                        $grade = $potentialgrade;
1640 1637
                     }
  1638
+
  1639
+                } else if ($answer->answer == $question->answer) {
  1640
+                    $feedback[0] = $answer->feedback;
  1641
+                    $grade = $potentialgrade;
1641 1642
                 }
1642 1643
             }
1643 1644
             break;

0 notes on commit 5276dc4

Please sign in to comment.
Something went wrong with that request. Please try again.