adding equation display in calculated question text(MDL-10070) and answers text length

greater.
This commit is contained in:
pichetp
2007-06-09 22:09:54 +00:00
parent fd6b864f7c
commit bfdc0bcedb
@@ -40,8 +40,8 @@ class question_edit_calculated_form extends question_edit_form {
$repeated = array();
$repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerhdr', 'qtype_calculated', '{no}'));
$repeated[] =& $mform->createElement('text', 'answers', get_string('correctanswerformula', 'quiz'));
$repeatedoptions['answers']['type'] = PARAM_NOTAGS;
$repeated[] =& $mform->createElement('text', 'answers', get_string('correctanswerformula', 'quiz').'=', array('size' => 50));
$repeatedoptions['answers']['type'] = PARAM_NOTAGS;
$creategrades = get_grade_options();
$gradeoptions = $creategrades->gradeoptions;
@@ -158,6 +158,26 @@ class question_edit_calculated_form extends question_edit_form {
function validation($data){
$errors = array();
//verifying for errors in {=...} in question text;
$qtext = "";
$qtextremaining = $data['questiontext'] ;
$possibledatasets = $this->qtypeobj->find_dataset_names($data['questiontext']);
foreach ($possibledatasets as $name => $value) {
$qtextremaining = str_replace('{'.$name.'}', '1', $qtextremaining);
}
// echo "numericalquestion qtextremaining <pre>";print_r($possibledatasets);
while (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
$qtextsplits = explode($regs1[0], $qtextremaining, 2);
$qtext =$qtext.$qtextsplits[0];
$qtextremaining = $qtextsplits[1];
if (!empty($regs1[1]) && $formulaerrors = qtype_calculated_find_formula_errors($regs1[1])) {
if(!isset($errors['questiontext'])){
$errors['questiontext'] = $formulaerrors.':'.$regs1[1] ;
}else {
$errors['questiontext'] .= '<br/>'.$formulaerrors.':'.$regs1[1];
}
}
}
$answers = $data['answers'];
$answercount = 0;
$maxgrade = false;