mirror of
https://github.com/moodle/moodle.git
synced 2025-08-02 15:49:43 +02:00
MDL-20636 make qe upgrade tests independent of html2text details.
Based on Eloy's change, but refactored to be slightly nicer.
This commit is contained in:
parent
0370e3ab0d
commit
4c5743343f
14 changed files with 79 additions and 50 deletions
|
@ -593,7 +593,7 @@ function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffi
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
</textarea>';
|
||||
}
|
||||
|
|
|
@ -125,4 +125,33 @@ class question_attempt_upgrader_test_base extends UnitTestCase {
|
|||
public function tearDown() {
|
||||
$this->updater = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear text, bringing independence of html2text results
|
||||
*
|
||||
* Some tests performing text comparisons of converted text are too much
|
||||
* dependent of the behavior of the html2text library. This function is
|
||||
* aimed to reduce such dependencies that should not affect the results
|
||||
* of these question attempt upgrade tests.
|
||||
*/
|
||||
protected function clear_html2text_dependencies($qa) {
|
||||
// Cleaning all whitespace should be enough to ignore any html2text dependency
|
||||
if (property_exists($qa, 'responsesummary')) {
|
||||
$qa->responsesummary = preg_replace('/\s/', '', $qa->responsesummary);
|
||||
}
|
||||
if (property_exists($qa, 'questionsummary')) {
|
||||
$qa->questionsummary = preg_replace('/\s/', '', $qa->questionsummary);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two qas, ignoring inessential differences.
|
||||
* @param object $expectedqa the expected qa.
|
||||
* @param object $qa the actual qa.
|
||||
*/
|
||||
protected function compare_qas($expectedqa, $qa) {
|
||||
$this->clear_html2text_dependencies($expectedqa);
|
||||
$this->clear_html2text_dependencies($qa);
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ Remember to type a unit.',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculated_adaptive_qsession100() {
|
||||
|
@ -475,7 +475,7 @@ Remember to type a unit.',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculated_adaptive_qsession103() {
|
||||
|
@ -695,6 +695,6 @@ Remember to type a unit.',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ class qtype_calculatedmulti_attempt_upgrader_test extends question_attempt_upgra
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculatedmulti_adaptive_qsession99() {
|
||||
|
@ -498,7 +498,7 @@ class qtype_calculatedmulti_attempt_upgrader_test extends question_attempt_upgra
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculatedmulti_adaptive_qsession102() {
|
||||
|
@ -800,6 +800,6 @@ class qtype_calculatedmulti_attempt_upgrader_test extends question_attempt_upgra
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ class qtype_calculatedsimple_attempt_upgrader_test extends question_attempt_upgr
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculatedsimple_adaptive_qsession98() {
|
||||
|
@ -446,7 +446,7 @@ class qtype_calculatedsimple_attempt_upgrader_test extends question_attempt_upgr
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_calculatedsimple_adaptive_qsession101() {
|
||||
|
@ -632,6 +632,6 @@ class qtype_calculatedsimple_attempt_upgrader_test extends question_attempt_upgr
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ class qtype_description_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_description_deferredfeedback_history70() {
|
||||
|
@ -327,7 +327,7 @@ class qtype_description_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_description_deferredfeedback_history0() {
|
||||
|
@ -455,6 +455,6 @@ class qtype_description_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ class qtype_essay_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_essay_deferredfeedback_history820() {
|
||||
|
@ -449,7 +449,7 @@ class qtype_essay_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_essay_deferredfeedback_missing() {
|
||||
|
@ -561,6 +561,6 @@ class qtype_essay_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ class qtype_match_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
}
|
||||
}
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_match_deferredfeedback_history60() {
|
||||
|
@ -482,7 +482,7 @@ class qtype_match_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
}
|
||||
}
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_match_deferredfeedback_history622220() {
|
||||
|
@ -782,6 +782,6 @@ class qtype_match_attempt_upgrader_test extends question_attempt_upgrader_test_b
|
|||
}
|
||||
}
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multianswer_adaptivenopenalty_qsession106() {
|
||||
|
@ -421,7 +421,7 @@ class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multianswer_adaptivenopenalty_qsession108() {
|
||||
|
@ -646,7 +646,7 @@ class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multianswer_adaptivenopenalty_qsession105() {
|
||||
|
@ -1332,7 +1332,7 @@ b) What grade would you give it? _____',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multianswer_adaptivenopenalty_qsession107() {
|
||||
|
@ -1990,7 +1990,7 @@ b) What grade would you give it? _____',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multianswer_adaptivenopenalty_qsession109() {
|
||||
|
@ -2724,6 +2724,6 @@ b) What grade would you give it? _____',
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_history0() {
|
||||
|
@ -431,7 +431,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_history60() {
|
||||
|
@ -634,7 +634,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_history6220() {
|
||||
|
@ -873,7 +873,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_missing() {
|
||||
|
@ -1007,7 +1007,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession140() {
|
||||
|
@ -1209,7 +1209,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession2018195() {
|
||||
|
@ -1455,7 +1455,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession2653368() {
|
||||
|
@ -1679,7 +1679,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession3131() {
|
||||
|
@ -1924,7 +1924,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession4307870 () {
|
||||
|
@ -2129,7 +2129,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession49446() {
|
||||
|
@ -2344,7 +2344,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession591() {
|
||||
|
@ -2553,7 +2553,7 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_multichoice_deferredfeedback_qsession594() {
|
||||
|
@ -2764,6 +2764,6 @@ public function test_multichoice_deferredfeedback_qsession140() {
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ class qtype_numerical_attempt_upgrader_test extends question_attempt_upgrader_te
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_numerical_deferredfeedback_required_units() {
|
||||
|
@ -458,6 +458,6 @@ class qtype_numerical_attempt_upgrader_test extends question_attempt_upgrader_te
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_random_deferredfeedback_qsession4225582() {
|
||||
|
@ -513,7 +513,7 @@ class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_random_deferredfeedback_qsession3481928() {
|
||||
|
@ -783,7 +783,7 @@ class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_numerical_deferredfeedback_qsession55() {
|
||||
|
@ -980,6 +980,6 @@ class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_shortanswer_deferredfeedback_history60() {
|
||||
|
@ -419,7 +419,7 @@ class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_shortanswer_deferredfeedback_history3220() {
|
||||
|
@ -635,6 +635,6 @@ class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ class qtype_truefalse_attempt_upgrader_test extends question_attempt_upgrader_te
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_truefalse_deferredfeedback_history20() {
|
||||
|
@ -404,7 +404,7 @@ class qtype_truefalse_attempt_upgrader_test extends question_attempt_upgrader_te
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
|
||||
public function test_truefalse_deferredfeedback_history90() {
|
||||
|
@ -581,6 +581,6 @@ class qtype_truefalse_attempt_upgrader_test extends question_attempt_upgrader_te
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertEqual($expectedqa, $qa);
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue