Moodle

The subquestions and subanswers in the Renderedmatch question type don't show up when you try to edit them!!!!

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.2
  • Fix Version/s: 1.7.2
  • Component/s: Questions, Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_16_STABLE
  • Fixed Branches:
    MOODLE_17_STABLE

Description

When you are editing a quiz, well editing a question in a quiz, and the question is a renderedmatch question the subquestions and subanswers don't show up in the text field. The implementation of question/question.php gets data from teh question table, but doesn't take data from the question_renderedmatch_sub table, which is where the subquestions and subanswers are stored. I have fixed this by adding code at line 55 in question/question.php . In the "if($id)" branch
right after $qtype=$question->qtype I have added this code:

$qtype = $question->qtype;

/beginning of new code/
if($qtype=="renderedmatch")
{
if (! $subs = get_records("question_renderedmatch_sub", "question", $id))

{ error("This question doesn't exist"); }

foreach($subs as $subquestion)

{ $subquestions[]=$subquestion->questiontext; $subanswers[]=$subquestion->answertext; }

}
/end of new code/

The variables are named subquestion[] and subanswers[] since question/type/renderedmatch/editsubquestion.php trys to insert $subquestion[$i] and $subanswer[$i] into the text fields, and it only needs teh questiontext and the answertext. When you edit these questions though I still thought something would need to be added to ensure that the sub(questions and answers) were changed in the database, but after testing the database is changed. So it would appear that $question = $QTYPES[$qtype]->save_question($question, $form, $course); saves the renderedmatch sub information. If this is the case then this code should be fine.

Activity

Hide
Jean-Michel Vedrine added a comment -

This bug was in fact caused by the fact that when this questiontype was updated for Moodle 1.6 in some places of the code the tables name was not changed from quiz_ to question_. This has been corrected a few months ago and the actual code in contrib/plugins/question/type/renderedmatch CVS works with Moodle 1.6, 1.7 and 1.8 (and is in the process of been adapted to Moodle 1.9 too)

Show
Jean-Michel Vedrine added a comment - This bug was in fact caused by the fact that when this questiontype was updated for Moodle 1.6 in some places of the code the tables name was not changed from quiz_ to question_. This has been corrected a few months ago and the actual code in contrib/plugins/question/type/renderedmatch CVS works with Moodle 1.6, 1.7 and 1.8 (and is in the process of been adapted to Moodle 1.9 too)
Hide
Jean-Michel Vedrine added a comment -

Closing this issue because it is now fixed

Show
Jean-Michel Vedrine added a comment - Closing this issue because it is now fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: