Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 15... Línea 15...
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
namespace qtype_truefalse;
17
namespace qtype_truefalse;
-
 
18
 
Línea 18... Línea 19...
18
 
19
use question_state;
Línea 19... Línea 20...
19
use question_state;
20
use question_display_options;
20
 
21
 
Línea 30... Línea 31...
30
 * @package    qtype_truefalse
31
 * @package    qtype_truefalse
31
 * @copyright  2011 The Open University
32
 * @copyright  2011 The Open University
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @covers     \qtype_truefalse_question
34
 * @covers     \qtype_truefalse_question
34
 */
35
 */
35
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
36
final class walkthrough_test extends \qbehaviour_walkthrough_test_base {
36
    public function test_false_right_does_not_show_feedback_when_not_answered(): void {
37
    public function test_false_right_does_not_show_feedback_when_not_answered(): void {
Línea 37... Línea 38...
37
 
38
 
38
        // Create a true-false question with correct answer false.
39
        // Create a true-false question with correct answer false.
39
        $tf = \test_question_maker::make_question('truefalse', 'false');
40
        $tf = \test_question_maker::make_question('truefalse', 'false');
Línea 154... Línea 155...
154
        $this->start_attempt_at_question($tf, 'deferredfeedback', 1);
155
        $this->start_attempt_at_question($tf, 'deferredfeedback', 1);
155
        $this->render();
156
        $this->render();
Línea 156... Línea 157...
156
 
157
 
157
        // Check for 'Show standard instruction'.
158
        // Check for 'Show standard instruction'.
158
        $standardinstruction = \html_writer::tag('legend', get_string('answer'), [
159
        $standardinstruction = \html_writer::tag('legend', get_string('answer'), [
159
            'class' => 'prompt h6 font-weight-normal sr-only'
160
            'class' => 'prompt h6 fw-normal visually-hidden',
160
        ]);
161
        ]);
161
        $this->assertStringContainsString($standardinstruction, $this->currentoutput);
162
        $this->assertStringContainsString($standardinstruction, $this->currentoutput);
-
 
163
    }
-
 
164
 
-
 
165
    /**
-
 
166
     * Tests that the general feedback box is not displayed when it is empty for a false answer.
-
 
167
     *
-
 
168
     * @covers ::format_generalfeedback
-
 
169
     */
-
 
170
    public function test_false_right_does_not_show_empty_general_feedback_when_answer(): void {
-
 
171
        $tf = \test_question_maker::make_question('truefalse', 'false');
-
 
172
        $this->start_attempt_at_question($tf, 'deferredfeedback', 1);
-
 
173
        $this->process_submission(data: ['answer' => 0]);
-
 
174
        $this->quba->finish_all_questions();
-
 
175
        $displayoptions = new question_display_options();
-
 
176
        $html = $this->quba->render_question(1, $displayoptions);
-
 
177
        $pattern = "/<div class=\"generalfeedback\">\s*<div class=\"clearfix\">\s*{$tf->generalfeedback}\s*<\/div>\s*<\/div>/";
-
 
178
        $this->assertMatchesRegularExpression($pattern, $html);
-
 
179
 
-
 
180
        $tf->generalfeedback = "";
-
 
181
        $this->start_attempt_at_question($tf, 'deferredfeedback', 1);
-
 
182
        $this->process_submission(data: ['answer' => 0]);
-
 
183
        $this->quba->finish_all_questions();
-
 
184
        $html = $this->quba->render_question(1, $displayoptions);
-
 
185
        $pattern = "/<div class=\"generalfeedback\">\s*<div class=\"clearfix\"><\/div>\s*<\/div>/";
-
 
186
        $this->assertDoesNotMatchRegularExpression($pattern, $html);
162
    }
187
    }