Fix hotspot , use web_code_path, fix hotspot number, if no result check for older answer id

pull/2487/head
jmontoyaa 9 years ago
parent 5a661ff9f4
commit f9aa1a2f97
  1. 51
      main/exercise/exercise.class.php
  2. 2
      main/exercise/exercise_show.php
  3. 2
      main/exercise/hotspot_admin.inc.php
  4. 13
      main/exercise/question_list_admin.inc.php
  5. 124
      main/inc/lib/agenda.lib.php
  6. 13
      main/inc/lib/exercise.lib.php
  7. 14
      main/inc/lib/javascript/hotspot/js/hotspot.js

@ -4016,24 +4016,47 @@ class Exercise
$sql = "SELECT hotspot_correct
FROM $TBL_TRACK_HOTSPOT
WHERE
hotspot_exe_id = '".$exeId."' AND
hotspot_question_id= '".$questionId."' AND
hotspot_exe_id = $exeId AND
hotspot_question_id= $questionId AND
hotspot_answer_id = ".intval($answerAutoId)."";
$result = Database::query($sql);
$studentChoice = Database::result($result, 0, "hotspot_correct");
if (Database::num_rows($result)) {
$studentChoice = Database::result(
$result,
0,
"hotspot_correct"
);
if ($studentChoice) {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
if ($studentChoice) {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
}
} else {
// If answerid is different:
$sql = "SELECT hotspot_correct
FROM $TBL_TRACK_HOTSPOT
WHERE
hotspot_exe_id = $exeId AND
hotspot_question_id= $questionId AND
hotspot_answer_id = ".intval($answerId);
$result = Database::query($sql);
$studentChoice = Database::result(
$result,
0,
"hotspot_correct"
);
if ($studentChoice) {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
}
}
} else {
if (!isset($choice[$answerAutoId])) {
$choice[$answerAutoId] = 0;
} else {
$studentChoice = $choice[$answerAutoId];
$choiceIsValid = false;
if (!empty($studentChoice)) {
$hotspotType = $objAnswerTmp->selectHotspotType($answerId);
$hotspotCoordinates = $objAnswerTmp->selectHotspotCoordinates($answerId);
@ -4069,7 +4092,7 @@ class Exercise
break;
// @todo never added to chamilo
//for hotspot with fixed order
case HOT_SPOT_ORDER :
case HOT_SPOT_ORDER:
$studentChoice = $choice['order'][$answerId];
if ($studentChoice == $answerId) {
$questionScore += $answerWeighting;
@ -4080,7 +4103,7 @@ class Exercise
}
break;
// for hotspot with delineation
case HOT_SPOT_DELINEATION :
case HOT_SPOT_DELINEATION:
if ($from_database) {
// getting the user answer
$TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
@ -4228,6 +4251,7 @@ class Exercise
);
} elseif ($answerType == HOT_SPOT) {
foreach ($orderedHotspots as $correctAnswerId => $hotspot) {
if ($hotspot->getHotspotAnswerId() == $answerAutoId) {
break;
}
@ -4235,7 +4259,7 @@ class Exercise
ExerciseShowFunctions::display_hotspot_answer(
$feedback_type,
++$correctAnswerId,
$answerId,
$answer,
$studentChoice,
$answerComment,
@ -4980,16 +5004,14 @@ class Exercise
// We made an extra table for the answers
if ($show_result) {
$relPath = api_get_path(REL_PATH);
$relPath = api_get_path(WEB_CODE_PATH);
// if ($origin != 'learnpath') {
echo '</table></td></tr>';
echo "
<tr>
<td colspan=\"2\">
<p><em>" . get_lang('HotSpot') . "</em></p>
<div id=\"hotspot-solution-$questionId\"></div>
<script>
$(document).on('ready', function () {
new HotspotQuestion({
@ -5000,7 +5022,6 @@ class Exercise
relPath: '$relPath'
});
});
</script>
</td>
</tr>

@ -439,7 +439,7 @@ foreach ($questionList as $questionId) {
$totalScore += $question_result['score'];
if ($show_results) {
$relPath = api_get_path(REL_PATH);
$relPath = api_get_path(WEB_CODE_PATH);
echo '</table></td></tr>';
echo "
<tr>

@ -1034,7 +1034,7 @@ if ($modifyAnswers) {
<?php
$swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450;
$relPath = api_get_path(REL_PATH);
$relPath = api_get_path(WEB_CODE_PATH);
?>
<div id="hotspot-container" class="center-block">
</div>

@ -270,7 +270,18 @@ if (!$inATest) {
echo '<div class="question-list-description-block">';
echo '<p class="lead">' . get_lang($question_class) . '</p>';
//echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
ExerciseLib::showQuestion($id, false, null, null, false, true, false, true, $objExercise->feedback_type, true);
ExerciseLib::showQuestion(
$id,
false,
null,
null,
false,
true,
false,
true,
$objExercise->feedback_type,
true
);
echo '</div>';
echo '</div>';
unset($objQuestionTmp);

@ -197,7 +197,9 @@ class Agenda
$groupIid = 0;
if ($groupId) {
$groupInfo = GroupManager::get_group_properties($groupId);
$groupIid = $groupInfo['iid'];
if ($groupInfo) {
$groupIid = $groupInfo['iid'];
}
}
if (!empty($usersToSend)) {
@ -235,7 +237,9 @@ class Agenda
$groupIidItem = 0;
if ($group) {
$groupInfo = GroupManager::get_group_properties($group);
$groupIidItem = $groupInfo['iid'];
if ($groupInfo) {
$groupIidItem = $groupInfo['iid'];
}
}
api_item_property_update(
@ -529,7 +533,7 @@ class Agenda
$course_id = api_get_course_int_id();
// Check params
if (empty($item_id) or $item_id != strval(intval($item_id))) {
if (empty($item_id) || $item_id != strval(intval($item_id))) {
return -1;
}
@ -624,6 +628,15 @@ class Agenda
}
$groupId = api_get_group_id();
$groupIid = 0;
if ($groupId) {
$groupInfo = GroupManager::get_group_properties($groupId);
if ($groupInfo) {
$groupIid = $groupInfo['iid'];
}
}
$course_id = $this->course['real_id'];
if (empty($course_id)) {
@ -668,12 +681,20 @@ class Agenda
!empty($eventInfo['send_to']['groups'])
) {
foreach ($eventInfo['send_to']['groups'] as $group) {
$groupIidItem = 0;
if ($group) {
$groupInfo = GroupManager::get_group_properties($group);
if ($groupInfo) {
$groupIidItem = $groupInfo['iid'];
}
}
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
0,
$group,
$groupIidItem,
$this->sessionId
);
}
@ -689,7 +710,7 @@ class Agenda
TOOL_CALENDAR_EVENT,
$id,
$userId,
$groupId,
$groupIid,
$this->sessionId
);
}
@ -700,9 +721,9 @@ class Agenda
$this->course,
TOOL_CALENDAR_EVENT,
$id,
"visible",
'visible',
api_get_user_id(),
$groupId,
$groupIid,
null,
$start,
$end,
@ -722,13 +743,21 @@ class Agenda
// Add groups
if (!empty($groupToAdd)) {
foreach ($groupToAdd as $group) {
$groupIidItem = 0;
if ($group) {
$groupInfo = GroupManager::get_group_properties($group);
if ($groupInfo) {
$groupIidItem = $groupInfo['iid'];
}
}
api_item_property_update(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
"visible",
'visible',
api_get_user_id(),
$group,
$groupIidItem,
0,
$start,
$end,
@ -740,12 +769,20 @@ class Agenda
// Delete groups.
if (!empty($groupsToDelete)) {
foreach ($groupsToDelete as $group) {
$groupIidItem = 0;
if ($group) {
$groupInfo = GroupManager::get_group_properties($group);
if ($groupInfo) {
$groupIidItem = $groupInfo['iid'];
}
}
api_item_property_delete(
$this->course,
TOOL_CALENDAR_EVENT,
$id,
0,
$group,
$groupIidItem,
$this->sessionId
);
}
@ -758,9 +795,9 @@ class Agenda
$this->course,
TOOL_CALENDAR_EVENT,
$id,
"visible",
'visible',
api_get_user_id(),
$groupId,
$groupIid,
$userId,
$start,
$end,
@ -777,7 +814,7 @@ class Agenda
TOOL_CALENDAR_EVENT,
$id,
$userId,
$groupId,
$groupIid,
$this->sessionId
);
}
@ -1515,7 +1552,11 @@ class Agenda
to_user_id
FROM $tlb_course_agenda agenda
INNER JOIN $tbl_property ip
ON (agenda.id = ip.ref AND agenda.c_id = ip.c_id AND ip.tool = '".TOOL_CALENDAR_EVENT."')
ON (
agenda.id = ip.ref AND
agenda.c_id = ip.c_id AND
ip.tool = '".TOOL_CALENDAR_EVENT."'
)
WHERE
$where_condition AND
ip.visibility = '1' AND
@ -1528,7 +1569,7 @@ class Agenda
if (api_is_allowed_to_edit()) {
if ($user_id == 0) {
$where_condition = "";
$where_condition = '';
} else {
$where_condition = " (ip.to_user_id = ".$user_id." OR ip.to_user_id IS NULL) AND ip.to_group_id IS NULL AND ";
}
@ -1736,7 +1777,6 @@ class Agenda
{
$start = isset($start) && !empty($start) ? api_get_utc_datetime(intval($start)) : null;
$end = isset($end) && !empty($end) ? api_get_utc_datetime(intval($end)) : null;
$dateCondition = '';
if (!empty($start) && !empty($end)) {
@ -1858,6 +1898,7 @@ class Agenda
$html .= '</optgroup>';
$html .= "</select>";
}
return $html;
}
@ -2145,8 +2186,6 @@ class Agenda
'<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
//if ($showAttachmentForm) {
if (isset($params['attachment']) && !empty($params['attachment'])) {
$attachmentList = $params['attachment'];
foreach ($attachmentList as $attachment) {
@ -2160,9 +2199,7 @@ class Agenda
);
}
}
}
// }
$form->addElement('textarea', 'file_comment', get_lang('FileComment'));
}
@ -2236,7 +2273,6 @@ class Agenda
);
return true;
}
/**
@ -2255,9 +2291,21 @@ class Agenda
}
if ($visibility == 0) {
api_item_property_update($courseInfo, TOOL_CALENDAR_EVENT, $id, "invisible", $userId);
api_item_property_update(
$courseInfo,
TOOL_CALENDAR_EVENT,
$id,
'invisible',
$userId
);
} else {
api_item_property_update($courseInfo, TOOL_CALENDAR_EVENT, $id, "visible", $userId);
api_item_property_update(
$courseInfo,
TOOL_CALENDAR_EVENT,
$id,
'visible',
$userId
);
}
}
@ -2352,8 +2400,8 @@ class Agenda
if (!empty($fileUserUpload['name'])) {
$upload_ok = process_uploaded_file($fileUserUpload);
}
if (!empty($upload_ok)) {
if (!empty($upload_ok)) {
$courseDir = $courseInfo['directory'].'/upload/calendar';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$uploadDir = $sys_course_path.$courseDir;
@ -2363,6 +2411,7 @@ class Agenda
stripslashes($fileUserUpload['name']),
$fileUserUpload['type']
);
// user's file name
$file_name = $fileUserUpload['name'];
@ -2452,7 +2501,10 @@ class Agenda
);
if (!empty($result)) {
return Display::return_message(get_lang("AttachmentFileDeleteSuccess"), 'confirmation');
return Display::return_message(
get_lang("AttachmentFileDeleteSuccess"),
'confirmation'
);
}
}
@ -2463,7 +2515,7 @@ class Agenda
* @param integer $timestamp
* @return int The new timestamp
*/
function addWeek($timestamp, $num = 1)
public function addWeek($timestamp, $num = 1)
{
return $timestamp + $num * 604800;
}
@ -2475,7 +2527,7 @@ class Agenda
* @param integer $timestamp
* @return int The new timestamp
*/
function addMonth($timestamp, $num = 1)
public function addMonth($timestamp, $num = 1)
{
list($y, $m, $d, $h, $n, $s) = split('/', date('Y/m/d/h/i/s', $timestamp));
if ($m + $num > 12) {
@ -2494,7 +2546,7 @@ class Agenda
* @param integer $timestamp
* @return int The new timestamp
*/
function addYear($timestamp, $num = 1)
public function addYear($timestamp, $num = 1)
{
list($y, $m, $d, $h, $n, $s) = split('/', date('Y/m/d/h/i/s', $timestamp));
return mktime($h, $n, $s, $m, $d, $y + $num);
@ -2543,8 +2595,8 @@ class Agenda
$sql = "SELECT count(DISTINCT(id)) as count
FROM ".$this->tbl_course_agenda."
WHERE
c_id = ".$courseId." AND
parent_event_id = ".$eventId;
c_id = $courseId AND
parent_event_id = $eventId";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
@ -2717,8 +2769,16 @@ class Agenda
$end = $event->DTEND->getDateTime();
//Sabre\VObject\DateTimeParser::parseDateTime(string $dt, \Sabre\VObject\DateTimeZone $tz)
$startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e'));
$endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e'));
$startDateTime = api_get_local_time(
$start->format('Y-m-d H:i:s'),
$currentTimeZone,
$start->format('e')
);
$endDateTime = api_get_local_time(
$end->format('Y-m-d H:i'),
$currentTimeZone,
$end->format('e')
);
$title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8');
$description = api_convert_encoding((string)$event->description, $charset, 'UTF-8');

@ -1136,9 +1136,8 @@ HTML;
}
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
if ($freeze) {
$relPath = api_get_path(REL_PATH);
$relPath = api_get_path(WEB_CODE_PATH);
echo "
<script>
$(document).on('ready', function () {
@ -1172,28 +1171,24 @@ HTML;
}
$answerList = '';
if ($answerType != HOT_SPOT_DELINEATION) {
$answerList = '
<div class="well well-sm">
<h5 class="page-header">' . get_lang('HotspotZones') . '</h5>
<ol>
<ul>
';
if (!empty($answers_hotspot)) {
Session::write('hotspot_ordered', array_keys($answers_hotspot));
$countAnswers = 1;
foreach ($answers_hotspot as $value) {
$answerList .= "<li><p>{$countAnswers} - {$value}</p></li>";
$countAnswers++;
}
}
$answerList .= '
</ol>
</ul>
</div>
';
}
@ -1212,7 +1207,7 @@ HTML;
HOTSPOT;
}
$relPath = api_get_path(REL_PATH);
$relPath = api_get_path(WEB_CODE_PATH);
$s .= "
<div class=\"col-sm-8 col-md-9\">
<div class=\"hotspot-image\"></div>

@ -1136,13 +1136,13 @@ window.HotspotQuestion = (function () {
switch (config.for) {
case 'admin':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_actionscript_admin.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_actionscript_admin.as.php', {
modifyAnswers: parseInt(config.questionId)
});
break;
case 'user':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_actionscript.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_actionscript.as.php', {
modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId)
});
@ -1151,7 +1151,7 @@ window.HotspotQuestion = (function () {
case 'solution':
//no break
case 'preview':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_answers.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId)
});
@ -1760,21 +1760,19 @@ window.DelineationQuestion = (function () {
switch (config.for) {
case 'admin':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_actionscript_admin.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_actionscript_admin.as.php', {
modifyAnswers: parseInt(config.questionId)
});
break;
case 'user':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_actionscript.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_actionscript.as.php', {
modifyAnswers: parseInt(config.questionId)
});
break;
case 'solution':
//no break
case 'preview':
xhrQuestion = $.getJSON(config.relPath+'main/exercise/hotspot_answers.as.php', {
xhrQuestion = $.getJSON(config.relPath+'exercise/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId)
});

Loading…
Cancel
Save