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

PHP Notice with multianswer shortanswer question correct response with html

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 2.4.8, 2.5.4, 2.6.1
    • 2.4.6, 2.4.7
    • Quiz
    • MOODLE_24_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • 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.

    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

            timhunt Tim Hunt
            mwebster Mark van Hoek
            Mark Nelson Mark Nelson
            Dan Poltawski Dan Poltawski
            Sam Hemelryk Sam Hemelryk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Clockify

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.