Exercises: Fix queries, fix hotspot image

pull/3741/head
Julio Montoya 4 years ago
parent fdeca28d34
commit 929166e211
  1. 4
      public/main/exercise/TestCategory.php
  2. 4
      public/main/exercise/answer.class.php
  3. 28
      public/main/exercise/exercise.class.php
  4. 2
      public/main/exercise/exercise_report.php
  5. 3
      public/main/exercise/export/qti2/qti2_export.php
  6. 29
      public/main/exercise/hotspot_actionscript.as.php
  7. 22
      public/main/exercise/hotspot_actionscript_admin.as.php
  8. 1
      public/main/exercise/qti2.php
  9. 4
      public/main/inc/lib/exercise.lib.php
  10. 2
      src/CourseBundle/Repository/CQuizQuestionRepository.php

@ -45,13 +45,13 @@ class TestCategory
$id = (int) $id;
$courseId = empty($courseId) ? api_get_course_int_id() : (int) $courseId;
$sql = "SELECT * FROM $table
WHERE id = $id AND c_id = ".$courseId;
WHERE iid = $id AND c_id = ".$courseId;
$res = Database::query($sql);
if (Database::num_rows($res)) {
$row = Database::fetch_array($res);
$this->id = $row['id'];
$this->id = $row['iid'];
$this->name = $row['title'];
$this->description = $row['description'];

@ -135,6 +135,8 @@ class Answer
// while a record is found
while ($object = Database::fetch_object($result)) {
$this->id[$i] = $object->iid;
$this->autoId[$i] = $object->iid;
$this->iid[$i] = $object->iid;
$this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment;
@ -143,8 +145,6 @@ class Answer
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $object->destination;
$this->autoId[$i] = $object->iid;
$this->iid[$i] = $object->iid;
$i++;
}
$this->nbrAnswers = $i - 1;

@ -8774,7 +8774,6 @@ class Exercise
$myActions = null,
$returnTable = false
) {
$course = api_get_course_entity($courseId);
$session = api_get_session_entity($sessionId);
@ -8853,9 +8852,9 @@ class Exercise
}
}
$keywordCondition = '';
if (!empty($keyword)) {
$qb->andWhere($qb->expr()->eq('resource.title', $keyword));
$qb->andWhere($qb->expr()->eq('resource.title', ':keyword'));
$qb->setParameter('keyword', $keyword);
}
$qb->setFirstResult($from);
@ -8997,19 +8996,22 @@ class Exercise
$visibility = $exerciseEntity->isVisible($course, $session);
}
$style = '';
if (0 == $exerciseEntity->getActive() || false === $visibility) {
$title = Display::tag('font', $cut_title, ['style' => 'color:grey']);
} else {
$title = $cut_title;
$style = 'color:grey';
//$title = Display::tag('font', $cut_title, ['style' => 'color:grey']);
}
$move = null;
$class_tip = '';
$url = $move.'<a
'.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$exerciseId.'"
href="overview.php?'.api_get_cidreq().$mylpid.$mylpitemid.'&exerciseId='.$exerciseId.'">
'.Display::return_icon('quiz.png', $title).'
'.$title.' </a>'.PHP_EOL;
$title = $cut_title;
$url = '<a
'.$alt_title.'
id="tooltip_'.$exerciseId.'"
href="overview.php?'.api_get_cidreq().$mylpid.$mylpitemid.'&exerciseId='.$exerciseId.'"
style = "'.$style.'"
>
'.Display::return_icon('quiz.png', $title).$title.
'</a>';
if (ExerciseLib::isQuizEmbeddable($exerciseEntity)) {
$embeddableIcon = Display::return_icon(

@ -600,7 +600,7 @@ $group_parameters = [
];
foreach ($group_list as $group) {
$group_parameters[] = $group['id'].':'.$group['name'];
$group_parameters[] = $group['iid'].':'.$group['name'];
}
if (!empty($group_parameters)) {
$group_parameters = implode(';', $group_parameters);

@ -5,10 +5,7 @@
/**
* @author Claro Team <cvs@claroline.net>
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
require __DIR__.'/qti2_classes.php';
/**
* An IMS/QTI item. It corresponds to a single question.
* This class allows export from Claroline to IMS/QTI2.0 XML format of a single question.
* It is not usable as-is, but must be subclassed, to support different kinds of questions.

@ -25,20 +25,25 @@ $exerciseId = isset($_GET['exe_id']) ? (int) $_GET['exe_id'] : 0;
$questionRepo = Container::getQuestionRepository();
/** @var CQuizQuestion $objQuestion */
$objQuestion = $questionRepo->find($questionId);
if (!$objQuestion) {
api_not_allowed();
}
$answer_type = $objQuestion->getType(); //very important
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
if (!$objQuestion->getResourceNode()->hasResourceFile()) {
api_not_allowed();
}
$resourceFile = $objQuestion->getResourceNode()->getResourceFile();
$pictureWidth = $resourceFile->getWidth();
$pictureHeight = $resourceFile->getHeight();
$imagePath = $questionRepo->getHotSpotImageUrl($objQuestion);
$imagePath = $questionRepo->getHotSpotImageUrl($objQuestion).'?'.api_get_cidreq();
$course_id = api_get_course_int_id();
// Query db for answers
if (HOT_SPOT_DELINEATION == $answer_type) {
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
$sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation
FROM $TBL_ANSWERS
WHERE
c_id = $course_id AND
@ -46,7 +51,7 @@ if (HOT_SPOT_DELINEATION == $answer_type) {
hotspot_type = 'delineation'
ORDER BY iid";
} else {
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
$sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation
FROM $TBL_ANSWERS
WHERE c_id = $course_id AND question_id = $questionId
ORDER BY position";
@ -67,28 +72,28 @@ $nmbrTries = 0;
while ($hotspot = Database::fetch_assoc($result)) {
$hotSpot = [];
$hotSpot['id'] = $hotspot['id'];
$hotSpot['id'] = $hotspot['iid'];
$hotSpot['iid'] = $hotspot['iid'];
$hotSpot['answer'] = $hotspot['answer'];
// Square or rectancle
if ('square' == $hotspot['hotspot_type']) {
// Square or rectangle
if ('square' === $hotspot['hotspot_type']) {
$hotSpot['type'] = 'square';
}
// Circle or ovale
if ('circle' == $hotspot['hotspot_type']) {
// Circle or oval
if ('circle' === $hotspot['hotspot_type']) {
$hotSpot['type'] = 'circle';
}
// Polygon
if ('poly' == $hotspot['hotspot_type']) {
if ('poly' === $hotspot['hotspot_type']) {
$hotSpot['type'] = 'poly';
}
// Delineation
if ('delineation' == $hotspot['hotspot_type']) {
if ('delineation' === $hotspot['hotspot_type']) {
$hotSpot['type'] = 'delineation';
}
// No error
if ('noerror' == $hotspot['hotspot_type']) {
if ('noerror' === $hotspot['hotspot_type']) {
$hotSpot['type'] = 'noerror';
}

@ -18,8 +18,7 @@ api_protect_course_script(false);
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
if (!$isAllowedToEdit) {
api_not_allowed(true);
exit;
api_not_allowed();
}
$_course = api_get_course_info();
@ -27,11 +26,16 @@ $questionId = isset($_GET['modifyAnswers']) ? (int) $_GET['modifyAnswers'] : 0;
$questionRepo = Container::getQuestionRepository();
/** @var CQuizQuestion $objQuestion */
$objQuestion = $questionRepo->find($questionId);
if (!$objQuestion) {
api_not_allowed();
}
if (!$objQuestion->getResourceNode()->hasResourceFile()) {
api_not_allowed();
}
$resourceFile = $objQuestion->getResourceNode()->getResourceFile();
$pictureWidth = $resourceFile->getWidth();
$pictureHeight = $resourceFile->getHeight();
$imagePath = $questionRepo->getHotSpotImageUrl($objQuestion);
$imagePath = $questionRepo->getHotSpotImageUrl($objQuestion).'?'.api_get_cidreq();
$data = [];
$data['type'] = 'admin';
@ -60,18 +64,18 @@ for ($i = 1; $i <= $nbrAnswers; $i++) {
$hotSpot['type'] = 'oar';
}
} else {
// Square or rectancle
if ('square' == $answers['hotspot_type'][$i]) {
// Square or rectangle
if ('square' === $answers['hotspot_type'][$i]) {
$hotSpot['type'] = 'square';
}
// Circle or ovale
if ('circle' == $answers['hotspot_type'][$i]) {
// Circle or oval
if ('circle' === $answers['hotspot_type'][$i]) {
$hotSpot['type'] = 'circle';
}
// Polygon
if ('poly' == $answers['hotspot_type'][$i]) {
if ('poly' === $answers['hotspot_type'][$i]) {
$hotSpot['type'] = 'poly';
}
/*// Delineation

@ -71,7 +71,6 @@ function importFile($array_file)
if ($process && 1 == $unzip) {
$main_path = api_get_path(SYS_CODE_PATH);
require_once $main_path.'exercise/export/exercise_import.inc.php';
require_once $main_path.'exercise/export/qti2/qti2_classes.php';
return import_exercise($array_file['name']);
}

@ -1424,7 +1424,7 @@ HTML;
$answers = $objAnswerTmp->selectAnswerByAutoId(
$objAnswerTmp->selectAutoId($answerId)
);
$answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer(
$answers_hotspot[$answers['iid']] = $objAnswerTmp->selectAnswer(
$answerId
);
}
@ -2162,7 +2162,7 @@ HOTSPOT;
$clean_group_list = [];
if (!empty($group_list)) {
foreach ($group_list as $group) {
$clean_group_list[$group['id']] = $group['name'];
$clean_group_list[$group['iid']] = $group['name'];
}
}

@ -21,7 +21,7 @@ final class CQuizQuestionRepository extends ResourceRepository
public function getHotSpotImageUrl(CQuizQuestion $resource): string
{
$params = [
'mode' => 'show',
'mode' => 'view',
'filter' => 'hotspot_question',
];

Loading…
Cancel
Save