Fix exercise question label + format code + fix behat test

pull/3064/head
Julio 6 years ago
parent 378e17017c
commit 6183a2e909
  1. 1
      public/main/exercise/Annotation.php
  2. 3
      public/main/exercise/Draggable.php
  3. 3
      public/main/exercise/MatchingDraggable.php
  4. 21
      public/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  5. 5
      public/main/exercise/ReadingComprehension.php
  6. 3
      public/main/exercise/UniqueAnswerImage.php
  7. 3
      public/main/exercise/calculated_answer.class.php
  8. 2
      public/main/exercise/exercise.class.php
  9. 2
      public/main/exercise/exercise_admin.php
  10. 135
      public/main/exercise/fill_blanks.class.php
  11. 5
      public/main/exercise/freeanswer.class.php
  12. 3
      public/main/exercise/global_multiple_answer.class.php
  13. 5
      public/main/exercise/hotspot.class.php
  14. 2
      public/main/exercise/multiple_answer.class.php
  15. 3
      public/main/exercise/multiple_answer_combination.class.php
  16. 3
      public/main/exercise/multiple_answer_combination_true_false.class.php
  17. 3
      public/main/exercise/multiple_answer_true_false.class.php
  18. 5
      public/main/exercise/oral_expression.class.php
  19. 38
      public/main/exercise/question.class.php
  20. 3
      public/main/exercise/question_admin.inc.php
  21. 22
      public/main/exercise/question_list_admin.inc.php
  22. 2
      public/main/exercise/unique_answer.class.php
  23. 3
      public/main/exercise/unique_answer_no_option.class.php
  24. 4
      tests/behat/features/toolExercise.feature

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -9,7 +10,7 @@
class Draggable extends Question class Draggable extends Question
{ {
public $typePicture = 'ordering.png'; public $typePicture = 'ordering.png';
public $explanationLangVar = 'Draggable'; public $explanationLangVar = 'Sequence ordering';
/** /**
* Class constructor. * Class constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -9,7 +10,7 @@
class MatchingDraggable extends Question class MatchingDraggable extends Question
{ {
public $typePicture = 'matchingdrag.png'; public $typePicture = 'matchingdrag.png';
public $explanationLangVar = 'MatchingDraggable'; public $explanationLangVar = 'Match by dragging';
/** /**
* Class constructor. * Class constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -7,8 +8,6 @@ use ChamiloSession as Session;
* Class MultipleAnswerTrueFalseDegreeCertainty * Class MultipleAnswerTrueFalseDegreeCertainty
* This class allows to instantiate an object of type MULTIPLE_ANSWER * This class allows to instantiate an object of type MULTIPLE_ANSWER
* (MULTIPLE CHOICE, MULTIPLE ANSWER), extending the class question. * (MULTIPLE CHOICE, MULTIPLE ANSWER), extending the class question.
*
* @package chamilo.exercise
*/ */
class MultipleAnswerTrueFalseDegreeCertainty extends Question class MultipleAnswerTrueFalseDegreeCertainty extends Question
{ {
@ -19,7 +18,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
const LEVEL_DARKRED = 5; const LEVEL_DARKRED = 5;
public $typePicture = 'mccert.png'; public $typePicture = 'mccert.png';
public $explanationLangVar = 'MultipleAnswerTrueFalseDegreeCertainty'; public $explanationLangVar = 'Multiple answer true/false/degree of certainty';
public $optionsTitle; public $optionsTitle;
public $options; public $options;
@ -831,17 +830,17 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$colWidth = $widthTable / 5; $colWidth = $widthTable / 5;
$html .= '<tr> $html .= '<tr>
<td class="firstLine borderRight '.$classGlobalChart.'" <td class="firstLine borderRight '.$classGlobalChart.'"
colspan="2" colspan="2"
style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'. style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'.
sprintf(get_lang('Incorrect answers: %s'), $nbResponsesInc).' sprintf(get_lang('Incorrect answers: %s'), $nbResponsesInc).'
</td> </td>
<td class="firstLine borderRight '.$classGlobalChart.'" <td class="firstLine borderRight '.$classGlobalChart.'"
style="width:'.$colWidth.'px; line-height: 15px; font-size :'.$textSize.'%;">'. style="width:'.$colWidth.'px; line-height: 15px; font-size :'.$textSize.'%;">'.
sprintf(get_lang('Ignorance: %s'), $nbResponsesIng).' sprintf(get_lang('Ignorance: %s'), $nbResponsesIng).'
</td> </td>
<td class="firstLine '.$classGlobalChart.'" <td class="firstLine '.$classGlobalChart.'"
colspan="2" colspan="2"
style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'. style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'.
sprintf(get_lang('Correct answers: %s'), $nbResponsesCor).' sprintf(get_lang('Correct answers: %s'), $nbResponsesCor).'
</td> </td>
@ -1147,8 +1146,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$tblAnswerOption = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); $tblAnswerOption = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$optionId = (int) $optionId; $optionId = (int) $optionId;
$sql = "SELECT position $sql = "SELECT position
FROM $tblAnswerOption FROM $tblAnswerOption
WHERE c_id = $courseId AND id = $optionId"; WHERE c_id = $courseId AND id = $optionId";
$res = Database::query($sql); $res = Database::query($sql);
@ -1232,7 +1231,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$tableTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $tableTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$exeId = (int) $exeId; $exeId = (int) $exeId;
$sql = "SELECT exe_exo_id $sql = "SELECT exe_exo_id
FROM $tableTrackEExercise FROM $tableTrackEExercise
WHERE exe_id=".$exeId; WHERE exe_id=".$exeId;
$res = Database::query($sql); $res = Database::query($sql);

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -6,13 +7,11 @@
* *
* This class allows to instantiate an object of type READING_COMPREHENSION * This class allows to instantiate an object of type READING_COMPREHENSION
* extending the class question * extending the class question
*
* @package chamilo.exercise
*/ */
class ReadingComprehension extends UniqueAnswer class ReadingComprehension extends UniqueAnswer
{ {
public $typePicture = 'reading-comprehension.png'; public $typePicture = 'reading-comprehension.png';
public $explanationLangVar = 'ReadingComprehension'; public $explanationLangVar = 'Reading comprehension';
/** /**
* Defines the different speeds of scrolling for the reading window, * Defines the different speeds of scrolling for the reading window,

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -11,7 +12,7 @@ use ChamiloSession as Session;
class UniqueAnswerImage extends UniqueAnswer class UniqueAnswerImage extends UniqueAnswer
{ {
public $typePicture = 'uaimg.png'; public $typePicture = 'uaimg.png';
public $explanationLangVar = 'UniqueAnswerImage'; public $explanationLangVar = 'Unique answer image';
/** /**
* UniqueAnswerImage constructor. * UniqueAnswerImage constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Webit\Util\EvalMath\EvalMath; use Webit\Util\EvalMath\EvalMath;
@ -12,7 +13,7 @@ use Webit\Util\EvalMath\EvalMath;
class CalculatedAnswer extends Question class CalculatedAnswer extends Question
{ {
public $typePicture = 'calculated_answer.png'; public $typePicture = 'calculated_answer.png';
public $explanationLangVar = 'CalculatedAnswer'; public $explanationLangVar = 'Calculated question';
/** /**
* Constructor. * Constructor.

@ -8435,7 +8435,7 @@ class Exercise
'legacy_main', 'legacy_main',
false, false,
'_self', '_self',
['class' => 'btn btn-secondary', 'icon' => 'fa fa-pen'] ['class' => 'btn btn-secondary', 'icon' => 'fa fa-pen', 'title' => get_lang('Edit')]
); );
$myRowAction->setRouteParameters( $myRowAction->setRouteParameters(

@ -200,7 +200,7 @@ if ($form->validate()) {
Display::return_icon('back.png', get_lang("Back to").' '.get_lang('Learning paths'), '', ICON_SIZE_MEDIUM)."</a>"; Display::return_icon('back.png', get_lang("Back to").' '.get_lang('Learning paths'), '', ICON_SIZE_MEDIUM)."</a>";
} else { } else {
echo '<a href="exercise.php?'.api_get_cidreq().'">'. echo '<a href="exercise.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('Back toTestsList'), '', ICON_SIZE_MEDIUM). Display::return_icon('back.png', get_lang('Back to test list'), '', ICON_SIZE_MEDIUM).
'</a>'; '</a>';
} }
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -14,7 +15,7 @@ class FillBlanks extends Question
public const FILL_THE_BLANK_SEVERAL_ANSWER = 2; public const FILL_THE_BLANK_SEVERAL_ANSWER = 2;
public $typePicture = 'fill_in_blanks.png'; public $typePicture = 'fill_in_blanks.png';
public $explanationLangVar = 'FillBlanks'; public $explanationLangVar = 'Fill blanks or form';
/** /**
* Constructor. * Constructor.
@ -63,40 +64,40 @@ class FillBlanks extends Question
} }
} }
echo '<script> echo '<script>
var firstTime = true; var firstTime = true;
var originalOrder = new Array(); var originalOrder = new Array();
var blankSeparatorStart = "'.$blankSeparatorStart.'"; var blankSeparatorStart = "'.$blankSeparatorStart.'";
var blankSeparatorEnd = "'.$blankSeparatorEnd.'"; var blankSeparatorEnd = "'.$blankSeparatorEnd.'";
var blankSeparatorStartRegexp = getBlankSeparatorRegexp(blankSeparatorStart); var blankSeparatorStartRegexp = getBlankSeparatorRegexp(blankSeparatorStart);
var blankSeparatorEndRegexp = getBlankSeparatorRegexp(blankSeparatorEnd); var blankSeparatorEndRegexp = getBlankSeparatorRegexp(blankSeparatorEnd);
var blanksRegexp = "/"+blankSeparatorStartRegexp+"[^"+blankSeparatorStartRegexp+"]*"+blankSeparatorEndRegexp+"/g"; var blanksRegexp = "/"+blankSeparatorStartRegexp+"[^"+blankSeparatorStartRegexp+"]*"+blankSeparatorEndRegexp+"/g";
CKEDITOR.on("instanceCreated", function(e) { CKEDITOR.on("instanceCreated", function(e) {
if (e.editor.name === "answer") { if (e.editor.name === "answer") {
//e.editor.on("change", updateBlanks); //e.editor.on("change", updateBlanks);
e.editor.on("change", function(){ e.editor.on("change", function(){
updateBlanks(); updateBlanks();
}); });
} }
}); });
function updateBlanks() function updateBlanks()
{ {
var answer; var answer;
if (firstTime) { if (firstTime) {
var field = document.getElementById("answer"); var field = document.getElementById("answer");
answer = field.value; answer = field.value;
} else { } else {
answer = CKEDITOR.instances["answer"].getData(); answer = CKEDITOR.instances["answer"].getData();
} }
// disable the save button, if not blanks have been created // disable the save button, if not blanks have been created
$("button").attr("disabled", "disabled"); $("button").attr("disabled", "disabled");
$("#defineoneblank").show(); $("#defineoneblank").show();
var blanks = answer.match(eval(blanksRegexp)); var blanks = answer.match(eval(blanksRegexp));
var fields = "<div class=\"form-group \">"; var fields = "<div class=\"form-group \">";
fields += "<label class=\"col-sm-2 control-label\"></label>"; fields += "<label class=\"col-sm-2 control-label\"></label>";
fields += "<div class=\"col-sm-8\">"; fields += "<div class=\"col-sm-8\">";
fields += "<table class=\"data_table\">"; fields += "<table class=\"data_table\">";
@ -107,34 +108,34 @@ class FillBlanks extends Question
if (blanks != null) { if (blanks != null) {
for (var i=0; i < blanks.length; i++) { for (var i=0; i < blanks.length; i++) {
// remove forbidden characters that causes bugs // remove forbidden characters that causes bugs
blanks[i] = removeForbiddenChars(blanks[i]); blanks[i] = removeForbiddenChars(blanks[i]);
// trim blanks between brackets // trim blanks between brackets
blanks[i] = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd); blanks[i] = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd);
// if the word is empty [] // if the word is empty []
if (blanks[i] == blankSeparatorStartRegexp+blankSeparatorEndRegexp) { if (blanks[i] == blankSeparatorStartRegexp+blankSeparatorEndRegexp) {
break; break;
} }
// get input size // get input size
var inputSize = 100; var inputSize = 100;
var textValue = blanks[i].substr(1, blanks[i].length - 2); var textValue = blanks[i].substr(1, blanks[i].length - 2);
var btoaValue = textValue.hashCode(); var btoaValue = textValue.hashCode();
if (firstTime == false) { if (firstTime == false) {
var element = document.getElementById("samplesize["+i+"]"); var element = document.getElementById("samplesize["+i+"]");
if (element) { if (element) {
inputSize = document.getElementById("sizeofinput["+i+"]").value; inputSize = document.getElementById("sizeofinput["+i+"]").value;
} }
} }
if (document.getElementById("weighting["+i+"]")) { if (document.getElementById("weighting["+i+"]")) {
var value = document.getElementById("weighting["+i+"]").value; var value = document.getElementById("weighting["+i+"]").value;
} else { } else {
var value = "1"; var value = "1";
} }
var blanksWithColor = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd, 1); var blanksWithColor = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd, 1);
fields += "<tr>"; fields += "<tr>";
fields += "<td>"+blanksWithColor+"</td>"; fields += "<td>"+blanksWithColor+"</td>";
fields += "<td><input class=\"form-control\" style=\"width:60px\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td>"; fields += "<td><input class=\"form-control\" style=\"width:60px\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td>";
@ -145,31 +146,31 @@ class FillBlanks extends Question
fields += "<input id=\"sizeofinput["+i+"]\" type=\"hidden\" value=\""+inputSize+"\" name=\"sizeofinput["+i+"]\" />"; fields += "<input id=\"sizeofinput["+i+"]\" type=\"hidden\" value=\""+inputSize+"\" name=\"sizeofinput["+i+"]\" />";
fields += "</td>"; fields += "</td>";
fields += "</tr>"; fields += "</tr>";
// enable the save button // enable the save button
$("button").removeAttr("disabled"); $("button").removeAttr("disabled");
$("#defineoneblank").hide(); $("#defineoneblank").hide();
} }
} }
document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>"; document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
$(originalOrder).each(function(i, data) { $(originalOrder).each(function(i, data) {
if (firstTime == false) { if (firstTime == false) {
value = data.value; value = data.value;
var d = $("input.sample[data-btoa=\'"+value+"\']"); var d = $("input.sample[data-btoa=\'"+value+"\']");
var id = d.attr("id"); var id = d.attr("id");
if (id) { if (id) {
var sizeInputId = id.replace("samplesize", "sizeofinput"); var sizeInputId = id.replace("samplesize", "sizeofinput");
var sizeInputId = sizeInputId.replace("[", "\\\["); var sizeInputId = sizeInputId.replace("[", "\\\[");
var sizeInputId = sizeInputId.replace("]", "\\\]"); var sizeInputId = sizeInputId.replace("]", "\\\]");
$("#"+sizeInputId).val(data.width); $("#"+sizeInputId).val(data.width);
d.outerWidth(data.width+"px"); d.outerWidth(data.width+"px");
} }
} }
}); });
updateOrder(blanks); updateOrder(blanks);
if (firstTime) { if (firstTime) {
firstTime = false; firstTime = false;
@ -177,7 +178,7 @@ class FillBlanks extends Question
} }
} }
window.onload = updateBlanks; window.onload = updateBlanks;
String.prototype.hashCode = function() { String.prototype.hashCode = function() {
var hash = 0, i, chr, len; var hash = 0, i, chr, len;
if (this.length === 0) return hash; if (this.length === 0) return hash;
@ -188,35 +189,35 @@ class FillBlanks extends Question
} }
return hash; return hash;
}; };
function updateOrder(blanks) function updateOrder(blanks)
{ {
originalOrder = new Array(); originalOrder = new Array();
if (blanks != null) { if (blanks != null) {
for (var i=0; i < blanks.length; i++) { for (var i=0; i < blanks.length; i++) {
// remove forbidden characters that causes bugs // remove forbidden characters that causes bugs
blanks[i] = removeForbiddenChars(blanks[i]); blanks[i] = removeForbiddenChars(blanks[i]);
// trim blanks between brackets // trim blanks between brackets
blanks[i] = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd); blanks[i] = trimBlanksBetweenSeparator(blanks[i], blankSeparatorStart, blankSeparatorEnd);
// if the word is empty [] // if the word is empty []
if (blanks[i] == blankSeparatorStartRegexp+blankSeparatorEndRegexp) { if (blanks[i] == blankSeparatorStartRegexp+blankSeparatorEndRegexp) {
break; break;
} }
var textValue = blanks[i].substr(1, blanks[i].length - 2); var textValue = blanks[i].substr(1, blanks[i].length - 2);
var btoaValue = textValue.hashCode(); var btoaValue = textValue.hashCode();
if (firstTime == false) { if (firstTime == false) {
var element = document.getElementById("samplesize["+i+"]"); var element = document.getElementById("samplesize["+i+"]");
if (element) { if (element) {
inputSize = document.getElementById("sizeofinput["+i+"]").value; inputSize = document.getElementById("sizeofinput["+i+"]").value;
originalOrder.push({ "width" : inputSize, "value": btoaValue }); originalOrder.push({ "width" : inputSize, "value": btoaValue });
} }
} }
} }
} }
} }
function changeInputSize(coef, inIdNum) function changeInputSize(coef, inIdNum)
{ {
if (firstTime) { if (firstTime) {
@ -225,7 +226,7 @@ class FillBlanks extends Question
} else { } else {
answer = CKEDITOR.instances["answer"].getData(); answer = CKEDITOR.instances["answer"].getData();
} }
var blanks = answer.match(eval(blanksRegexp)); var blanks = answer.match(eval(blanksRegexp));
var currentWidth = $("#samplesize\\\["+inIdNum+"\\\]").width(); var currentWidth = $("#samplesize\\\["+inIdNum+"\\\]").width();
var newWidth = currentWidth + coef * 20; var newWidth = currentWidth + coef * 20;
@ -233,7 +234,7 @@ class FillBlanks extends Question
newWidth = Math.min(newWidth, 600); newWidth = Math.min(newWidth, 600);
$("#samplesize\\\["+inIdNum+"\\\]").outerWidth(newWidth); $("#samplesize\\\["+inIdNum+"\\\]").outerWidth(newWidth);
$("#sizeofinput\\\["+inIdNum+"\\\]").attr("value", newWidth); $("#sizeofinput\\\["+inIdNum+"\\\]").attr("value", newWidth);
updateOrder(blanks); updateOrder(blanks);
} }
@ -247,7 +248,7 @@ class FillBlanks extends Question
outTxt = outTxt.replace(/&nbsp;/g, " "); outTxt = outTxt.replace(/&nbsp;/g, " ");
outTxt = outTxt.replace(/^ +/, ""); outTxt = outTxt.replace(/^ +/, "");
outTxt = outTxt.replace(/ +$/, ""); outTxt = outTxt.replace(/ +$/, "");
return outTxt; return outTxt;
} }
@ -298,11 +299,11 @@ class FillBlanks extends Question
result = result.replace(inSeparatorStart, ""); result = result.replace(inSeparatorStart, "");
result = result.replace(inSeparatorEnd, ""); result = result.replace(inSeparatorEnd, "");
result = result.trim(); result = result.trim();
if (addColor == 1) { if (addColor == 1) {
var resultParts = result.split("|"); var resultParts = result.split("|");
var partsToString = ""; var partsToString = "";
resultParts.forEach(function(item, index) { resultParts.forEach(function(item, index) {
if (index == 0) { if (index == 0) {
item = "<b><font style=\"color:green\"> " + item +"</font></b>"; item = "<b><font style=\"color:green\"> " + item +"</font></b>";
} }
@ -313,10 +314,10 @@ class FillBlanks extends Question
}); });
result = partsToString; result = partsToString;
} }
return inSeparatorStart+result+inSeparatorEnd; return inSeparatorStart+result+inSeparatorEnd;
} }
</script>'; </script>';
// answer // answer
@ -889,15 +890,15 @@ class FillBlanks extends Question
// we got the less recent attempt first // we got the less recent attempt first
$sql = 'SELECT * FROM '.$tblTrackEAttempt.' tea $sql = 'SELECT * FROM '.$tblTrackEAttempt.' tea
LEFT JOIN '.$tblTrackEExercise.' tee LEFT JOIN '.$tblTrackEExercise.' tee
ON ON
tee.exe_id = tea.exe_id AND tee.exe_id = tea.exe_id AND
tea.c_id = '.$courseId.' AND tea.c_id = '.$courseId.' AND
exe_exo_id = '.$testId.' exe_exo_id = '.$testId.'
WHERE WHERE
tee.c_id = '.$courseId.' AND tee.c_id = '.$courseId.' AND
question_id = '.$questionId.' AND question_id = '.$questionId.' AND
tea.user_id IN ('.implode(',', $studentsIdList).') AND tea.user_id IN ('.implode(',', $studentsIdList).') AND
tea.tms >= "'.$startDate.'" AND tea.tms >= "'.$startDate.'" AND
tea.tms <= "'.$endDate.'" tea.tms <= "'.$endDate.'"
ORDER BY user_id, tea.exe_id; ORDER BY user_id, tea.exe_id;
'; ';
@ -1256,8 +1257,8 @@ class FillBlanks extends Question
} }
if ($hideExpectedAnswer) { if ($hideExpectedAnswer) {
$correctAnswerHtml = "<span $correctAnswerHtml = "<span
class='feedback-green' class='feedback-green'
title='".get_lang('Note: This test has been setup to hide the expected answers.')."'> &#8212; </span>"; title='".get_lang('Note: This test has been setup to hide the expected answers.')."'> &#8212; </span>";
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -6,14 +7,12 @@
* This class allows to instantiate an object of type FREE_ANSWER, * This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question. * extending the class question.
* *
* @package chamilo.exercise
*
* @author Eric Marguin * @author Eric Marguin
*/ */
class FreeAnswer extends Question class FreeAnswer extends Question
{ {
public $typePicture = 'open_answer.png'; public $typePicture = 'open_answer.png';
public $explanationLangVar = 'FreeAnswer'; public $explanationLangVar = 'Open question';
/** /**
* Constructor. * Constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -9,7 +10,7 @@ use ChamiloSession as Session;
class GlobalMultipleAnswer extends Question class GlobalMultipleAnswer extends Question
{ {
public $typePicture = 'mcmagl.png'; public $typePicture = 'mcmagl.png';
public $explanationLangVar = 'GlobalMultipleAnswer'; public $explanationLangVar = 'Combination true/false/don\'t-know';
/** /**
* GlobalMultipleAnswer constructor. * GlobalMultipleAnswer constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -9,13 +10,11 @@
* extending the class question * extending the class question
* *
* @author Eric Marguin * @author Eric Marguin
*
* @package chamilo.exercise
*/ */
class HotSpot extends Question class HotSpot extends Question
{ {
public $typePicture = 'hotspot.png'; public $typePicture = 'hotspot.png';
public $explanationLangVar = 'HotSpot'; public $explanationLangVar = 'Image zones';
/** /**
* HotSpot constructor. * HotSpot constructor.

@ -14,7 +14,7 @@ use ChamiloSession as Session;
class MultipleAnswer extends Question class MultipleAnswer extends Question
{ {
public $typePicture = 'mcma.png'; public $typePicture = 'mcma.png';
public $explanationLangVar = 'MultipleSelect'; public $explanationLangVar = 'Multiple answer';
/** /**
* Constructor. * Constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -15,7 +16,7 @@ use ChamiloSession as Session;
class MultipleAnswerCombination extends Question class MultipleAnswerCombination extends Question
{ {
public $typePicture = 'mcmac.png'; public $typePicture = 'mcmac.png';
public $explanationLangVar = 'MultipleSelectCombination'; public $explanationLangVar = 'Exact Selection';
/** /**
* Constructor. * Constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -8,8 +9,6 @@
* extending the class question * extending the class question
* *
* @author Eric Marguin * @author Eric Marguin
*
* @package chamilo.exercise
*/ */
class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination
{ {

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -13,7 +14,7 @@ use ChamiloSession as Session;
class MultipleAnswerTrueFalse extends Question class MultipleAnswerTrueFalse extends Question
{ {
public $typePicture = 'mcmao.png'; public $typePicture = 'mcmao.png';
public $explanationLangVar = 'MultipleAnswerTrueFalse'; public $explanationLangVar = 'Multiple answer true/false/don\'t know';
public $options; public $options;
/** /**

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -7,13 +8,11 @@
* extending the class question. * extending the class question.
* *
* @author Eric Marguin * @author Eric Marguin
*
* @package chamilo.exercise
*/ */
class OralExpression extends Question class OralExpression extends Question
{ {
public $typePicture = 'audio_question.png'; public $typePicture = 'audio_question.png';
public $explanationLangVar = 'OralExpression'; public $explanationLangVar = 'Oral expression';
public $available_extensions = ['wav', 'ogg']; public $available_extensions = ['wav', 'ogg'];
private $sessionId; private $sessionId;
private $userId; private $userId;

@ -901,8 +901,8 @@ abstract class Question
$sql = "SELECT question_order $sql = "SELECT question_order
FROM $table FROM $table
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
question_id = $id AND question_id = $id AND
exercice_id = $exerciseId"; exercice_id = $exerciseId";
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
@ -911,8 +911,8 @@ abstract class Question
$sql = "UPDATE $table $sql = "UPDATE $table
SET question_order = question_order-1 SET question_order = question_order-1
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
exercice_id = $exerciseId AND exercice_id = $exerciseId AND
question_order > ".$row['question_order']; question_order > ".$row['question_order'];
Database::query($sql); Database::query($sql);
} }
@ -920,8 +920,8 @@ abstract class Question
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
question_id = $id AND question_id = $id AND
exercice_id = $exerciseId"; exercice_id = $exerciseId";
Database::query($sql); Database::query($sql);
@ -962,7 +962,7 @@ abstract class Question
// if the question must be removed from all exercises // if the question must be removed from all exercises
if (!$deleteFromEx) { if (!$deleteFromEx) {
//update the question_order of each question to avoid inconsistencies //update the question_order of each question to avoid inconsistencies
$sql = "SELECT exercice_id, question_order $sql = "SELECT exercice_id, question_order
FROM $TBL_EXERCISE_QUESTION FROM $TBL_EXERCISE_QUESTION
WHERE c_id = $courseId AND question_id = ".$id; WHERE c_id = $courseId AND question_id = ".$id;
@ -973,8 +973,8 @@ abstract class Question
$sql = "UPDATE $TBL_EXERCISE_QUESTION $sql = "UPDATE $TBL_EXERCISE_QUESTION
SET question_order = question_order-1 SET question_order = question_order-1
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
exercice_id = ".intval($row['exercice_id'])." AND exercice_id = ".intval($row['exercice_id'])." AND
question_order > ".$row['question_order']; question_order > ".$row['question_order'];
Database::query($sql); Database::query($sql);
} }
@ -995,8 +995,8 @@ abstract class Question
// remove the category of this question in the question_rel_category table // remove the category of this question in the question_rel_category table
$sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
question_id = ".$id; question_id = ".$id;
Database::query($sql); Database::query($sql);
@ -1098,7 +1098,7 @@ abstract class Question
$newQuestionId = Database::insert($questionTable, $params); $newQuestionId = Database::insert($questionTable, $params);
if ($newQuestionId) { if ($newQuestionId) {
$sql = "UPDATE $questionTable $sql = "UPDATE $questionTable
SET id = iid SET id = iid
WHERE iid = $newQuestionId"; WHERE iid = $newQuestionId";
Database::query($sql); Database::query($sql);
@ -1112,7 +1112,7 @@ abstract class Question
unset($item['iid']); unset($item['iid']);
$id = Database::insert($TBL_QUESTION_OPTIONS, $item); $id = Database::insert($TBL_QUESTION_OPTIONS, $item);
if ($id) { if ($id) {
$sql = "UPDATE $TBL_QUESTION_OPTIONS $sql = "UPDATE $TBL_QUESTION_OPTIONS
SET id = iid SET id = iid
WHERE iid = $id"; WHERE iid = $id";
Database::query($sql); Database::query($sql);
@ -1760,7 +1760,7 @@ abstract class Question
// Get the max position // Get the max position
$sql = "SELECT max(position) as max_position $sql = "SELECT max(position) as max_position
FROM $tbl_quiz_question q FROM $tbl_quiz_question q
INNER JOIN $tbl_quiz_rel_question r INNER JOIN $tbl_quiz_rel_question r
ON ON
q.id = r.question_id AND q.id = r.question_id AND
@ -1783,7 +1783,7 @@ abstract class Question
$question_id = Database::insert($tbl_quiz_question, $params); $question_id = Database::insert($tbl_quiz_question, $params);
if ($question_id) { if ($question_id) {
$sql = "UPDATE $tbl_quiz_question $sql = "UPDATE $tbl_quiz_question
SET id = iid WHERE iid = $question_id"; SET id = iid WHERE iid = $question_id";
Database::query($sql); Database::query($sql);
@ -1816,7 +1816,7 @@ abstract class Question
*/ */
public function getExplanation() public function getExplanation()
{ {
return $this->explanationLangVar; return get_lang($this->explanationLangVar);
} }
/** /**
@ -2059,10 +2059,10 @@ abstract class Question
$result = $em $result = $em
->createQuery(' ->createQuery('
SELECT e SELECT e
FROM ChamiloCourseBundle:CQuizRelQuestion qq FROM ChamiloCourseBundle:CQuizRelQuestion qq
JOIN ChamiloCourseBundle:CQuiz e JOIN ChamiloCourseBundle:CQuiz e
WHERE e.iid = qq.exerciceId AND qq.questionId = :id WHERE e.iid = qq.exerciceId AND qq.questionId = :id
') ')
->setParameters(['id' => (int) $this->id]) ->setParameters(['id' => (int) $this->id])
->getResult(); ->getResult();

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -6,8 +7,6 @@
* It is included from the script admin.php. * It is included from the script admin.php.
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*
* @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $
*/ */
if (isset($_GET['editQuestion'])) { if (isset($_GET['editQuestion'])) {
$objQuestion = Question::read($_GET['editQuestion']); $objQuestion = Question::read($_GET['editQuestion']);

@ -4,8 +4,6 @@
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* @package chamilo.exercise
*
* @author Olivier Brouckaert & Julio Montoya & Hubert Borderiou 21-10-2011 (Question by category) * @author Olivier Brouckaert & Julio Montoya & Hubert Borderiou 21-10-2011 (Question by category)
* QUESTION LIST ADMINISTRATION * QUESTION LIST ADMINISTRATION
* *
@ -175,7 +173,6 @@ if (!$inATest) {
$questionList = $objExercise->getQuestionForTeacher($start, $length); $questionList = $objExercise->getQuestionForTeacher($start, $length);
$paginator = new Knp\Component\Pager\Paginator(); $paginator = new Knp\Component\Pager\Paginator();
$pagination = $paginator->paginate([]); $pagination = $paginator->paginate([]);
$pagination->setTotalItemCount($nbrQuestions); $pagination->setTotalItemCount($nbrQuestions);
$pagination->setItemNumberPerPage($length); $pagination->setItemNumberPerPage($length);
$pagination->setCurrentPageNumber($page); $pagination->setCurrentPageNumber($page);
@ -305,18 +302,17 @@ if (!$inATest) {
'.$move.' '.cut($title, 42).' '.$move.' '.cut($title, 42).'
</a>'; </a>';
// Question type $questionType = Display::return_icon(
$typeImg = $objQuestionTmp->getTypePicture(); $objQuestionTmp->getTypePicture(),
$typeExpl = $objQuestionTmp->getExplanation(); $objQuestionTmp->getExplanation()
);
$questionType = Display::return_icon($typeImg, $typeExpl);
// Question category // Question category
$txtQuestionCat = Security::remove_XSS( $questionCategory = Security::remove_XSS(
TestCategory::getCategoryNameForQuestion($objQuestionTmp->id) TestCategory::getCategoryNameForQuestion($objQuestionTmp->id)
); );
if (empty($txtQuestionCat)) { if (empty($questionCategory)) {
$txtQuestionCat = '-'; $questionCategory = '-';
} }
// Question level // Question level
@ -340,9 +336,9 @@ if (!$inATest) {
<span class="visible-xs-inline">'.get_lang('Type').' </span>' <span class="visible-xs-inline">'.get_lang('Type').' </span>'
.$questionType.' .$questionType.'
</div> </div>
<div class="category col-sm-2 col-xs-12" title="'.$txtQuestionCat.'"> <div class="category col-sm-2 col-xs-12" title="'.$questionCategory.'">
<span class="visible-xs-inline">'.get_lang('Category').' </span>' <span class="visible-xs-inline">'.get_lang('Category').' </span>'
.cut($txtQuestionCat, 42).' .cut($questionCategory, 42).'
</div> </div>
<div class="level text-right col-sm-1 col-xs-6"> <div class="level text-right col-sm-1 col-xs-6">
<span class="visible-xs-inline">'.get_lang('Difficulty').' </span>' <span class="visible-xs-inline">'.get_lang('Difficulty').' </span>'

@ -18,7 +18,7 @@ use ChamiloSession as Session;
class UniqueAnswer extends Question class UniqueAnswer extends Question
{ {
public $typePicture = 'mcua.png'; public $typePicture = 'mcua.png';
public $explanationLangVar = 'UniqueSelect'; public $explanationLangVar = 'Multiple choice';
/** /**
* Constructor. * Constructor.

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
@ -14,7 +15,7 @@ use ChamiloSession as Session;
class UniqueAnswerNoOption extends Question class UniqueAnswerNoOption extends Question
{ {
public $typePicture = 'mcuao.png'; public $typePicture = 'mcuao.png';
public $explanationLangVar = 'UniqueAnswerNoOption'; public $explanationLangVar = 'Unique answer with unknown';
/** /**
* Constructor. * Constructor.

@ -31,7 +31,7 @@ Feature: Exercise tool
| exercise_title | Exercise 1 | | exercise_title | Exercise 1 |
And I fill in ckeditor field "exerciseDescription" with "Exercise description" And I fill in ckeditor field "exerciseDescription" with "Exercise description"
And I press "submitExercise" And I press "submitExercise"
Then I should see "Exercise added" Then I should see "Test added"
Scenario: Edit an exercise Scenario: Edit an exercise
Given I am on "/main/exercise/exercise.php?cid=1" Given I am on "/main/exercise/exercise.php?cid=1"
@ -44,7 +44,7 @@ Feature: Exercise tool
Scenario: Add question "Multiple choice" to exercise created "Exercise 1" Scenario: Add question "Multiple choice" to exercise created "Exercise 1"
Given I am on "/main/exercise/exercise.php?cid=1" Given I am on "/main/exercise/exercise.php?cid=1"
And I follow "Exercise 1" And I follow "Exercise 1"
And I follow "Edit" And I follow "Add questions"
And I follow "Multiple choice" And I follow "Multiple choice"
When I fill in the following: When I fill in the following:
| questionName | Multiple choice | | questionName | Multiple choice |

Loading…
Cancel
Save