Skip to content
Snippets Groups Projects
Commit 8b20c33d authored by Chris Sangwin's avatar Chris Sangwin
Browse files

First use of html_writer::tag....

parent 3d609fc9
Branches
No related tags found
No related merge requests found
...@@ -64,5 +64,5 @@ function stack_maxima_translate($rawfeedback) { ...@@ -64,5 +64,5 @@ function stack_maxima_translate($rawfeedback) {
} }
function stack_maxima_format_casstring($str) { function stack_maxima_format_casstring($str) {
return '<span class=\'SyntaxExample2\'>'.$str.'</span>'; return html_writer::tag('span', $str, array('class' => 'SyntaxExample2'));
} }
...@@ -72,6 +72,7 @@ class qtype_stack_question extends question_graded_automatically { ...@@ -72,6 +72,7 @@ class qtype_stack_question extends question_graded_automatically {
public function start_attempt(question_attempt_step $step, $variant) { public function start_attempt(question_attempt_step $step, $variant) {
$seed = time(); $seed = time();
$this->seed = $seed;
$step->set_qt_var('_seed', $seed); $step->set_qt_var('_seed', $seed);
$questionvars = new stack_cas_keyval($this->questionvariables, $this->options, $seed, 't'); $questionvars = new stack_cas_keyval($this->questionvariables, $this->options, $seed, 't');
......
...@@ -33,13 +33,13 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -33,13 +33,13 @@ defined('MOODLE_INTERNAL') || die();
class qtype_stack_renderer extends qtype_renderer { class qtype_stack_renderer extends qtype_renderer {
public function formulation_and_controls(question_attempt $qa, question_display_options $options) { public function formulation_and_controls(question_attempt $qa, question_display_options $options) {
$question = $qa->get_question(); $question = $qa->get_question();
//$response = $question->get_response($qa);
$questiontext = $question->questiontext; $questiontext = $question->questiontext;
$seed = 0; //$question->seed; $seed = 0; //$question->seed;
$session = null; // $question->session;
$session = null; // $questionvars->get_session(); // $question->session;
if (empty($question->interactions)) { if (empty($question->interactions)) {
$xhtml = '<div class="secondaryFeedback">'.stack_string('stackQuestion_noQuestionParts').'</div>'.$questiontext; $xhtml = html_writer::tag('div', stack_string('stackQuestion_noQuestionParts'), array('class' => 'secondaryFeedback')).$questiontext;
} else { } else {
foreach ($question->interactions as $name => $interaction) { foreach ($question->interactions as $name => $interaction) {
$fieldname = $qa->get_qt_field_name($name); $fieldname = $qa->get_qt_field_name($name);
...@@ -61,9 +61,8 @@ class qtype_stack_renderer extends qtype_renderer { ...@@ -61,9 +61,8 @@ class qtype_stack_renderer extends qtype_renderer {
} else { // TODO... } else { // TODO...
$results['feedback'] = ''; $results['feedback'] = '';
} }
$feedback = $this->format_prt_feedback($results['feedback']);
$questiontext = str_replace("<PRTfeedback>{$index}</PRTfeedback>", $feedback, $questiontext); $questiontext = str_replace("<PRTfeedback>{$index}</PRTfeedback>", $results['feedback'], $questiontext);
} }
} }
return $question->format_text($questiontext, $question->questiontextformat, return $question->format_text($questiontext, $question->questiontextformat,
......
...@@ -308,15 +308,16 @@ class stack_interaction_element { ...@@ -308,15 +308,16 @@ class stack_interaction_element {
return ''; return '';
} }
$feedback = '<div class="InteractionElementFeedback">';
$feedback .= '<p class="studentFeedback">'.stack_string('studentValidation_yourLastAnswer').$display.'</p>'; $feedback = html_writer::start_tag('div', array('class' => 'InteractionElementFeedback'));
$feedback .= html_writer::tag('p', stack_string('studentValidation_yourLastAnswer').$display, array('class' => 'studentFeedback'));
if (!$valid) { if (!$valid) {
$feedback .= '<span class="studentFeedback">'.stack_string('studentValidation_invalidAnswer').'</span>'; $feedback .= html_writer::tag('span', stack_string('studentValidation_invalidAnswer'), array('class' => 'studentFeedback'));
} }
if ('' != $errors) { if ('' != $errors) {
$feedback .= '<span class="studentFeedback">'.$errors.'</span>'; $feedback .= html_writer::tag('span', $errors, array('class' => 'errors'));
} }
$feedback .= '</div>'; $feedback .= html_writer::end_tag('div');
return $feedback; return $feedback;
} }
......
...@@ -175,7 +175,7 @@ class stack_potentialresponse_tree { ...@@ -175,7 +175,7 @@ class stack_potentialresponse_tree {
// Tidy up the results. // Tidy up the results.
$feedbackct = new stack_cas_text(implode(' ', $results['feedback']), $cascontext, $seed, 't', false, false); $feedbackct = new stack_cas_text(implode(' ', $results['feedback']), $cascontext, $seed, 't', false, false);
$results['feedback'] = trim($feedbackct->get_display_castext()); $results['feedback'] = html_writer::tag('div', $feedbackct->get_display_castext(), array('class' => 'PRTFeedback'));
$results['errors'] .= $feedbackct->get_errors(); $results['errors'] .= $feedbackct->get_errors();
$results['answernote'] = implode(' | ', $results['answernote']); $results['answernote'] = implode(' | ', $results['answernote']);
......
...@@ -58,7 +58,7 @@ class stack_potentialresponsetree_test extends UnitTestCase { ...@@ -58,7 +58,7 @@ class stack_potentialresponsetree_test extends UnitTestCase {
$this->assertEqual('', $result['errors']); $this->assertEqual('', $result['errors']);
$this->assertEqual(2, $result['mark']); $this->assertEqual(2, $result['mark']);
$this->assertEqual(0, $result['penalty']); $this->assertEqual(0, $result['penalty']);
$this->assertEqual('Yeah!', $result['feedback']); $this->assertEqual('<div class="PRTFeedback">Yeah!</div>', $result['feedback']);
$this->assertEqual('ATInt_true | 1-0-1', $result['answernote']); $this->assertEqual('ATInt_true | 1-0-1', $result['answernote']);
} }
...@@ -92,7 +92,7 @@ class stack_potentialresponsetree_test extends UnitTestCase { ...@@ -92,7 +92,7 @@ class stack_potentialresponsetree_test extends UnitTestCase {
$this->assertEqual('', $result['errors']); $this->assertEqual('', $result['errors']);
$this->assertEqual(2, $result['mark']); $this->assertEqual(2, $result['mark']);
$this->assertEqual(0, $result['penalty']); $this->assertEqual(0, $result['penalty']);
$this->assertEqual('Ok, you can diff. Do not expand!', $result['feedback']); $this->assertEqual('<div class="PRTFeedback">Ok, you can diff. Do not expand!</div>', $result['feedback']);
$this->assertEqual('ATDiff_true | 1-0-1 | ATFacForm_notfactored. | 1-1-0', $result['answernote']); $this->assertEqual('ATDiff_true | 1-0-1 | ATFacForm_notfactored. | 1-1-0', $result['answernote']);
// Now have another attempt at the same PRT! // Now have another attempt at the same PRT!
...@@ -104,7 +104,7 @@ class stack_potentialresponsetree_test extends UnitTestCase { ...@@ -104,7 +104,7 @@ class stack_potentialresponsetree_test extends UnitTestCase {
$this->assertEqual('', $result['errors']); $this->assertEqual('', $result['errors']);
$this->assertEqual(2, $result['mark']); $this->assertEqual(2, $result['mark']);
$this->assertEqual(0, $result['penalty']); $this->assertEqual(0, $result['penalty']);
$this->assertEqual('Ok, you can diff. Yeah!', $result['feedback']); $this->assertEqual('<div class="PRTFeedback">Ok, you can diff. Yeah!</div>', $result['feedback']);
$this->assertEqual('ATDiff_true | 1-0-1 | ATFacForm_true | 1-1-1', $result['answernote']); $this->assertEqual('ATDiff_true | 1-0-1 | ATFacForm_true | 1-1-1', $result['answernote']);
} }
...@@ -151,7 +151,7 @@ class stack_potentialresponsetree_test extends UnitTestCase { ...@@ -151,7 +151,7 @@ class stack_potentialresponsetree_test extends UnitTestCase {
$this->assertEqual('', $result['errors']); $this->assertEqual('', $result['errors']);
$this->assertEqual(1, $result['mark']); $this->assertEqual(1, $result['mark']);
$this->assertEqual(0, $result['penalty']); $this->assertEqual(0, $result['penalty']);
$this->assertEqual('Test 1 true. Test 2 false.', $result['feedback']); $this->assertEqual('<div class="PRTFeedback">Test 1 true. Test 2 false.</div>', $result['feedback']);
$this->assertEqual('1-0-1 | ATFacForm_notfactored. | 1-1-0 | [PRT-CIRCULARITY]=0', $result['answernote']); $this->assertEqual('1-0-1 | ATFacForm_notfactored. | 1-1-0 | [PRT-CIRCULARITY]=0', $result['answernote']);
$this->assertEqual(array('sa1', 'ta'), $tree->get_required_variables(array('sa1', 'sa3', 'ta', 'ssa1', 'a1', 't'))); $this->assertEqual(array('sa1', 'ta'), $tree->get_required_variables(array('sa1', 'sa3', 'ta', 'ssa1', 'a1', 't')));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment