/**
  * Validate a CAS string field to make sure that: 1. it fits in the DB, and
  * 2. that it is syntactically valid.
  * @param array $errors the errors array that validation is assembling.
  * @param string $value the submitted value validate.
  * @param string $fieldname the name of the field add any errors to.
  * @return array updated $errors array.
  */
 protected function validate_cas_keyval($errors, $value, $fieldname)
 {
     if ('' == trim($value)) {
         return $errors;
     }
     $keyval = new stack_cas_keyval($value, $this->options, $this->seed, 't');
     if (!$keyval->get_valid()) {
         $errors[$fieldname][] = $keyval->get_errors();
     }
     return $errors;
 }
Example #2
0
} else {
    $simp = false;
}
// Initially simplification should be on.
if (!$vars and !$string) {
    $simp = true;
}
if ($string) {
    $options = new stack_options();
    $options->set_site_defaults();
    $options->set_option('simplify', $simp);
    $session = new stack_cas_session(null, $options);
    if ($vars) {
        $keyvals = new stack_cas_keyval($vars, $options, 0, 't');
        $session = $keyvals->get_session();
        $varerrs = $keyvals->get_errors();
    }
    if (!$varerrs) {
        $ct = new stack_cas_text($string, $session, 0, 't');
        $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'));