Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-43000

PHP Notice with multianswer shortanswer question correct response with html

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.6, 2.4.7
    • Fix Version/s: 2.4.8, 2.5.4, 2.6.1
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a Cloze question like the one in the issue description.

      Type smomething enclosed in em tags: {1:SHORTANSWER:=********************************<em>***************************</em>***********************}
      

      2. Preview it, ensuring that all the Display options are turned on.

      3. Answer it, and type something like <em>frog</em>.

      4. Verify that there are no notices, that your response is graded as correct, and that the feedback tooltip shows the right correct answer.

      Show
      1. Create a Cloze question like the one in the issue description. Type smomething enclosed in em tags: {1:SHORTANSWER:=********************************<em>***************************</em>***********************} 2. Preview it, ensuring that all the Display options are turned on. 3. Answer it, and type something like <em>frog</em>. 4. Verify that there are no notices, that your response is graded as correct, and that the feedback tooltip shows the right correct answer.
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Two issues:
      • The html tags are not stripped when the question is edited.
      • If the tags are present, $correctanswer is not an object.
      To reproduce:
      • Moodle 2.4.7 (Build: 20131111)
      • Create a quiz question > Multianswer (Embedded answer/Cloze) > with something like this question text:

         
        During my two hour study session, I will be working on {1:MULTICHOICE:=1. studying for a quiz~2. lab assignment~3. reading the textbook~4. lecture learning~5. seminar engagement~6. practice questions or test~7. SOMETHING ELSE} in {1:SHORTANSWER:=****************************<em>****<em>****************************<em>****</em></em>***********************</em>******************************************************} (eg. PSY 100).
        

      I've added some error_log() lines to /question/type/multianswer/renderer.php ~line 222

              error_log(__FUNCTION__.'::qtype='.$subq->qtype->name());
              error_log(__FUNCTION__.'::$correctanswer='.is_object($correctanswer));
              error_log(__FUNCTION__.'::id='.$inputattributes['id']);
              $feedbackpopup = $this->feedback_popup($subq, $matchinganswer->fraction,
                      $subq->format_text($matchinganswer->feedback, $matchinganswer->feedbackformat,
                             	$qa, 'question', 'answerfeedback', $matchinganswer->id),
                      s($correctanswer->answer), $options);
      

      I get this in the PHP error log when I review a student's quiz attempt:

      [error] subquestion::qtype=shortanswer
      [error] subquestion::$correctanswer=
      [error] subquestion::id=q24366:8_sub2_answer
      [error] PHP Notice: Trying to get property of non-object in /question/type/multianswer/renderer.php on line 228, referer: http://moodle.mydomain.com/question/question.php?cmid=3850&returnurl=%2Fmod%2Fquiz%2Freview.php%3Fattempt%3D23623%23q8&id=20371

        Attachments

          Activity

            People

            • Assignee:
              timhunt Tim Hunt
              Reporter:
              mwebster Mark van Hoek
              Peer reviewer:
              Mark Nelson
              Integrator:
              Dan Poltawski
              Tester:
              Sam Hemelryk
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Jan/14