Example #1
0
 private function display_question_information($question)
 {
     global $OUTPUT;
     $opts = $question->options;
     echo $OUTPUT->heading($question->name, 3);
     // Display the question variables.
     echo $OUTPUT->heading(stack_string('questionvariables'), 3);
     echo html_writer::start_tag('div', array('class' => 'questionvariables'));
     echo html_writer::tag('pre', htmlspecialchars($opts->questionvariables));
     echo html_writer::end_tag('div');
     echo $OUTPUT->heading(stack_string('questiontext'), 3);
     echo html_writer::tag('div', html_writer::tag('div', stack_ouput_castext($question->questiontext), array('class' => 'outcome generalfeedback')), array('class' => 'que'));
     echo $OUTPUT->heading(stack_string('generalfeedback'), 3);
     echo html_writer::tag('div', html_writer::tag('div', stack_ouput_castext($question->generalfeedback), array('class' => 'outcome generalfeedback')), array('class' => 'que'));
     echo $OUTPUT->heading(stack_string('questionnote'), 3);
     echo html_writer::tag('div', html_writer::tag('div', stack_ouput_castext($opts->questionnote), array('class' => 'outcome generalfeedback')), array('class' => 'que'));
     echo $OUTPUT->heading(get_string('pluginname', 'quiz_stack'), 3);
 }
