type = UNIQUE_ANSWER; } /** * function which redifines Question::createAnswersForm * @param the formvalidator instance * @param the answers number to display */ function createAnswersForm ($form) { // getting the exercise list $obj_ex =$_SESSION['objExercise']; $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125'); //this line define how many question by default appear when creating a choice question $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 2; $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); /* Types of Feedback $feedback_option[0]=get_lang('Feedback'); $feedback_option[1]=get_lang('DirectFeedback'); $feedback_option[2]=get_lang('NoFeedback'); */ $feedback_title=''; $comment_title=''; if ($obj_ex->selectFeedbackType()==0) { $comment_title = '
'.get_lang('Number').' | '.get_lang('True').' | '.get_lang('Answer').' | '.$comment_title.' '.$feedback_title.''.get_lang('Weighting').' |
---|---|---|---|
{error} {element} | ');
$answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number->freeze();
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
if ($obj_ex->selectFeedbackType()==0) // feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
elseif ($obj_ex->selectFeedbackType()==1) // direct feedback
{
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
//Adding extra feedback fields
$group = array();
$group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' );
$group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id);
$group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question);
$group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px'));
$form -> addGroup($group, 'scenario', 'scenario');
$renderer->setGroupElementTemplate('
'; //$list_destination = $form -> getSubmitValue('destination'.$i); //$destination_str = $form -> getSubmitValue('destination'.$i); $try = $scenario['try'.$i]; $lp= $scenario['lp'.$i]; $destination = $scenario['destination'.$i]; $url = trim($scenario['url'.$i]); /* How we are going to parse the destination value here we parse the destination value which is a string 1@@3@@2;4;4;@@http://www.dokeos.com where: try_again@@lp_id@@selected_questions@@url try_again = is 1 || 0 lp_id = id of a learning path (0 if dont select) selected_questions= ids of questions url= an url */ /* $destination_str=''; foreach ($list_destination as $destination_id) { $destination_str.=$destination_id.';'; }*/ $goodAnswer= ($correct == $i) ? true : false; if($goodAnswer) { $nbrGoodAnswers++; $weighting = abs($weighting); if($weighting > 0) { $questionWeighting += $weighting; } } if (empty($try)) $try=0; if (empty($lp)) { $lp=0; } if (empty($destination)) { $destination=0; } if ($url=='') { $url=0; } //1@@1;2;@@2;4;4;@@http://www.dokeos.com $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url; $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); } // saves the answers into the data base $objAnswer -> save(); // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); } } endif; ?>