Minor - Coding conventions + comments

1.9.x
Yannick Warnier 11 years ago
parent 02d3aa4b23
commit f5578b4c5a
  1. 2
      main/exercice/exercise.class.php
  2. 8
      main/exercice/exercise.lib.php
  3. 37
      main/exercice/fill_blanks.class.php

@ -2480,7 +2480,7 @@ class Exercise
WHERE exe_id = $exeId
AND question_id= ".intval($questionId);
$resfill = Database::query($queryfill);
$str = Database::result($resfill,0,'answer');
$str = Database::result($resfill, 0, 'answer');
$listStudentResults = FillBlanks::getAnswerInfo($str, true);
$choice = $listStudentResults['studentanswer'];

@ -445,7 +445,7 @@ function showQuestion(
list($answer) = explode('::', $answer);
//Correct answer
//Correct answers
$correctAnswerList = $listAnswerInformations['tabwords'];
//Student's answer
@ -455,7 +455,7 @@ function showQuestion(
$studentAnswerList = $arrayStudentAnswer['studentanswer'];
}
// If display the question with answer (in page exercice/admin.php) for teacher preview
// If the question must be shown with the answer (in page exercice/admin.php) for teacher preview
// set the student-answer to the correct answer
if ($debug_mark_answer) {
$studentAnswerList = $correctAnswerList;
@ -473,9 +473,9 @@ function showQuestion(
// replace / with \/ to allow the preg_replace bellow and all the regexp char
$correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
if (isset($studentAnswerList[$i])) {
// student already start this test and this question
// If student already started this test and answered this question,
// fill the blank with his previous answers
// may be "" if student did the question, but not fill the blanks
// may be "" if student viewed the question, but did not fill the blanks
$correctItem = $studentAnswerList[$i];
}
$attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px";

@ -284,7 +284,7 @@ class FillBlanks extends Question
* abstract function which creates the form to create / edit the answers of the question
* @param FormValidator $form
*/
function processAnswersCreation($form)
public function processAnswersCreation($form)
{
global $charset;
@ -294,7 +294,7 @@ class FillBlanks extends Question
$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
// remove the :: eventually written by the user
$answer = str_replace('::','',$answer);
$answer = str_replace('::', '', $answer);
// remove starting and ending space and  
$answer = api_preg_replace("/\xc2\xa0/", " ", $answer);
@ -307,7 +307,8 @@ class FillBlanks extends Question
$blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator);
// remove spaces at the beginning and the end of text in square brackets
$answer = preg_replace_callback("/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/",
$answer = preg_replace_callback(
"/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/",
function ($matches) use ($blankStartSeparator, $blankEndSeparator) {
$matchingResult = $matches[0];
$matchingResult = trim($matchingResult, $blankStartSeparator);
@ -318,12 +319,12 @@ class FillBlanks extends Question
$matchingResult = str_replace('/"/', "", $matchingResult);
return $blankStartSeparator.$matchingResult.$blankEndSeparator;
},
$answer);
$answer
);
// get the blanks weightings
$nb = preg_match_all('/'.$blankStartSeparatorRegexp.'[^'.$blankStartSeparatorRegexp.']*'.$blankEndSeparatorRegexp.'/', $answer, $blanks);
if(isset($_GET['editQuestion']))
{
if (isset($_GET['editQuestion'])) {
$this -> weighting = 0;
}
@ -344,10 +345,10 @@ class FillBlanks extends Question
D : input width for the word [pen]
E : equal @1 if "Allow answers order switches" has been checked, @ otherwise
*/
if($nb > 0) {
if ($nb > 0) {
$answer .= '::';
// weighting
for($i=0 ; $i < $nb ; ++$i) {
for ($i=0; $i < $nb; ++$i) {
// enter the weighting of word $i
$answer .= $form->getSubmitValue('weighting['.$i.']');
// not the last word, add ","
@ -360,7 +361,7 @@ class FillBlanks extends Question
// input width
$answer .= ":";
for ($i=0 ; $i < $nb ; ++$i) {
for ($i=0; $i < $nb; ++$i) {
// enter the width of input for word $i
$answer .= $form->getSubmitValue('sizeofinput['.$i.']');
// not the last word, add ","
@ -399,7 +400,7 @@ class FillBlanks extends Question
* @param null $score
* @return null|string
*/
function return_header($feedback_type = null, $counter = null, $score = null)
public function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'">
@ -455,6 +456,7 @@ class FillBlanks extends Question
$result .= '</select>';
break;
case self::FILL_THE_BLANK_SEVERAL_ANSWER:
//no break
case self::FILL_THE_BLANK_STANDARD:
default:
$result = Display::input('text', "choice[$questionId][]", $correctItem, $attributes);
@ -465,7 +467,7 @@ class FillBlanks extends Question
/**
* Return an array with the differents choice avaliable when the bracket is a menu
* Return an array with the different choices available when the answers between bracket show as a menu
* @param $correctAnswer
* @param $displayForStudent true if we want to shuffle the choices of the menu for students
* @return array
@ -482,7 +484,7 @@ class FillBlanks extends Question
/**
* Return the array indice of the student answer
* Return the array index of the student answer
* @param $correctAnswer the menu Choice1|Choice2|Choice3
* @param $studentAnswer the student answer must be Choice1 or Choice2 or Choice3
* @return int in the exemple 0 1 or 2 depending of the choice of the student
@ -500,7 +502,7 @@ class FillBlanks extends Question
/**
* return the possible answer if bracket is a multiple choice menu
* Return the possible answer if the answer between brackets is a multiple choice menu
* @param $correctAnswer
* @return array
*/
@ -513,8 +515,8 @@ class FillBlanks extends Question
/**
* Return true if student answer is right according to the correctAnswer
* it is not so simple as equality, because of the type of Fill The Blank question
* eg : studentNaswer = 'Un' and correctAnswer = 'Un||1||un'
* it is not as simple as equality, because of the type of Fill The Blank question
* eg : studentAnswer = 'Un' and correctAnswer = 'Un||1||un'
* @param $studentAnswer the [studentanswer] of the info array of the answer field
* @param $correctAnswer the [tabwords] of the info array of the answer field
* @return bool
@ -622,8 +624,9 @@ class FillBlanks extends Question
if ($listAnswerResults['wordsCount'] > 0) {
$listAnswerResults['tabwordsbracket'] = $listWords[0];
// remove [ and ] in string
array_walk($listWords[0],function (&$value, $key, $tabBlankChar)
{
array_walk(
$listWords[0],
function (&$value, $key, $tabBlankChar) {
$trimChars = "";
for ($i=0; $i < count($tabBlankChar); $i++) {
$trimChars .= $tabBlankChar[$i];

Loading…
Cancel
Save