function output_cas_text($title, $intro, $castext)
{
    global $OUTPUT;
    echo $OUTPUT->heading($title, 3);
    echo html_writer::tag('p', $intro);
    echo html_writer::tag('pre', s($castext));
    $ct = new stack_cas_text($castext, null, 0, 't');
    echo html_writer::tag('p', format_text(stack_ouput_castext($ct->get_display_castext())));
    echo output_debug(stack_string('errors'), $ct->get_errors());
    echo output_debug(stack_string('debuginfo'), $ct->get_debuginfo());
}
Example #3
0
 /**
  * We need to make sure the inputs are displayed in the order in which they
  * occur in the question text. This is not necessarily the order in which they
  * are listed in the array $this->inputs.
  */
 public function format_correct_response($qa)
 {
     $feedback = '';
     $inputs = stack_utils::extract_placeholders($this->questiontextinstantiated, 'input');
     foreach ($inputs as $name) {
         $input = $this->inputs[$name];
         $feedback .= html_writer::tag('p', $input->get_teacher_answer_display($this->session->get_value_key($name), $this->session->get_display_key($name)));
     }
     return stack_ouput_castext($feedback);
 }
 /**
  * Update maths delimiters in one field of an object, outputting the before
  * and after HTML for review.
  * @param stdClass $question an object.
  * @param field $field the name of one of its fields.
  * @return boolean whether any change was made to the field.
  */
 public function fix_question_field($question, $field)
 {
     $newtext = stack_maths::replace_dollars($question->{$field});
     if ($newtext == $question->{$field}) {
         return false;
     }
     $markedup = stack_maths::replace_dollars($question->{$field}, '<ins>', '</ins>');
     echo html_writer::tag('p', stack_string('replacedollarsin', $field));
     echo html_writer::tag('pre', str_replace($this->search, $this->replace, s($markedup)), array('class' => 'questiontext'));
     echo html_writer::tag('div', stack_ouput_castext($newtext), array('class' => 'questiontext'));
     $question->{$field} = $newtext;
     return true;
 }
        echo $OUTPUT->single_button(new moodle_url('/question/type/stack/questiontestedit.php', $urlparams + array('testcase' => $key)), stack_string('editthistestcase', 'qtype_stack'), 'get');
        echo $OUTPUT->single_button(new moodle_url('/question/type/stack/questiontestdelete.php', $urlparams + array('testcase' => $key)), stack_string('deletethistestcase', 'qtype_stack'), 'get');
        echo html_writer::end_tag('div');
    }
}
// Display the question.
$renderer = $PAGE->get_renderer('qtype_stack');
echo $OUTPUT->heading(stack_string('questionpreview'), 3);
echo html_writer::tag('p', html_writer::link($questionbanklink, stack_string('seethisquestioninthequestionbank')));
if ($canedit) {
    echo html_writer::tag('p', html_writer::link($exportquestionlink, stack_string('exportthisquestion')) . $OUTPUT->help_icon('exportthisquestion', 'qtype_stack'));
}
echo $quba->render_question($slot, $options);
// Display the question note.
echo $OUTPUT->heading(stack_string('questionnote'), 3);
echo html_writer::tag('p', stack_ouput_castext($question->get_question_summary()), array('class' => 'questionnote'));
// Display the question variables.
echo $OUTPUT->heading(stack_string('questionvariablevalues'), 3);
echo html_writer::start_tag('div', array('class' => 'questionvariables'));
$displayqvs = '';
foreach ($question->get_question_var_values() as $key => $value) {
    $displayqvs .= s($key) . ' : ' . s($value) . ";\n";
}
echo html_writer::tag('pre', $displayqvs);
echo html_writer::end_tag('div');
// Display the general feedback, aka "Worked solution".
$qa = new question_attempt($question, 0);
echo $OUTPUT->heading(stack_string('generalfeedback'), 3);
echo html_writer::tag('div', html_writer::tag('div', $renderer->general_feedback($qa), array('class' => 'outcome generalfeedback')), array('class' => 'que'));
// Add a link to the cas chat to facilitate editing the general feedback.
if ($question->options->get_option('simplify')) {
Example #6
0
        $displaytext = $ct->get_display_castext();
        $errs = $ct->get_errors();
        $debuginfo = $ct->get_debuginfo();
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
echo html_writer::tag('p', stack_string('chatintro'));
// If we are editing the General Feedback from a question it is very helpful to see the question text.
if ($questionid) {
    echo $OUTPUT->heading(stack_string('questiontext'), 3);
    echo html_writer::tag('pre', $question->questiontext, array('class' => 'questiontext'));
}
if (!$varerrs) {
    if ($string) {
        echo $OUTPUT->box(stack_ouput_castext($displaytext));
    }
}
if ($simp) {
    $simp = stack_string('autosimplify') . ' ' . html_writer::empty_tag('input', array('type' => 'checkbox', 'checked' => $simp, 'name' => 'simp'));
} else {
    $simp = stack_string('autosimplify') . ' ' . html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'simp'));
}
$varlen = substr_count($vars, "\n") + 3;
$stringlen = max(substr_count($string, "\n") + 3, 8);
echo html_writer::tag('form', html_writer::tag('h2', stack_string('questionvariables')) . html_writer::tag('p', $varerrs) . html_writer::tag('p', html_writer::tag('textarea', $vars, array('cols' => 100, 'rows' => $varlen, 'name' => 'vars'))) . html_writer::tag('p', $simp) . html_writer::tag('h2', stack_string('castext')) . html_writer::tag('p', $errs) . html_writer::tag('p', html_writer::tag('textarea', $string, array('cols' => 100, 'rows' => $stringlen, 'name' => 'cas'))) . html_writer::tag('p', html_writer::empty_tag('input', array('type' => 'submit', 'value' => stack_string('chat')))), array('action' => $PAGE->url, 'method' => 'post'));
if ($string) {
    // Display the question variables.
    echo $OUTPUT->heading(stack_string('questionvariablevalues'), 3);
    echo html_writer::start_tag('div', array('class' => 'questionvariables'));
    $displayqvs = '';
 if ($result->passed()) {
     $outcome = html_writer::tag('span', stack_string('testsuitepass'), array('class' => 'pass'));
 } else {
     $outcome = html_writer::tag('span', stack_string('testsuitefail'), array('class' => 'fail'));
 }
 echo $OUTPUT->heading(stack_string('testcasexresult', array('no' => $key, 'result' => $outcome)), 3);
 // Display the information about the inputs.
 $inputstable = new html_table();
 $inputstable->head = array(stack_string('inputname'), stack_string('inputexpression'), stack_string('inputentered'), stack_string('inputdisplayed'), stack_string('inputstatus'), stack_string('errors'));
 $inputstable->attributes['class'] = 'generaltable stacktestsuite';
 foreach ($result->get_input_states() as $inputname => $inputstate) {
     $inputval = s($inputstate->input);
     if (false === $inputstate->input) {
         $inputval = '';
     }
     $inputstable->data[] = array(s($inputname), s($inputstate->rawinput), $inputval, stack_ouput_castext($inputstate->display), stack_string('inputstatusname' . $inputstate->status), $inputstate->errors);
 }
 echo html_writer::table($inputstable);
 // Display the information about the PRTs.
 $prtstable = new html_table();
 $prtstable->head = array(stack_string('prtname'), stack_string('score'), stack_string('expectedscore'), stack_string('penalty'), stack_string('expectedpenalty'), stack_string('answernote'), stack_string('expectedanswernote'), get_string('feedback', 'question'), stack_string('testsuitecolpassed'));
 $prtstable->attributes['class'] = 'generaltable stacktestsuite';
 foreach ($result->get_prt_states() as $prtname => $state) {
     if ($state->testoutcome) {
         $prtstable->rowclasses[] = 'pass';
         $passedcol = stack_string('testsuitepass');
     } else {
         $prtstable->rowclasses[] = 'fail';
         $passedcol = stack_string('testsuitefail') . $state->reason;
     }
     // Sort out excessive decimal places from the DB.