Fix shuffle with hotspot question - refs #8148

1.10.x
Angel Fernando Quiroz Campos 9 years ago
parent e0e55b708d
commit e86630ac24
  1. 4
      main/exercice/answer.class.php
  2. 27
      main/exercice/exercise.class.php
  3. 21
      main/exercice/hotspot_actionscript.as.php
  4. 2
      main/inc/lib/exercise.lib.php
  5. 28
      main/inc/lib/exercise_show_functions.lib.php

@ -245,6 +245,8 @@ class Answer
$this->comment[$i] = $object->comment;
$this->weighting[$i] = $object->ponderation;
$this->position[$i] = $object->position;
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $object->destination;
$this->autoId[$i] = $object->id_auto;
$i++;
@ -256,6 +258,8 @@ class Answer
$this->comment[$i] = $doubt_data->comment;
$this->weighting[$i] = $doubt_data->ponderation;
$this->position[$i] = $doubt_data->position;
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $doubt_data->destination;
$this->autoId[$i] = $doubt_data->id_auto;
$i++;

@ -2137,6 +2137,8 @@ class Exercise
global $learnpath_id, $learnpath_item_id;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
$em = Database::getManager();
$feedback_type = $this->selectFeedbackType();
$results_disabled = $this->selectResultsDisabled();
@ -2272,6 +2274,20 @@ class Exercise
$answer_correct_array = array();
$orderedHotspots = [];
if ($answerType == HOT_SPOT) {
$orderedHotspots = $em
->getRepository('ChamiloCoreBundle:TrackEHotspot')
->findBy([
'hotspotQuestionId' => $questionId,
'cId' => $course_id,
'hotspotExeId' => $exeId
],
['hotspotId' => 'ASC']
);
}
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
@ -3223,13 +3239,20 @@ class Exercise
//}
} elseif ($answerType == HOT_SPOT) {
//if ($origin != 'learnpath') {
foreach ($orderedHotspots as $correctAnswerId => $hotspot) {
if ($hotspot->getHotspotAnswerId() == $answerAutoId) {
break;
}
}
ExerciseShowFunctions::display_hotspot_answer(
$feedback_type,
$answerId,
++$correctAnswerId,
$answer,
$studentChoice,
$answerComment,
$results_disabled
$results_disabled,
$answerId
);
// }
} elseif ($answerType == HOT_SPOT_ORDER) {

@ -8,6 +8,8 @@
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
use ChamiloSession as Session;
session_cache_limiter("none");
require '../inc/global.inc.php';
@ -128,6 +130,25 @@ if (!empty($attemptList)) {
$data['nmbrTries'] = $nmbrTries;
$data['done'] = 'done';
if (Session::has('hotspot_ordered')) {
$tempHotspots = [];
$hotspotOrdered = Session::read('hotspot_ordered');
foreach ($hotspotOrdered as $hotspotOrder) {
foreach ($data['hotspots'] as $hotspot) {
if ($hotspot['id'] != $hotspotOrder) {
continue;
}
$tempHotspots[] = $hotspot;
}
}
$data['hotspots'] = $tempHotspots;
Session::erase('hotspot_ordered');
}
header('Content-Type: application/json');
echo json_encode($data);

@ -1161,7 +1161,7 @@ HTML;
';
if (!empty($answers_hotspot)) {
ksort($answers_hotspot);
Session::write('hotspot_ordered', array_keys($answers_hotspot));
$countAnswers = 1;

@ -153,14 +153,24 @@ class ExerciseShowFunctions
/**
* Displays the answer to a hotspot question
*
* @param int $answerId
* @param string $answer
* @param string $studentChoice
* @param string $answerComment
*/
static function display_hotspot_answer($feedback_type, $answerId, $answer, $studentChoice, $answerComment, $in_results_disabled)
{
* @param int $feedback_type
* @param int $answerId
* @param string $answer
* @param string $studentChoice
* @param string $answerComment
* @param string $in_results_disabled
* @param int $orderColor
*/
public static function display_hotspot_answer(
$feedback_type,
$answerId,
$answer,
$studentChoice,
$answerComment,
$in_results_disabled,
$orderColor
)
{
$hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) {
$hide_expected_answer = true;
@ -185,7 +195,7 @@ class ExerciseShowFunctions
<table class="data_table">
<tr>
<td class="text-center" width="5%">
<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color: <?php echo $hotspot_colors[$answerId]; ?>"></span>
<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color: <?php echo $hotspot_colors[$orderColor]; ?>"></span>
</td>
<td class="text-left" width="25%">
<?php echo "$answerId - $answer"; ?>

Loading…
Cancel
Save