Alright, I tracked down the problem and have a fix!
To reitterate:
On a Lesson question page, the question content is being used as the title. The question title is completely disregarded.
This issue affects all question types (short answer, essay, multichoice, matching, numeric, true/false).
Problem:
Figure 1: The backend showing the 2 fields
The page title is completely absent from the rendered question and the content is found where the title SHOULD be.
Figure 2: The rendered question. Note no page title and the legend being off kilter
Firefox and Chrome handle this issue much more gracefully than IE, but it’s still wrong.
A closer look at the code reveals that in fact the page content is being placed inside of the legend (markup and all) which is almost definitely wrong.
<fieldset class="clearfix" id="pageheader">
<legend class="ftoggler">
<div class="box contents">
<p>This is a big ol question and you should probably have this be a buig fraking pain in the neck…SNIP
</p>
</div>
</legend>
<div class="advancedbutton"></div>
<div class="fcontainer clearfix">
<div class="fitem">
<div class="fitemtitle">
<label for="id_answer">Your answer </label>
</div>
<div class="felement ftext">
<input size="50" maxlength="200" name="answer" type="text" id="id_answer" />
</div>
</div>
</div>
</fieldset>
|
Table 1 Incorrectly rendered code
Solution:
You will modify the following files inside of /mod/lesson/pagetypes/:
- shortanswer.php
- truefalse.php
- numerical.php
- multichoice.php
- matching.php
- essay.php
In each file you will modify the function display().
Modifying display()
Find the line that looks something like
$mform = new lesson_display_answer_form_ANSWERTYPE(…);
The second parameter of new lesson_display_answer_form_ANSWERTYPE() is an array. Inside that array you should see ‘content’->$this->getContents(). Add to the array 'title'=>$this->title. Order doesn’t matter.
You’re done modifying display(). Now onto modifying lesson_display_answer_form_ANSWERTYPE::definition()!
Modifying lesson_display_answer_form_ANSWERTYPE::definition()
Find the line that looks like $contents = $this->_customdata['contents'];
Under that line, add $title = $this->_customdata['title'];
Comment out the line that looks like $mform->addElement('header', 'pageheader', $OUTPUT->box($contents, 'contents'));
Add the following two lines under the line you just commented out:
$mform->addElement('header', 'pageheader', $title);
$mform->addElement('html', $OUTPUT->box($contents, 'contents'));
That’s it! You’ve fixed this rendering issue. Save your changes and test to be sure it’s working. Be sure to make these fixes in all 6 question-type files.
Figure 3: The content and the title are now in the correct places!
<fieldset class="clearfix" id="pageheader">
<legend class="ftoggler">lesson question 1</legend>
<div class="advancedbutton"></div>
<div class="fcontainer clearfix">
<div class="box contents"><p>This is a big ol question and you should probably have this be a …SNIP</p>
</div>
<div class="fitem">
<div class="fitemtitle">
<label for="id_answer">Your answer </label>
</div>
<div class="felement ftext">
<input size="50" maxlength="200" name="answer" type="text" id="id_answer" />
</div>
</div>
</div>
</fieldset>
|
Table 2 The correctly rendered code