|
|
|
@ -1,21 +1,8 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/** |
|
|
|
|
|
|
|
* File containing the FillBlanks class. |
|
|
|
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
|
|
|
* @author Eric Marguin |
|
|
|
|
|
|
|
* @author Julio Montoya Armas switchable fill in blank option added |
|
|
|
|
|
|
|
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Code |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
|
* This class allows to instantiate an object of type MULTIPLE_ANSWER |
|
|
|
* Class FillBlanks |
|
|
|
* (MULTIPLE CHOICE, MULTIPLE ANSWER), |
|
|
|
|
|
|
|
* extending the class question |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @author Eric Marguin |
|
|
|
* @author Eric Marguin |
|
|
|
* @author Julio Montoya multiple fill in blank option added |
|
|
|
* @author Julio Montoya multiple fill in blank option added |
|
|
|
@ -37,7 +24,7 @@ class FillBlanks extends Question |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* function which redifines Question::createAnswersForm |
|
|
|
* function which redefines Question::createAnswersForm |
|
|
|
* @param the formvalidator instance |
|
|
|
* @param the formvalidator instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function createAnswersForm($form) |
|
|
|
function createAnswersForm($form) |
|
|
|
@ -164,17 +151,17 @@ class FillBlanks extends Question |
|
|
|
$answer = $form->getSubmitValue('answer'); |
|
|
|
$answer = $form->getSubmitValue('answer'); |
|
|
|
|
|
|
|
|
|
|
|
//remove the :: eventually written by the user |
|
|
|
//remove the :: eventually written by the user |
|
|
|
$answer = str_replace('::','',$answer); |
|
|
|
$answer = str_replace('::', '', $answer); |
|
|
|
|
|
|
|
|
|
|
|
// get the blanks weightings |
|
|
|
// get the blanks weightings |
|
|
|
$nb = preg_match_all('/\[[^\]]*\]/', $answer, $blanks); |
|
|
|
$nb = preg_match_all('/\[[^\]]*\]/', $answer, $blanks); |
|
|
|
if (isset($_GET['editQuestion'])) { |
|
|
|
if (isset($_GET['editQuestion'])) { |
|
|
|
$this -> weighting = 0; |
|
|
|
$this ->weighting = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($nb>0) { |
|
|
|
if ($nb > 0) { |
|
|
|
$answer .= '::'; |
|
|
|
$answer .= '::'; |
|
|
|
for($i=0 ; $i<$nb ; ++$i) { |
|
|
|
for ($i=0 ; $i < $nb; ++$i) { |
|
|
|
$blankItem = $blanks[0][$i]; |
|
|
|
$blankItem = $blanks[0][$i]; |
|
|
|
$replace = array("[", "]"); |
|
|
|
$replace = array("[", "]"); |
|
|
|
$newBlankItem = str_replace($replace, "", $blankItem); |
|
|
|
$newBlankItem = str_replace($replace, "", $blankItem); |
|
|
|
@ -183,12 +170,11 @@ class FillBlanks extends Question |
|
|
|
$answer .= $form->getSubmitValue('weighting['.$i.']').','; |
|
|
|
$answer .= $form->getSubmitValue('weighting['.$i.']').','; |
|
|
|
$this -> weighting += $form->getSubmitValue('weighting['.$i.']'); |
|
|
|
$this -> weighting += $form->getSubmitValue('weighting['.$i.']'); |
|
|
|
} |
|
|
|
} |
|
|
|
$answer = api_substr($answer,0,-1); |
|
|
|
$answer = api_substr($answer, 0, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$is_multiple = $form->getSubmitValue('multiple_answer'); |
|
|
|
$is_multiple = $form->getSubmitValue('multiple_answer'); |
|
|
|
|
|
|
|
$answer.= '@'.$is_multiple; |
|
|
|
$answer.='@'.$is_multiple; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->save(); |
|
|
|
$this->save(); |
|
|
|
$objAnswer = new answer($this->id); |
|
|
|
$objAnswer = new answer($this->id); |
|
|
|
@ -196,6 +182,12 @@ class FillBlanks extends Question |
|
|
|
$objAnswer->save(); |
|
|
|
$objAnswer->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param null $feedback_type |
|
|
|
|
|
|
|
* @param null $counter |
|
|
|
|
|
|
|
* @param null $score |
|
|
|
|
|
|
|
* @return null|string |
|
|
|
|
|
|
|
*/ |
|
|
|
function return_header($feedback_type = null, $counter = null, $score = null) |
|
|
|
function return_header($feedback_type = null, $counter = null, $score = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$header = parent::return_header($feedback_type, $counter, $score); |
|
|
|
$header = parent::return_header($feedback_type, $counter, $score); |
|
|
|
|