MDL-20636 Actually, passing to get_question summary is silly. Revert.

This commit is contained in:
Tim Hunt
2011-01-13 18:36:03 +00:00
parent 6d03299dec
commit ec3d4ef543
11 changed files with 40 additions and 162 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ abstract class question_behaviour {
* @return string|null a plain text summary of this question.
*/
public function get_question_summary() {
return $this->question->get_question_summary($this->qa);
return $this->question->get_question_summary();
}
/**
-1
View File
@@ -65,7 +65,6 @@ abstract class question_bank {
}
$file = get_plugin_directory('qtype', $qtypename) . '/questiontype.php';
if (!is_readable($file)) {
echo 'problem';
if ($mustexist || $qtypename == 'missingtype') {
throw new Exception('Unknown question type ' . $qtypename);
} else {
+1 -2
View File
@@ -231,7 +231,6 @@ class core_question_renderer extends renderer_base {
* @return string the img tag.
*/
protected function get_flag_html($flagged, $id = '') {
global $CFG;
if ($id) {
$id = 'id="' . $id . '" ';
}
@@ -240,7 +239,7 @@ class core_question_renderer extends renderer_base {
} else {
$img = 'unflagged.png';
}
return '<img ' . $id . 'src="' . $CFG->pixpath . '/i/' . $img .
return '<img ' . $id . 'src="' . $this->pix_url('/i/' . $img) .
'" alt="' . get_string('flagthisquestion', 'question') . '" />';
}
+19 -19
View File
@@ -284,9 +284,9 @@ DONE question/behaviour/opaque/lang/en_utf8/qbehaviour_opaque.php | 4 +
question/type/calculated/questiontype.php | 19 +-
question/type/calculated/version.php | 2 -
question/type/datasetdependent/abstractqtype.php | 4 +-
question/type/datasetdependent/datasetdefinitions_form.php | 1 -
question/type/datasetdependent/datasetitems_form.php | 1 -
DONE question/type/datasetdependent/abstractqtype.php | 4 +-
DONE question/type/datasetdependent/datasetdefinitions_form.php | 1 -
DONE question/type/datasetdependent/datasetitems_form.php | 1 -
question/type/ddwtos/db/install.xml | 23 +
question/type/ddwtos/db/upgrade.php | 83 +
@@ -304,23 +304,23 @@ DONE question/behaviour/opaque/lang/en_utf8/qbehaviour_opaque.php | 4 +
question/type/ddwtos/styles.css | 67 +
question/type/ddwtos/version.php | 4 +
question/type/description/edit_description_form.php | 15 +-
question/type/description/lang/en_utf8/qtype_description.php | 5 +
question/type/description/question.html | 19 -
question/type/description/question.php | 35 +
question/type/description/questiontype.php | 90 +-
question/type/description/renderer.php | 41 +
question/type/description/simpletest/testquestiontype.php | 65 +
DONE question/type/description/edit_description_form.php | 15 +-
DONE question/type/description/lang/en_utf8/qtype_description.php | 5 +
DONE question/type/description/question.html | 19 -
DONE question/type/description/question.php | 35 +
DONE question/type/description/questiontype.php | 90 +-
DONE question/type/description/renderer.php | 41 +
DONE question/type/description/simpletest/testquestiontype.php | 65 +
question/type/essay/display.html | 22 -
question/type/essay/edit_essay_form.php | 31 +-
question/type/essay/lang/en_utf8/qtype_essay.php | 5 +
question/type/essay/question.php | 64 +
question/type/essay/questiontype.php | 164 +-
question/type/essay/renderer.php | 65 +
question/type/essay/simpletest/testquestion.php | 50 +
question/type/essay/simpletest/testquestiontype.php | 71 +
question/type/essay/version.php | 2 -
DONE question/type/essay/display.html | 22 -
DONE question/type/essay/edit_essay_form.php | 31 +-
DONE question/type/essay/lang/en_utf8/qtype_essay.php | 5 +
DONE question/type/essay/question.php | 64 +
DONE question/type/essay/questiontype.php | 164 +-
DONE question/type/essay/renderer.php | 65 +
DONE question/type/essay/simpletest/testquestion.php | 50 +
DONE question/type/essay/simpletest/testquestiontype.php | 71 +
DONE question/type/essay/version.php | 2 -
question/type/match/db/install.xml | 6 +-
question/type/match/db/upgrade.php | 44 +
@@ -37,8 +37,7 @@ class qtype_essay_question_test extends UnitTestCase {
public function test_get_question_summary() {
$essay = test_question_maker::make_an_essay_question();
$essay->questiontext = 'Hello <img src="http://example.com/globe.png" alt="world" />';
$this->assertEqual('Hello [world]', $essay->get_question_summary(
test_question_maker::get_a_qa($essay)));
$this->assertEqual('Hello [world]', $essay->get_question_summary());
}
public function test_summarise_response() {
-20
View File
@@ -1,20 +0,0 @@
<div class="qtext">
<?php echo $questiontext; ?>
</div>
<?php if ($anss) { ?>
<div class="ablock clearfix">
<div class="prompt">
<?php print_string('answers', 'quiz'); ?>
</div>
<table class="answer">
<?php $row = 1; foreach ($anss as $answer) { ?>
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<td class="c1 text">
<?php echo $answer->text; ?>
</td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
@@ -1,78 +0,0 @@
<?php
///////////////////
/// missingtype ///
///////////////////
/// QUESTION TYPE CLASS //////////////////
/**
* Missing question type class
*
* When a question is encountered with a type that is not installed then its
* type is changed to 'missingtype'. This questiontype just makes sure that the
* necessary information is printed about the question.
* @package questionbank
* @subpackage questiontypes
*/
class question_missingtype_qtype extends default_questiontype {
function name() {
return 'missingtype';
}
function menu_name() {
return false;
}
function is_usable_by_random() {
return false;
}
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
global $CFG;
$answers = &$question->options->answers;
$formatoptions = new stdClass;
$formatoptions->noclean = true;
$formatoptions->para = false;
// Print formulation
$questiontext = format_text($question->questiontext,
$question->questiontextformat,
$formatoptions, $cmoptions->course);
// Print each answer in a separate row if there are any
$anss = array();
if ($answers) {
foreach ($answers as $answer) {
$a = new stdClass;
$a->text = format_text($answer->answer, $answer->answerformat, $formatoptions, $cmoptions->course);
$anss[] = clone($a);
}
}
include("$CFG->dirroot/question/type/missingtype/display.html");
}
function grade_responses(&$question, &$state, $cmoptions) {
return true;
}
function display_question_editing_page(&$mform, $question, $wizardnow){
global $OUTPUT;
echo $OUTPUT->heading(get_string('warningmissingtype', 'qtype_missingtype'));
$mform->display();
}
}
//// END OF CLASS ////
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_missingtype_qtype());
-34
View File
@@ -1,34 +0,0 @@
<div class="qtext">
<?php echo $questiontext; ?>
</div>
<div class="ablock clearfix">
<div class="prompt">
<?php echo $answerprompt; ?>
</div>
<table class="answer">
<?php $row = 1; foreach ($anss as $answer) { ?>
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<td class="c0 control">
<?php echo $answer->control; ?>
</td>
<td class="c1 text <?php echo $answer->class ?>">
<label for="<?php echo $answer->id ?>">
<?php echo $answer->text; ?>
<?php echo $answer->feedbackimg; ?>
</label>
</td>
<td class="c0 feedback">
<?php echo $answer->feedback; ?>
</td>
</tr>
<?php } ?>
</table>
<?php if ($feedback) { ?>
<div class="feedback">
<?php echo $feedback ?>
</div>
<?php } ?>
<?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
</div>
+16 -3
View File
@@ -158,8 +158,8 @@ abstract class question_definition {
* inappropriate.
* @return string|null a plain text summary of this question.
*/
public function get_question_summary(question_attempt $qa) {
return html_to_text($this->format_questiontext($qa), 0, false);
public function get_question_summary() {
return $this->html_to_text($this->questiontext);
}
/**
@@ -197,7 +197,7 @@ abstract class question_definition {
* @return qtype_renderer the renderer to use for outputting this question.
*/
public function get_renderer() {
global $PAGE;
global $PAGE; // TODO get rid of this global.
return $PAGE->get_renderer('qtype_' . $this->qtype->name());
}
@@ -236,6 +236,7 @@ abstract class question_definition {
* @return string the text formatted for output by format_text.
*/
public function format_text($text, $qa, $component, $filearea, $itemid, $clean = false) {
// TODO format.
$formatoptions = new stdClass;
$formatoptions->noclean = !$clean;
$formatoptions->para = false;
@@ -243,6 +244,18 @@ abstract class question_definition {
return format_text($text, $this->questiontextformat, $formatoptions);
}
/**
* Convert some part of the question text to plain text. This might be used,
* for example, by get_response_summary().
* @param string $text The HTML to reduce to plain text.
*/
public function html_to_text($text) {
$formatoptions = new stdClass;
$formatoptions->noclean = true;
return html_to_text(format_text($text, $this->questiontextformat, $formatoptions),
0, false);
}
/** @return the result of applying {@link format_text()} to the question text. */
public function format_questiontext($qa) {
return $this->format_text($this->questiontext, $qa,
@@ -116,7 +116,7 @@ class qtype_shortanswer_question_test extends UnitTestCase {
public function test_get_question_summary() {
$sa = test_question_maker::make_a_shortanswer_question();
$qsummary = $sa->get_question_summary(test_question_maker::get_a_qa($sa));
$qsummary = $sa->get_question_summary();
$this->assertEqual('Name an amphibian: __________', $qsummary);
}
@@ -73,7 +73,7 @@ class qtype_truefalse_question_test extends UnitTestCase {
public function test_get_question_summary() {
$tf = test_question_maker::make_a_truefalse_question();
$qsummary = $tf->get_question_summary(test_question_maker::get_a_qa($tf));
$qsummary = $tf->get_question_summary();
$this->assertEqual('The answer is true.', $qsummary);
}