@@ -395,4 +395,21 @@ public function test_decimals() {
395395 $ expected = 'A correct answer is: <code>3,1415</code> ' ;
396396 $ this ->assertEquals ($ expected , $ el ->get_teacher_answer_display (false , false ));
397397 }
398+
399+ public function test_validate_student_response_castext () {
400+ $ options = new stack_options ();
401+ $ ta = '[[1+x^2,false],[1-x^2,false], ' .
402+ '["1+x^3",true,["%root","Hello world ",["smlt"," \\({x^3} \\)"]]]] ' ;
403+ $ el = stack_input_factory::make ('dropdown ' , 'ans1 ' , $ ta , $ options , ['options ' => '' ]);
404+ $ el ->adapt_to_model_answer ($ ta );
405+ $ state = $ el ->validate_student_response (['ans1 ' => '2 ' ], $ options , '2 ' , new stack_cas_security ());
406+ $ this ->assertEquals (stack_input::SCORE , $ state ->status );
407+
408+ $ ta = '[[1+x^2,true],[1-x^2,false], ' .
409+ '["1+x^3",false,["%root","Hello world ",["smlt"," \\({x^3} \\)"]]]] ' ;
410+ $ el = stack_input_factory::make ('dropdown ' , 'ans1 ' , $ ta , $ options , ['options ' => '' ]);
411+ $ el ->adapt_to_model_answer ($ ta );
412+ $ state = $ el ->validate_student_response (['ans1 ' => '2 ' ], $ options , '2 ' , new stack_cas_security ());
413+ $ this ->assertEquals (stack_input::SCORE , $ state ->status );
414+ }
398415}
0 commit comments