Minor - merge 1.11.x

pull/2715/head
Julio Montoya 7 years ago
parent 436307390b
commit dd20a596e6
  1. 7
      main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  2. 14
      main/exercise/exercise.class.php
  3. 13
      main/exercise/fill_blanks.class.php
  4. 111
      main/exercise/recalculate.php
  5. 93
      main/forum/forumfunction.inc.php
  6. 2
      main/gradebook/gradebook_display_certificate.php
  7. 21
      main/inc/lib/agenda.lib.php
  8. 10
      main/inc/lib/course.lib.php
  9. 2
      main/inc/lib/fileUpload.lib.php
  10. 512
      main/lp/learnpath.class.php
  11. 1
      main/lp/learnpathItem.class.php
  12. 25
      main/lp/lp_ajax_save_item.php
  13. 21
      main/lp/lp_controller.php
  14. 21
      main/lp/lp_nav.php
  15. 25
      main/lp/scorm_api.php
  16. 11
      main/mySpace/myStudents.php
  17. 8
      main/social/home.php
  18. 2
      main/social/myfiles.php
  19. 8
      main/survey/ch_multipleresponse.php
  20. 2
      main/survey/reporting.php
  21. 137
      main/survey/surveyUtil.class.php
  22. 8
      src/CourseBundle/Entity/CDocument.php

@ -1097,10 +1097,14 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
} }
// get student answer option id // get student answer option id
$studentAnswerOptionId = $splitAnswer[1]; $studentAnswerOptionId = isset($splitAnswer[1]) ? $splitAnswer[1] : null;
// we got the correct answer option id, let's compare ti with the student answer // we got the correct answer option id, let's compare ti with the student answer
$percentage = null;
if (isset($splitAnswer[2])) {
$percentage = self::getPercentagePosition($splitAnswer[2]); $percentage = self::getPercentagePosition($splitAnswer[2]);
}
if ($studentAnswerOptionId == $correctAnswerOptionId) { if ($studentAnswerOptionId == $correctAnswerOptionId) {
// yeah, student got correct answer // yeah, student got correct answer
switch ($percentage) { switch ($percentage) {
@ -1199,6 +1203,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$and = ''; $and = '';
$questionId = (int) $questionId; $questionId = (int) $questionId;
$position = (int) $position; $position = (int) $position;
$exeId = (int) $exeId;
if ($questionId >= 0) { if ($questionId >= 0) {
$and .= " AND question_id = $questionId"; $and .= " AND question_id = $questionId";

@ -3318,6 +3318,7 @@ class Exercise
* @param int $propagate_neg * @param int $propagate_neg
* @param array $hotspot_delineation_result * @param array $hotspot_delineation_result
* @param bool $showTotalScoreAndUserChoicesInLastAttempt * @param bool $showTotalScoreAndUserChoicesInLastAttempt
* @param bool $updateResults
* *
* @todo reduce parameters of this function * @todo reduce parameters of this function
* *
@ -3334,7 +3335,8 @@ class Exercise
$show_result = true, $show_result = true,
$propagate_neg = 0, $propagate_neg = 0,
$hotspot_delineation_result = [], $hotspot_delineation_result = [],
$showTotalScoreAndUserChoicesInLastAttempt = true $showTotalScoreAndUserChoicesInLastAttempt = true,
$updateResults = false
) { ) {
$debug = false; $debug = false;
//needed in order to use in the exercise_attempt() for the time //needed in order to use in the exercise_attempt() for the time
@ -3425,8 +3427,8 @@ class Exercise
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$choiceTmp = $choice; $choiceTmp = $choice;
$choice = $choiceTmp["choice"]; $choice = isset($choiceTmp['choice']) ? $choiceTmp['choice'] : '';
$choiceDegreeCertainty = $choiceTmp["choiceDegreeCertainty"]; $choiceDegreeCertainty = isset($choiceTmp['choiceDegreeCertainty']) ? $choiceTmp['choiceDegreeCertainty'] : '';
} }
if ($answerType == FREE_ANSWER || if ($answerType == FREE_ANSWER ||
@ -5654,7 +5656,8 @@ class Exercise
$quesId, $quesId,
$exeId, $exeId,
$i, $i,
$this->id $this->id,
$updateResults
); );
} }
} else { } else {
@ -5664,7 +5667,8 @@ class Exercise
$quesId, $quesId,
$exeId, $exeId,
$i, $i,
$this->id $this->id,
$updateResults
); );
} }
if ($debug) { if ($debug) {

@ -991,10 +991,19 @@ class FillBlanks extends Question
// lets rebuild the sentence with [correct answer][student answer][answer is correct] // lets rebuild the sentence with [correct answer][student answer][answer is correct]
$result = ''; $result = '';
for ($i = 0; $i < count($listWithStudentAnswer['common_words']) - 1; $i++) { for ($i = 0; $i < count($listWithStudentAnswer['common_words']) - 1; $i++) {
$answerValue = null;
if (isset($listWithStudentAnswer['student_answer'][$i])) {
$answerValue = $listWithStudentAnswer['student_answer'][$i];
}
$scoreValue = null;
if (isset($listWithStudentAnswer['student_score'][$i])) {
$scoreValue = $listWithStudentAnswer['student_score'][$i];
}
$result .= $listWithStudentAnswer['common_words'][$i]; $result .= $listWithStudentAnswer['common_words'][$i];
$result .= $listWithStudentAnswer['words_with_bracket'][$i]; $result .= $listWithStudentAnswer['words_with_bracket'][$i];
$result .= $separatorStart.$listWithStudentAnswer['student_answer'][$i].$separatorEnd; $result .= $separatorStart.$answerValue.$separatorEnd;
$result .= $separatorStart.$listWithStudentAnswer['student_score'][$i].$separatorEnd; $result .= $separatorStart.$scoreValue.$separatorEnd;
} }
$result .= $listWithStudentAnswer['common_words'][$i]; $result .= $listWithStudentAnswer['common_words'][$i];
$result .= '::'; $result .= '::';

@ -1,69 +1,106 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackEExercises;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$isAllowedToEdit = api_is_allowed_to_edit(true, true); $isAllowedToEdit = api_is_allowed_to_edit(true, true);
if (!$isAllowedToEdit) { if (!$isAllowedToEdit) {
api_not_allowed(true);
exit; exit;
} }
if (!isset($_REQUEST['user'], $_REQUEST['exercise'], $_REQUEST['id'])) { if (!isset($_REQUEST['user'], $_REQUEST['exercise'], $_REQUEST['id'])) {
api_not_allowed(true);
exit; exit;
} }
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$em = Database::getManager(); $em = Database::getManager();
$trackedExercise = $em /** @var TrackEExercises $trackedExercise */
->getRepository('ChamiloCoreBundle:TrackEExercises') $trackedExercise = $em->getRepository('ChamiloCoreBundle:TrackEExercises')->find($_REQUEST['id']);
->find(intval($_REQUEST['id']));
if ($trackedExercise->getExeUserId() != intval($_REQUEST['user']) || if (empty($trackedExercise)) {
$trackedExercise->getExeExoId() != intval($_REQUEST['exercise'])
) {
api_not_allowed(true);
exit; exit;
} }
$attempts = $em->getRepository('ChamiloCoreBundle:TrackEAttempt') $studentId = $trackedExercise->getExeUserId();
->findBy([ $exerciseId = $trackedExercise->getExeExoId();
'exeId' => $trackedExercise->getExeId(), $exeId = $trackedExercise->getExeId();
'userId' => $trackedExercise->getExeUserId(),
]);
$newResult = 0; if ($studentId != intval($_REQUEST['user']) ||
/** @var \Chamilo\CoreBundle\Entity\TrackEAttempt $attempt */ $exerciseId != intval($_REQUEST['exercise'])
foreach ($attempts as $attempt) { ) {
$questionId = $attempt->getQuestionId(); exit;
}
$question = $em->find('ChamiloCourseBundle:CQuizQuestion', $questionId); $questionList = $trackedExercise->getDataTracking();
if (!$question) { if (empty($questionList)) {
continue; exit;
} }
$answers = $em->getRepository('ChamiloCourseBundle:CQuizAnswer')->findBy([ $questionList = explode(',', $questionList);
'questionId' => $questionId,
'correct' => 1, $exercise = new Exercise($courseId);
]); $exercise->read($exerciseId);
$totalScore = 0;
$newMarks = 0; $totalWeight = 0;
foreach ($answers as $answer) {
if ($answer->getId() != $attempt->getAnswer()) { foreach ($questionList as $questionId) {
continue; $question = Question::read($questionId, $courseId);
$totalWeight += $question->selectWeighting();
// We're inside *one* question. Go through each possible answer for this question
if ($question->type === MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$result = $exercise->manage_answer(
$exeId,
$questionId,
[],
'exercise_result',
[],
false,
true,
false,
$exercise->selectPropagateNeg(),
[],
[],
true
);
} else {
$result = $exercise->manage_answer(
$exeId,
$questionId,
[],
'exercise_result',
[],
false,
true,
false,
$exercise->selectPropagateNeg(),
[],
[],
true
);
} }
$newMarks += $answer->getPonderation();
// Adding the new score.
$totalScore += $result['score'];
} }
$newResult += $newMarks; $remindList = $trackedExercise->getQuestionsToCheck();
$attempt->setMarks($newMarks); if (!empty($remindList)) {
$em->merge($attempt); $remindList = explode(',', $remindList);
} }
$trackedExercise->setScore($newResult); $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$sql = "UPDATE $table SET
exe_result = '$totalScore',
exe_weighting = '$totalWeight'
WHERE exe_id = $exeId";
Database::query($sql);
$em->merge($trackedExercise); echo $totalScore.'/'.$totalWeight;
$em->flush();

@ -670,7 +670,7 @@ function store_forumcategory($values, $courseInfo = [], $showMessage = true)
function store_forum($values, $courseInfo = [], $returnId = false) function store_forum($values, $courseInfo = [], $returnId = false)
{ {
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$course_id = $courseInfo['real_id']; $courseId = $courseInfo['real_id'];
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$group_id = api_get_group_id(); $group_id = api_get_group_id();
if (isset($values['group_id']) && !empty($values['group_id'])) { if (isset($values['group_id']) && !empty($values['group_id'])) {
@ -690,7 +690,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$sql = "SELECT MAX(forum_order) as sort_max $sql = "SELECT MAX(forum_order) as sort_max
FROM $table_forums FROM $table_forums
WHERE WHERE
c_id = $course_id AND c_id = $courseId AND
forum_category='".Database::escape_string($values['forum_category'])."'"; forum_category='".Database::escape_string($values['forum_category'])."'";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
@ -770,10 +770,62 @@ function store_forum($values, $courseInfo = [], $returnId = false)
delete_forum_image($values['forum_id']); delete_forum_image($values['forum_id']);
} }
// Move groups from one group to another
if (isset($values['group_forum'])) {
$forumData = get_forums($values['forum_id']);
$currentGroupId = $forumData['forum_of_group'];
if ($currentGroupId != $values['group_forum']) {
$threads = get_threads($values['forum_id']);
$toGroupId = 'NULL';
if (!empty($values['group_forum'])) {
$toGroupId = $values['group_forum'];
}
$tableItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
foreach ($threads as $thread) {
$sql = "UPDATE $tableItemProperty
SET to_group_id = $toGroupId
WHERE
tool = '".TOOL_FORUM_THREAD."' AND
ref = ".$thread['thread_id']." AND
c_id = ".$courseId;
Database::query($sql);
$posts = getPosts(
$forumData,
$thread['thread_id']
);
foreach ($posts as $post) {
$postId = $post['post_id'];
$attachMentList = getAllAttachment($postId);
if (!empty($attachMentList)) {
foreach ($attachMentList as $attachMent) {
$sql = "UPDATE $tableItemProperty
SET to_group_id = $toGroupId
WHERE
tool = '".TOOL_FORUM_ATTACH."' AND
ref = ".$attachMent['iid']." AND
c_id = ".$courseId;
Database::query($sql);
}
}
$sql = "UPDATE $tableItemProperty
SET to_group_id = $toGroupId
WHERE
tool = '".TOOL_FORUM_POST."' AND
ref = $postId AND
c_id = $courseId";
Database::query($sql);
}
}
}
}
Database::update( Database::update(
$table_forums, $table_forums,
$params, $params,
['c_id = ? AND forum_id = ?' => [$course_id, $values['forum_id']]] ['c_id = ? AND forum_id = ?' => [$courseId, $values['forum_id']]]
); );
api_item_property_update( api_item_property_update(
@ -792,7 +844,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$new_file_name = isset($new_file_name) ? $new_file_name : ''; $new_file_name = isset($new_file_name) ? $new_file_name : '';
} }
$params = [ $params = [
'c_id' => $course_id, 'c_id' => $courseId,
'forum_title' => $values['forum_title'], 'forum_title' => $values['forum_title'],
'forum_image' => $new_file_name, 'forum_image' => $new_file_name,
'forum_comment' => isset($values['forum_comment']) ? $values['forum_comment'] : null, 'forum_comment' => isset($values['forum_comment']) ? $values['forum_comment'] : null,
@ -1917,12 +1969,12 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
function get_threads($forum_id, $courseId = null, $sessionId = null) function get_threads($forum_id, $courseId = null, $sessionId = null)
{ {
$groupId = api_get_group_id(); $groupId = api_get_group_id();
$sessionId = $sessionId !== null ? intval($sessionId) : api_get_session_id(); $sessionId = $sessionId !== null ? (int) $sessionId : api_get_session_id();
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$table_users = Database::get_main_table(TABLE_MAIN_USER); $table_users = Database::get_main_table(TABLE_MAIN_USER);
$courseId = $courseId !== null ? intval($courseId) : api_get_course_int_id(); $courseId = $courseId !== null ? (int) $courseId : api_get_course_int_id();
$groupInfo = GroupManager::get_group_properties($groupId); $groupInfo = GroupManager::get_group_properties($groupId);
$groupCondition = ''; $groupCondition = '';
@ -3986,10 +4038,11 @@ function increase_thread_view($thread_id)
* *
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
* *
* @param int $threadId
* @param string $lastPostId * @param string $lastPostId
* @param string $post_date * @param string $post_date
*/ */
function updateThreadInfo($thread_id, $lastPostId, $post_date) function updateThreadInfo($threadId, $lastPostId, $post_date)
{ {
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -3999,7 +4052,7 @@ function updateThreadInfo($thread_id, $lastPostId, $post_date)
thread_date = '".Database::escape_string($post_date)."' thread_date = '".Database::escape_string($post_date)."'
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
thread_id='".Database::escape_string($thread_id)."'"; // this needs to be cleaned first thread_id='".Database::escape_string($threadId)."'"; // this needs to be cleaned first
Database::query($sql); Database::query($sql);
} }
@ -5043,7 +5096,7 @@ function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
/** /**
* Show a list with all the attachments according to the post's id. * Show a list with all the attachments according to the post's id.
* *
* @param int $post_id * @param int $postId
* *
* @return array with the post info * @return array with the post info
* *
@ -5051,15 +5104,20 @@ function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
* *
* @version avril 2008, dokeos 1.8.5 * @version avril 2008, dokeos 1.8.5
*/ */
function get_attachment($post_id) function get_attachment($postId)
{ {
$forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT); $table = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$row = []; $row = [];
$post_id = intval($post_id); $postId = (int) $postId;
if (empty($postId)) {
return [];
}
$sql = "SELECT iid, path, filename, comment $sql = "SELECT iid, path, filename, comment
FROM $forum_table_attachment FROM $table
WHERE c_id = $course_id AND post_id = $post_id"; WHERE c_id = $course_id AND post_id = $postId";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) != 0) { if (Database::num_rows($result) != 0) {
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
@ -5077,7 +5135,12 @@ function getAllAttachment($postId)
{ {
$forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT); $forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$postId = intval($postId); $postId = (int) $postId;
if (empty($postId)) {
return [];
}
$columns = ['iid', 'path', 'filename', 'comment']; $columns = ['iid', 'path', 'filename', 'comment'];
$conditions = [ $conditions = [
'where' => [ 'where' => [

@ -85,7 +85,7 @@ switch ($action) {
$currentUserInfo = api_get_user_info(); $currentUserInfo = api_get_user_info();
$message = isset($_POST['message']) ? $_POST['message'] : ''; $message = isset($_POST['message']) ? $_POST['message'] : '';
$subject = get_lang('NotificationCertificateSubject'); $subject = get_lang('NotificationCertificateSubject');
if (!empty($originalMessage)) { if (!empty($message)) {
foreach ($certificate_list as $index => $value) { foreach ($certificate_list as $index => $value) {
$userInfo = api_get_user_info($value['user_id']); $userInfo = api_get_user_info($value['user_id']);
if (empty($userInfo)) { if (empty($userInfo)) {

@ -1319,6 +1319,8 @@ class Agenda
break; break;
} }
$this->cleanEvents();
switch ($format) { switch ($format) {
case 'json': case 'json':
if (empty($this->events)) { if (empty($this->events)) {
@ -1337,6 +1339,25 @@ class Agenda
} }
} }
/**
* Clean events.
*
* @return bool
*/
public function cleanEvents()
{
if (empty($this->events)) {
return false;
}
foreach ($this->events as &$event) {
$event['description'] = Security::remove_XSS($event['description']);
$event['title'] = Security::remove_XSS($event['title']);
}
return true;
}
/** /**
* @param int $id * @param int $id
* @param int $minute_delta * @param int $minute_delta

@ -3401,7 +3401,7 @@ class CourseManager
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sessionId = (int) $sessionId; $sessionId = (int) $sessionId;
$user_id = (int) $user_id; $user_id = (int) $user_id;
$select = "SELECT DISTINCT *, c.id as real_id "; $select = "SELECT DISTINCT c.*, c.id as real_id ";
if ($getCount) { if ($getCount) {
$select = "SELECT COUNT(DISTINCT c.id) as count"; $select = "SELECT COUNT(DISTINCT c.id) as count";
@ -3440,9 +3440,7 @@ class CourseManager
// Teacher of course or teacher inside session // Teacher of course or teacher inside session
$whereConditions = " AND (cru.status = ".COURSEMANAGER." OR srcru.status = 2) "; $whereConditions = " AND (cru.status = ".COURSEMANAGER." OR srcru.status = 2) ";
} }
$courseList = SessionManager::get_course_list_by_session_id( $courseList = SessionManager::get_course_list_by_session_id($sessionId);
$sessionId
);
if (!empty($courseList)) { if (!empty($courseList)) {
$courseListToString = implode("','", array_keys($courseList)); $courseListToString = implode("','", array_keys($courseList));
$whereConditions .= " AND c.id IN ('".$courseListToString."')"; $whereConditions .= " AND c.id IN ('".$courseListToString."')";
@ -6078,10 +6076,10 @@ class CourseManager
switch ($type) { switch ($type) {
case 'GROUP': case 'GROUP':
$groupList[] = intval($id); $groupList[] = (int) $id;
break; break;
case 'USER': case 'USER':
$userList[] = intval($id); $userList[] = (int) $id;
break; break;
} }
} }

@ -216,7 +216,7 @@ function process_uploaded_file($uploaded_file, $show_output = true)
* @param bool $treat_spaces_as_hyphens * @param bool $treat_spaces_as_hyphens
* *
* So far only use for unzip_uploaded_document function. * So far only use for unzip_uploaded_document function.
* If no output wanted on success, set to false * If no output wanted on success, set to false.
* *
* @return string path of the saved file * @return string path of the saved file
*/ */

@ -6,6 +6,7 @@ use Chamilo\CoreBundle\Entity\Repository\ItemPropertyRepository;
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver; use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder; use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer; use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Entity\CItemProperty; use Chamilo\CourseBundle\Entity\CItemProperty;
use Chamilo\CourseBundle\Entity\CLp; use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\CourseBundle\Entity\CLpCategory; use Chamilo\CourseBundle\Entity\CLpCategory;
@ -2300,10 +2301,13 @@ class learnpath
if (!empty($row['audio'])) { if (!empty($row['audio'])) {
$list = $_SESSION['oLP']->get_toc(); $list = $_SESSION['oLP']->get_toc();
switch ($row['item_type']) {
case 'quiz':
$type_quiz = false; $type_quiz = false;
foreach ($list as $toc) { foreach ($list as $toc) {
if ($toc['id'] == $_SESSION['oLP']->current && $toc['type'] == 'quiz') { if ($toc['id'] == $_SESSION['oLP']->current) {
$type_quiz = true; $type_quiz = true;
} }
} }
@ -2314,7 +2318,12 @@ class learnpath
} else { } else {
$autostart_audio = $autostart; $autostart_audio = $autostart;
} }
} else { }
break;
case TOOL_READOUT_TEXT:;
$autostart_audio = 'false';
break;
default:
$autostart_audio = 'true'; $autostart_audio = 'true';
} }
@ -6253,7 +6262,7 @@ class learnpath
$title_cut = cut($arrLP[$i]['title'], self::MAX_LP_ITEM_TITLE_LENGTH); $title_cut = cut($arrLP[$i]['title'], self::MAX_LP_ITEM_TITLE_LENGTH);
// Link for the documents // Link for the documents
if ($arrLP[$i]['item_type'] == 'document') { if ($arrLP[$i]['item_type'] == 'document' || $arrLP[$i]['item_type'] == TOOL_READOUT_TEXT) {
$url = $mainUrl.'&action=view_item&mode=preview_document&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id; $url = $mainUrl.'&action=view_item&mode=preview_document&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id;
$title_cut = Display::url( $title_cut = Display::url(
$title_cut, $title_cut,
@ -6466,6 +6475,7 @@ class learnpath
switch ($arrLP[$i]['item_type']) { switch ($arrLP[$i]['item_type']) {
case TOOL_DOCUMENT: case TOOL_DOCUMENT:
case TOOL_LP_FINAL_ITEM: case TOOL_LP_FINAL_ITEM:
case TOOL_READOUT_TEXT:
$urlPreviewLink = $mainUrl.'&action=view_item&mode=preview_document&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id; $urlPreviewLink = $mainUrl.'&action=view_item&mode=preview_document&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id;
$previewIcon = Display::url( $previewIcon = Display::url(
$previewImage, $previewImage,
@ -7336,6 +7346,7 @@ class learnpath
$return .= $this->getSavedFinalItem(); $return .= $this->getSavedFinalItem();
break; break;
case TOOL_DOCUMENT: case TOOL_DOCUMENT:
case TOOL_READOUT_TEXT:
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$sql_doc = "SELECT path FROM ".$tbl_doc." $sql_doc = "SELECT path FROM ".$tbl_doc."
WHERE c_id = ".$course_id." AND iid = ".intval($row['path']); WHERE c_id = ".$course_id." AND iid = ".intval($row['path']);
@ -7439,6 +7450,27 @@ class learnpath
$row_step $row_step
); );
break; break;
case TOOL_READOUT_TEXT:
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$sql = "SELECT lp.*, doc.path as dir
FROM $tbl_lp_item as lp
LEFT JOIN $tbl_doc as doc
ON (doc.iid = lp.path AND lp.c_id = doc.c_id)
WHERE
doc.c_id = $course_id AND
lp.iid = ".$item_id;
$res_step = Database::query($sql);
$row_step = Database::fetch_array($res_step, 'ASSOC');
$return .= $this->display_manipulate(
$item_id,
$row['item_type']
);
$return .= $this->displayFrmReadOutText(
'edit',
$item_id,
$row_step
);
break;
case TOOL_LINK: case TOOL_LINK:
$link_id = (string) $row['path']; $link_id = (string) $row['path'];
if (ctype_digit($link_id)) { if (ctype_digit($link_id)) {
@ -9104,6 +9136,473 @@ class learnpath
return $form->returnForm(); return $form->returnForm();
} }
/**
* Returns the form to update or create a read-out text.
*
* @param string $action "add" or "edit"
* @param int $id ID of the lp_item (if already exists)
* @param mixed $extra_info Integer if document ID, string if info ('new')
*
* @throws Exception
* @throws HTML_QuickForm_Error
*
* @return string HTML form
*/
public function displayFrmReadOutText($action = 'add', $id = 0, $extra_info = 'new')
{
$course_id = api_get_course_int_id();
$_course = api_get_course_info();
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$no_display_edit_textarea = false;
$item_description = '';
//If action==edit document
//We don't display the document form if it's not an editable document (html or txt file)
if ($action == 'edit') {
if (is_array($extra_info)) {
$path_parts = pathinfo($extra_info['dir']);
if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") {
$no_display_edit_textarea = true;
}
}
}
$no_display_add = false;
if ($id != 0 && is_array($extra_info)) {
$item_title = stripslashes($extra_info['title']);
$item_description = stripslashes($extra_info['description']);
$item_terms = stripslashes($extra_info['terms']);
if (empty($item_title)) {
$path_parts = pathinfo($extra_info['path']);
$item_title = stripslashes($path_parts['filename']);
}
} elseif (is_numeric($extra_info)) {
$sql = "SELECT path, title FROM $tbl_doc WHERE c_id = ".$course_id." AND iid = ".intval($extra_info);
$result = Database::query($sql);
$row = Database::fetch_array($result);
$item_title = $row['title'];
$item_title = str_replace('_', ' ', $item_title);
if (empty($item_title)) {
$path_parts = pathinfo($row['path']);
$item_title = stripslashes($path_parts['filename']);
}
} else {
$item_title = '';
$item_description = '';
}
if ($id != 0 && is_array($extra_info)) {
$parent = $extra_info['parent_item_id'];
} else {
$parent = 0;
}
$sql = "SELECT * FROM $tbl_lp_item WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
$result = Database::query($sql);
$arrLP = [];
while ($row = Database::fetch_array($result)) {
$arrLP[] = [
'id' => $row['iid'],
'item_type' => $row['item_type'],
'title' => $row['title'],
'path' => $row['path'],
'description' => $row['description'],
'parent_item_id' => $row['parent_item_id'],
'previous_item_id' => $row['previous_item_id'],
'next_item_id' => $row['next_item_id'],
'display_order' => $row['display_order'],
'max_score' => $row['max_score'],
'min_score' => $row['min_score'],
'mastery_score' => $row['mastery_score'],
'prerequisite' => $row['prerequisite'],
];
}
$this->tree_array($arrLP);
$arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
unset($this->arrMenu);
if ($action == 'add') {
$formHeader = get_lang('CreateTheDocument');
} else {
$formHeader = get_lang('EditTheCurrentDocument');
}
if ('edit' === $action) {
$urlAudioIcon = Display::url(
Display::return_icon('audio.png', get_lang('CreateReadOutText'), [], ICON_SIZE_TINY),
api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&lp_id='.$this->lp_id.'&'
.http_build_query(['view' => 'build', 'id' => $id, 'action' => 'add_audio'])
);
} else {
$urlAudioIcon = Display::return_icon('audio.png', get_lang('CreateReadOutText'), [], ICON_SIZE_TINY);
}
$form = new FormValidator(
'frm_add_reading',
'POST',
$this->getCurrentBuildingModeURL(),
'',
['enctype' => 'multipart/form-data']
);
$form->addHeader($formHeader);
$form->addHtml(
Display::return_message(
sprintf(get_lang('FrmReadOutTextIntro'), $urlAudioIcon),
'normal',
false
)
);
$defaults['title'] = !empty($item_title) ? Security::remove_XSS($item_title) : '';
$defaults['description'] = $item_description;
$data = $this->generate_lp_folder($_course);
if ($action != 'edit') {
$folders = DocumentManager::get_all_document_folders($_course, 0, true);
DocumentManager::build_directory_selector(
$folders,
'',
[],
true,
$form,
'directory_parent_id'
);
}
if (isset($data['id'])) {
$defaults['directory_parent_id'] = $data['id'];
}
$form->addElement(
'text',
'title',
get_lang('Title')
);
$form->applyFilter('title', 'trim');
$form->applyFilter('title', 'html_filter');
$arrHide[0]['value'] = $this->name;
$arrHide[0]['padding'] = 20;
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if ($arrLP[$i]['item_type'] == 'dir' &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
}
} else {
if ($arrLP[$i]['item_type'] == 'dir') {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
}
}
}
$parent_select = $form->addSelect(
'parent',
get_lang('Parent'),
[],
['onchange' => "javascript: load_cbo(this.value, 'frm_add_reading_previous');"]
);
$my_count = 0;
foreach ($arrHide as $key => $value) {
if ($my_count != 0) {
// The LP name is also the first section and is not in the same charset like the other sections.
$value['value'] = Security::remove_XSS($value['value']);
$parent_select->addOption(
$value['value'],
$key,
'style="padding-left:'.$value['padding'].'px;"'
);
} else {
$value['value'] = Security::remove_XSS($value['value']);
$parent_select->addOption(
$value['value'],
$key,
'style="padding-left:'.$value['padding'].'px;"'
);
}
$my_count++;
}
if (!empty($id)) {
$parent_select->setSelected($parent);
} else {
$parent_item_id = Session::read('parent_item_id', 0);
$parent_select->setSelected($parent_item_id);
}
if (is_array($arrLP)) {
reset($arrLP);
}
$arrHide = [];
$s_selected_position = null;
// POSITION
$lastPosition = null;
for ($i = 0; $i < count($arrLP); $i++) {
if (($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) ||
$arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM
) {
if ((isset($extra_info['previous_item_id']) &&
$extra_info['previous_item_id'] == $arrLP[$i]['id']) || $action == 'add'
) {
$s_selected_position = $arrLP[$i]['id'];
}
$arrHide[$arrLP[$i]['id']]['value'] = get_lang('After').' "'.$arrLP[$i]['title'].'"';
}
$lastPosition = $arrLP[$i]['id'];
}
if (empty($s_selected_position)) {
$s_selected_position = $lastPosition;
}
$position = $form->addSelect(
'previous',
get_lang('Position'),
[]
);
$position->addOption(get_lang('FirstPosition'), 0);
foreach ($arrHide as $key => $value) {
$padding = isset($value['padding']) ? $value['padding'] : 20;
$position->addOption(
$value['value'],
$key,
'style="padding-left:'.$padding.'px;"'
);
}
$position->setSelected($s_selected_position);
if (is_array($arrLP)) {
reset($arrLP);
}
$arrHide = [];
for ($i = 0; $i < count($arrLP); $i++) {
if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir' &&
$arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM
) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
}
}
if (!$no_display_add) {
$item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
$edit = isset($_GET['edit']) ? $_GET['edit'] : null;
if ($extra_info == 'new' || $item_type == TOOL_READOUT_TEXT || $edit == 'true') {
if (!$no_display_edit_textarea) {
$content = '';
if (isset($_POST['content'])) {
$content = stripslashes($_POST['content']);
} elseif (is_array($extra_info)) {
$content = $this->display_document($extra_info['path'], false, false);
} elseif (is_numeric($extra_info)) {
$content = $this->display_document($extra_info, false, false);
}
// A new document, it is in the root of the repository.
if (is_array($extra_info) && $extra_info != 'new') {
} else {
$this->generate_lp_folder($_course);
}
if ($_GET['action'] == 'add_item') {
$text = get_lang('LPCreateDocument');
} else {
$text = get_lang('SaveDocument');
}
$form->addTextarea('content_lp', get_lang('Content'), ['rows' => 20]);
$form
->defaultRenderer()
->setElementTemplate($form->getDefaultElementTemplate(), 'content_lp');
$form->addButtonSave($text, 'submit_button');
$defaults['content_lp'] = $content;
}
} elseif (is_numeric($extra_info)) {
$form->addButtonSave(get_lang('SaveDocument'), 'submit_button');
$return = $this->display_document($extra_info, true, true, true);
$form->addElement('html', $return);
}
}
if (is_numeric($extra_info)) {
$form->addElement('hidden', 'path', $extra_info);
} elseif (is_array($extra_info)) {
$form->addElement('hidden', 'path', $extra_info['path']);
}
$form->addElement('hidden', 'type', TOOL_READOUT_TEXT);
$form->addElement('hidden', 'post_time', time());
$form->setDefaults($defaults);
return $form->returnForm();
}
/**
* @param array $courseInfo
* @param string $content
* @param string $title
* @param int $parentId
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
*
* @return int
*/
public function createReadOutText($courseInfo, $content = '', $title = '', $parentId = 0)
{
$creatorId = api_get_user_id();
$sessionId = api_get_session_id();
// Generates folder
$result = $this->generate_lp_folder($courseInfo);
$dir = $result['dir'];
if (empty($parentId) || $parentId == '/') {
$postDir = isset($_POST['dir']) ? $_POST['dir'] : $dir;
$dir = isset($_GET['dir']) ? $_GET['dir'] : $postDir; // Please, do not modify this dirname formatting.
if ($parentId === '/') {
$dir = '/';
}
// Please, do not modify this dirname formatting.
if (strstr($dir, '..')) {
$dir = '/';
}
if (!empty($dir[0]) && $dir[0] == '.') {
$dir = substr($dir, 1);
}
if (!empty($dir[0]) && $dir[0] != '/') {
$dir = '/'.$dir;
}
if (isset($dir[strlen($dir) - 1]) && $dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
} else {
$parentInfo = DocumentManager::get_document_data_by_id(
$parentId,
$courseInfo['code']
);
if (!empty($parentInfo)) {
$dir = $parentInfo['path'].'/';
}
}
$filepath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/'.$dir;
if (!is_dir($filepath)) {
$dir = '/';
$filepath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/'.$dir;
}
$originalTitle = !empty($title) ? $title : $_POST['title'];
if (!empty($title)) {
$title = api_replace_dangerous_char(stripslashes($title));
} else {
$title = api_replace_dangerous_char(stripslashes($_POST['title']));
}
$title = disable_dangerous_file($title);
$filename = $title;
$content = !empty($content) ? $content : $_POST['content_lp'];
$tmpFileName = $filename;
$i = 0;
while (file_exists($filepath.$tmpFileName.'.html')) {
$tmpFileName = $filename.'_'.++$i;
}
$filename = $tmpFileName.'.html';
$content = stripslashes($content);
if (file_exists($filepath.$filename)) {
return 0;
}
$putContent = file_put_contents($filepath.$filename, $content);
if ($putContent === false) {
return 0;
}
$fileSize = filesize($filepath.$filename);
$saveFilePath = $dir.$filename;
$documentId = add_document(
$courseInfo,
$saveFilePath,
'file',
$fileSize,
$tmpFileName,
'',
0, //readonly
true,
null,
$sessionId,
$creatorId
);
if (!$documentId) {
return 0;
}
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$documentId,
'DocumentAdded',
$creatorId,
null,
null,
null,
null,
$sessionId
);
$newComment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$newTitle = $originalTitle;
if ($newComment || $newTitle) {
$em = Database::getManager();
/** @var CDocument $doc */
$doc = $em->find('ChamiloCourseBundle:CDocument', $documentId);
if ($newComment) {
$doc->setComment($newComment);
}
if ($newTitle) {
$doc->setTitle($newTitle);
}
$em->persist($doc);
$em->flush();
}
return $documentId;
}
/** /**
* Return HTML form to add/edit a link item. * Return HTML form to add/edit a link item.
* *
@ -10020,6 +10519,7 @@ class learnpath
$headers = [ $headers = [
get_lang('Files'), get_lang('Files'),
get_lang('CreateTheDocument'), get_lang('CreateTheDocument'),
get_lang('CreateReadOutText'),
get_lang('Upload'), get_lang('Upload'),
]; ];
@ -10091,9 +10591,10 @@ class learnpath
$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath='; $url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath=';
$form->addMultipleUpload($url); $form->addMultipleUpload($url);
$new = $this->display_document_form('add', 0); $new = $this->display_document_form('add', 0);
$frmReadOutText = $this->displayFrmReadOutText('add');
$tabs = Display::tabs( $tabs = Display::tabs(
$headers, $headers,
[$documentTree, $new, $form->returnForm()], [$documentTree, $new, $frmReadOutText, $form->returnForm()],
'subtab' 'subtab'
); );
@ -12890,6 +13391,9 @@ EOD;
return $main_dir_path.'forum/viewthread.php?post='.$id.'&thread='.$myrow['thread_id'].'&forum=' return $main_dir_path.'forum/viewthread.php?post='.$id.'&thread='.$myrow['thread_id'].'&forum='
.$myrow['forum_id'].'&lp=true&'.$extraParams; .$myrow['forum_id'].'&lp=true&'.$extraParams;
case TOOL_READOUT_TEXT:
return api_get_path(WEB_CODE_PATH).'lp/readout_text.php?&id='.$id.'&lp_id='.$learningPathId.'&'
.$extraParams;
case TOOL_DOCUMENT: case TOOL_DOCUMENT:
$document = $em $document = $em
->getRepository('ChamiloCourseBundle:CDocument') ->getRepository('ChamiloCourseBundle:CDocument')

@ -2451,6 +2451,7 @@ class learnpathItem
) { ) {
/** @var learnpathItem $itemToCheck */ /** @var learnpathItem $itemToCheck */
$itemToCheck = $items[$refs_list[$prereqs_string]]; $itemToCheck = $items[$refs_list[$prereqs_string]];
if ($itemToCheck->type == 'quiz') { if ($itemToCheck->type == 'quiz') {
// 1. Checking the status in current items. // 1. Checking the status in current items.
$status = $itemToCheck->get_status(true); $status = $itemToCheck->get_status(true);

@ -85,7 +85,7 @@ function save_item(
if (!is_a($myLP, 'learnpath')) { if (!is_a($myLP, 'learnpath')) {
if ($debug) { if ($debug) {
error_log("mylp variable is not an learnpath object"); error_log('mylp variable is not an learnpath object');
} }
return null; return null;
@ -146,7 +146,7 @@ function save_item(
} }
} else { } else {
if ($debug > 1) { if ($debug > 1) {
error_log("Score not updated"); error_log('Score not updated');
} }
} }
@ -164,7 +164,7 @@ function save_item(
} }
} else { } else {
if ($debug > 1) { if ($debug > 1) {
error_log("Status not updated"); error_log('Status not updated');
} }
} }
@ -248,8 +248,14 @@ function save_item(
) { ) {
if ($score >= $masteryScore) { if ($score >= $masteryScore) {
$myLPI->set_status('passed'); $myLPI->set_status('passed');
if ($debug) {
error_log('Set status: passed');
}
} else { } else {
$myLPI->set_status('failed'); $myLPI->set_status('failed');
if ($debug) {
error_log('Set status: failed');
}
} }
$statusIsSet = true; $statusIsSet = true;
} }
@ -261,6 +267,9 @@ function save_item(
*/ */
if (!$statusIsSet && !$masteryScore && !$statusSignalReceived) { if (!$statusIsSet && !$masteryScore && !$statusSignalReceived) {
if (!empty($status)) { if (!empty($status)) {
if ($debug) {
error_log("Set status: $status because: statusSignalReceived ");
}
$myLPI->set_status($status); $myLPI->set_status($status);
$statusIsSet = true; $statusIsSet = true;
} }
@ -276,6 +285,9 @@ function save_item(
if (!$statusIsSet && $credit == 'no-credit' && !$statusSignalReceived) { if (!$statusIsSet && $credit == 'no-credit' && !$statusSignalReceived) {
$mode = $myLPI->get_lesson_mode(); $mode = $myLPI->get_lesson_mode();
if ($mode == 'browse' && $status == 'browsed') { if ($mode == 'browse' && $status == 'browsed') {
if ($debug) {
error_log("Set status: $status because mode browse");
}
$myLPI->set_status($status); $myLPI->set_status($status);
$statusIsSet = true; $statusIsSet = true;
} }
@ -319,6 +331,9 @@ function save_item(
$myStatus = 'failed'; $myStatus = 'failed';
} }
} }
if ($debug) {
error_log("Set status: $myStatus because lmsFinish || userNavigatesAway");
}
$myLPI->set_status($myStatus); $myLPI->set_status($myStatus);
$statusIsSet = true; $statusIsSet = true;
} }
@ -410,6 +425,10 @@ function save_item(
$myStatusInDB != 'failed' $myStatusInDB != 'failed'
) { ) {
$myStatusInMemory = $myLPI->get_status(false); $myStatusInMemory = $myLPI->get_status(false);
if ($debug) {
error_log("myStatusInMemory: $myStatusInMemory");
}
if ($myStatusInMemory != $myStatusInDB) { if ($myStatusInMemory != $myStatusInDB) {
$myStatus = $myStatusInMemory; $myStatus = $myStatusInMemory;
} else { } else {

@ -451,6 +451,27 @@ switch ($action) {
$description, $description,
$prerequisites $prerequisites
); );
} elseif ($_POST['type'] == TOOL_READOUT_TEXT) {
if (isset($_POST['path']) && $_GET['edit'] != 'true') {
$document_id = $_POST['path'];
} else {
$document_id = $_SESSION['oLP']->createReadOutText(
$_course,
$_POST['content_lp'],
$_POST['title'],
$directoryParentId
);
}
$new_item_id = $_SESSION['oLP']->add_item(
$parent,
$previous,
TOOL_READOUT_TEXT,
$document_id,
$post_title,
$description,
$prerequisites
);
} else { } else {
// For all other item types than documents, // For all other item types than documents,
// load the item using the item type and path rather than its ID. // load the item using the item type and path rather than its ID.

@ -50,17 +50,14 @@ if ($myLP) {
$progress_bar = $myLP->getProgressBar(); $progress_bar = $myLP->getProgressBar();
$navigation_bar = $myLP->get_navigation_bar(); $navigation_bar = $myLP->get_navigation_bar();
$mediaplayer = $myLP->get_mediaplayer($lpItemId, $autostart); $mediaplayer = $myLP->get_mediaplayer($lpItemId, $autostart);
if ($mediaplayer) {
echo $mediaplayer;
echo "<script>
$(function() {
jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer();
});
</script>";
} }
session_write_close();
?>
<script>
$(document).ready(function() {
jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer({
success: function(player, node) {
} }
}); session_write_close();
});
</script>
<span>
<?php echo !empty($mediaplayer) ? $mediaplayer : '&nbsp;'; ?>
</span>

@ -303,7 +303,7 @@ function LMSInitialize() {
dataType: 'script', dataType: 'script',
async: false, async: false,
success:function(data) { success:function(data) {
jQuery("video:not(.skip), audio:not(.skip)").mediaelementplayer(); $('video:not(.skip), audio:not(.skip)').mediaelementplayer();
} }
}); });
@ -388,7 +388,6 @@ function LMSGetValue(param) {
olms.G_LastError = G_NoError; olms.G_LastError = G_NoError;
olms.G_LastErrorMessage = 'No error'; olms.G_LastErrorMessage = 'No error';
var result = ''; var result = '';
// the LMSInitialize is missing // the LMSInitialize is missing
if (olms.lms_initialized == 0) { if (olms.lms_initialized == 0) {
if (param == 'cmi.core.score.raw') { if (param == 'cmi.core.score.raw') {
@ -612,7 +611,9 @@ function LMSGetValue(param) {
result = ''; result = '';
return result; return result;
} }
logit_scorm("LMSGetValue\n\t('"+param+"') returned '"+result+"'",1);
logit_scorm("LMSGetValue ('"+param+"') returned '"+result+"'",1);
return result; return result;
} }
@ -843,7 +844,7 @@ function LMSSetValue(param, val) {
echo " var mycommit = LMSCommit('force');"; echo " var mycommit = LMSCommit('force');";
} }
?> ?>
return(return_value); return return_value;
} }
/** /**
@ -862,7 +863,7 @@ function savedata(item_id) {
// Status is NOT modified here see the lp_ajax_save_item.php file // Status is NOT modified here see the lp_ajax_save_item.php file
if (olms.lesson_status != '') { if (olms.lesson_status != '') {
olms.updatable_vars_list['cmi.core.lesson_status'] = true; //olms.updatable_vars_list['cmi.core.lesson_status'] = true;
} }
old_item_id = olms.info_lms_item[0]; old_item_id = olms.info_lms_item[0];
@ -1435,6 +1436,17 @@ function reinit_updatable_vars_list() {
* item (like 'next', 'previous', 'first' or 'last') or the id to the next item * item (like 'next', 'previous', 'first' or 'last') or the id to the next item
*/ */
function switch_item(current_item, next_item) { function switch_item(current_item, next_item) {
if (olms.lms_initialized == 0) {
// Fix error when flash is not loaded and SCO is not started BT#14944
olms.G_LastError = G_NotInitialized;
olms.G_LastErrorMessage = G_NotInitializedMessage;
logit_scorm('Error '+ G_NotInitialized + G_NotInitializedMessage, 0);
window.location.reload(false);
return false;
}
olms.switch_finished = 0; //only changed back once LMSInitialize() happens
// backup these params // backup these params
var orig_current_item = current_item; var orig_current_item = current_item;
var orig_next_item = next_item; var orig_next_item = next_item;
@ -1519,7 +1531,9 @@ function switch_item(current_item, next_item){
1, 1,
olms.statusSignalReceived olms.statusSignalReceived
); );
reinit_updatable_vars_list(); reinit_updatable_vars_list();
xajax_switch_item_toc( xajax_switch_item_toc(
olms.lms_lp_id, olms.lms_lp_id,
olms.lms_user_id, olms.lms_user_id,
@ -1680,7 +1694,6 @@ function switch_item(current_item, next_item){
} }
} }
}); });
olms.switch_finished = 0; //only changed back once LMSInitialize() happens
loadForumThread(olms.lms_lp_id, next_item); loadForumThread(olms.lms_lp_id, next_item);
checkCurrentItemPosition(olms.lms_item_id); checkCurrentItemPosition(olms.lms_item_id);

@ -34,6 +34,10 @@ if (empty($student_id)) {
// user info // user info
$user_info = api_get_user_info($student_id); $user_info = api_get_user_info($student_id);
if (empty($user_info)) {
api_not_allowed(true);
}
$allowToQualify = api_is_allowed_to_edit(null, true) || $allowToQualify = api_is_allowed_to_edit(null, true) ||
api_is_course_tutor() || api_is_course_tutor() ||
api_is_session_admin() || api_is_session_admin() ||
@ -354,9 +358,10 @@ $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_
// RRHH or session admin // RRHH or session admin
if (api_is_session_admin() || api_is_drh()) { if (api_is_session_admin() || api_is_drh()) {
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$session_by_session_admin = SessionManager::get_sessions_followed_by_drh( if (!empty($courses)) {
api_get_user_id() $courses = array_column($courses, 'real_id');
); }
$session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
if (!empty($session_by_session_admin)) { if (!empty($session_by_session_admin)) {
foreach ($session_by_session_admin as $session_coached_by_user) { foreach ($session_by_session_admin as $session_coached_by_user) {

@ -13,15 +13,15 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$show_full_profile = true; $show_full_profile = true;
// social tab // social tab
$this_section = SECTION_SOCIAL;
Session::erase('this_section'); Session::erase('this_section');
$this_section = SECTION_SOCIAL;
api_block_anonymous_users(); if (api_get_setting('allow_social_tool') !== 'true') {
if (api_get_setting('allow_social_tool') != 'true') {
$url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; $url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
header('Location: '.$url); header('Location: '.$url);
exit; exit;

@ -17,6 +17,8 @@ if (api_get_setting('allow_my_files') === 'false') {
api_not_allowed(true); api_not_allowed(true);
} }
$this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script> <script>
function denied_friend (element_input) { function denied_friend (element_input) {

@ -48,10 +48,10 @@ class ch_multipleresponse extends survey_question
$questionData = [], $questionData = [],
$answers = [] $answers = []
) { ) {
if ($questionData['display'] == 'vertical') {
$class = 'checkbox ';
} else {
$class = 'checkbox-inline'; $class = 'checkbox-inline';
$labelClass = 'checkbox-inline';
if ($questionData['display'] == 'vertical') {
$class = 'checkbox-vertical';
} }
$name = 'question'.$questionData['question_id']; $name = 'question'.$questionData['question_id'];
@ -60,7 +60,7 @@ class ch_multipleresponse extends survey_question
$name, $name,
null, null,
$questionData['options'], $questionData['options'],
['checkbox-class' => $class, 'label-class' => $class] ['checkbox-class' => $class, 'label-class' => $labelClass]
); );
$defaults = []; $defaults = [];

@ -125,7 +125,7 @@ if ($action == 'overview') {
]; ];
switch ($action) { switch ($action) {
case 'questionreport': case 'questionreport':
$singlePage = isset($_GET['single_page']) ? intval($_GET['single_page']) : 0; $singlePage = isset($_GET['single_page']) ? (int) $_GET['single_page'] : 0;
$tool_name = $singlePage ? get_lang('QuestionsOverallReport') : get_lang('DetailedReportByQuestion'); $tool_name = $singlePage ? get_lang('QuestionsOverallReport') : get_lang('DetailedReportByQuestion');
break; break;
case 'userreport': case 'userreport':

@ -235,7 +235,7 @@ class SurveyUtil
$questions_data = []; $questions_data = [];
foreach ($my_temp_questions_data as $key => &$value) { foreach ($my_temp_questions_data as $key => &$value) {
if ($value['type'] != 'comment' && $value['type'] != 'pagebreak') { if ($value['type'] != 'pagebreak') {
$questions_data[$value['sort']] = $value; $questions_data[$value['sort']] = $value;
} }
} }
@ -518,19 +518,19 @@ class SurveyUtil
*/ */
public static function display_question_report($survey_data) public static function display_question_report($survey_data)
{ {
$singlePage = isset($_GET['single_page']) ? intval($_GET['single_page']) : 0; $singlePage = isset($_GET['single_page']) ? (int) $_GET['single_page'] : 0;
// Determining the offset of the sql statement (the n-th question of the survey)
$offset = !isset($_GET['question']) ? 0 : (int) $_GET['question'];
$currentQuestion = isset($_GET['question']) ? (int) $_GET['question'] : 0;
$surveyId = (int) $_GET['survey_id'];
$action = Security::remove_XSS($_GET['action']);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Database table definitions // Database table definitions
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
// Determining the offset of the sql statement (the n-th question of the survey)
$offset = !isset($_GET['question']) ? 0 : intval($_GET['question']);
$currentQuestion = isset($_GET['question']) ? intval($_GET['question']) : 0;
$questions = []; $questions = [];
$surveyId = intval($_GET['survey_id']);
$action = Security::remove_XSS($_GET['action']);
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'&'.api_get_cidreq().'">'. echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'&'.api_get_cidreq().'">'.
@ -574,9 +574,8 @@ class SurveyUtil
$sql = "SELECT * FROM $table_survey_question $sql = "SELECT * FROM $table_survey_question
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".intval($_GET['survey_id'])."' AND survey_id='".$surveyId."' AND
type <>'pagebreak' AND type <>'pagebreak'
type <>'comment'
ORDER BY sort ASC ORDER BY sort ASC
$limitStatement"; $limitStatement";
$result = Database::query($sql); $result = Database::query($sql);
@ -584,10 +583,10 @@ class SurveyUtil
$questions[$row['question_id']] = $row; $questions[$row['question_id']] = $row;
} }
} }
foreach ($questions as $question) { foreach ($questions as $question) {
$chartData = []; $chartData = [];
$options = []; $options = [];
$questionId = (int) $question['question_id'];
echo '<div class="title-question">'; echo '<div class="title-question">';
echo strip_tags(isset($question['survey_question']) ? $question['survey_question'] : null); echo strip_tags(isset($question['survey_question']) ? $question['survey_question'] : null);
echo '</div>'; echo '</div>';
@ -595,13 +594,13 @@ class SurveyUtil
if ($question['type'] == 'score') { if ($question['type'] == 'score') {
/** @todo This function should return the options as this is needed further in the code */ /** @todo This function should return the options as this is needed further in the code */
$options = self::display_question_report_score($survey_data, $question, $offset); $options = self::display_question_report_score($survey_data, $question, $offset);
} elseif ($question['type'] == 'open') { } elseif ($question['type'] == 'open' || $question['type'] == 'comment') {
/** @todo Also get the user who has answered this */ /** @todo Also get the user who has answered this */
$sql = "SELECT * FROM $table_survey_answer $sql = "SELECT * FROM $table_survey_answer
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".intval($_GET['survey_id'])."' AND survey_id='".$surveyId."' AND
question_id = '".intval($question['question_id'])."'"; question_id = '".$questionId."'";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
echo $row['option_id'].'<hr noshade="noshade" size="1" />'; echo $row['option_id'].'<hr noshade="noshade" size="1" />';
@ -611,8 +610,8 @@ class SurveyUtil
$sql = "SELECT * FROM $table_survey_question_option $sql = "SELECT * FROM $table_survey_question_option
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".intval($_GET['survey_id'])."' survey_id='".$surveyId."'
AND question_id = '".intval($question['question_id'])."' AND question_id = '".$questionId."'
ORDER BY sort ASC"; ORDER BY sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -622,8 +621,8 @@ class SurveyUtil
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer $sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".intval($_GET['survey_id'])."' survey_id='".$surveyId."'
AND question_id = '".intval($question['question_id'])."' AND question_id = '".$questionId."'
GROUP BY option_id, value"; GROUP BY option_id, value";
$result = Database::query($sql); $result = Database::query($sql);
$number_of_answers = []; $number_of_answers = [];
@ -714,6 +713,7 @@ class SurveyUtil
echo '</div>'; echo '</div>';
} }
} }
if (isset($_GET['viewoption'])) { if (isset($_GET['viewoption'])) {
echo '<div class="answered-people">'; echo '<div class="answered-people">';
echo '<h4>'.get_lang('PeopleWhoAnswered').': ' echo '<h4>'.get_lang('PeopleWhoAnswered').': '
@ -865,7 +865,7 @@ class SurveyUtil
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$surveyId = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : 0; $surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
// Actions bar // Actions bar
@ -940,14 +940,17 @@ class SurveyUtil
} }
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT q.question_id, q.type, q.survey_question, count(o.question_option_id) as number_of_options $sql = "SELECT
q.question_id,
q.type,
q.survey_question,
count(o.question_option_id) as number_of_options
FROM $table_survey_question q FROM $table_survey_question q
LEFT JOIN $table_survey_question_option o LEFT JOIN $table_survey_question_option o
ON q.question_id = o.question_id ON q.question_id = o.question_id AND q.c_id = o.c_id
WHERE WHERE
q.survey_id = '".$surveyId."' AND q.survey_id = '".$surveyId."' AND
q.c_id = $course_id AND q.c_id = $course_id
o.c_id = $course_id
GROUP BY q.question_id GROUP BY q.question_id
ORDER BY q.sort ASC"; ORDER BY q.sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
@ -960,15 +963,12 @@ class SurveyUtil
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) (is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter']))
) { ) {
// We do not show comment and pagebreak question types // We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['type'] != 'pagebreak') {
echo ' <th'; echo ' <th';
// <hub> modified tst to include percentage
if ($row['number_of_options'] > 0 && $row['type'] != 'percentage') { if ($row['number_of_options'] > 0 && $row['type'] != 'percentage') {
// </hub>
echo ' colspan="'.$row['number_of_options'].'"'; echo ' colspan="'.$row['number_of_options'].'"';
} }
echo '>'; echo '>';
echo '<label><input type="checkbox" name="questions_filter[]" value="'.$row['question_id'] echo '<label><input type="checkbox" name="questions_filter[]" value="'.$row['question_id']
.'" checked="checked"/> '; .'" checked="checked"/> ';
echo $row['survey_question']; echo $row['survey_question'];
@ -985,7 +985,8 @@ class SurveyUtil
echo ' <th>&nbsp;</th>'; // the user column echo ' <th>&nbsp;</th>'; // the user column
if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] || if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] ||
isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])) { isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])
) {
//show the fields names for user fields //show the fields names for user fields
foreach ($extra_user_fields as &$field) { foreach ($extra_user_fields as &$field) {
echo '<th>'.$field[3].'</th>'; echo '<th>'.$field[3].'</th>';
@ -994,17 +995,21 @@ class SurveyUtil
// cells with option (none for open question) // cells with option (none for open question)
$sql = "SELECT $sql = "SELECT
sq.question_id, sq.survey_id, sq.question_id,
sq.survey_question, sq.display, sq.survey_id,
sq.sort, sq.type, sqo.question_option_id, sq.survey_question,
sqo.option_text, sqo.sort as option_sort sq.display,
sq.sort,
sq.type,
sqo.question_option_id,
sqo.option_text,
sqo.sort as option_sort
FROM $table_survey_question sq FROM $table_survey_question sq
LEFT JOIN $table_survey_question_option sqo LEFT JOIN $table_survey_question_option sqo
ON sq.question_id = sqo.question_id ON sq.question_id = sqo.question_id AND sq.c_id = sqo.c_id
WHERE WHERE
sq.survey_id = '".$surveyId."' AND sq.survey_id = '".$surveyId."' AND
sq.c_id = $course_id AND sq.c_id = $course_id
sqo.c_id = $course_id
ORDER BY sq.sort ASC, sqo.sort ASC"; ORDER BY sq.sort ASC, sqo.sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
@ -1019,8 +1024,7 @@ class SurveyUtil
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) (is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter']))
) { ) {
// <hub> modif 05-05-2010 // <hub> modif 05-05-2010
// we do not show comment and pagebreak question types if ($row['type'] == 'open' || $row['type'] == 'comment') {
if ($row['type'] == 'open') {
echo '<th>&nbsp;-&nbsp;</th>'; echo '<th>&nbsp;-&nbsp;</th>';
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
$display_percentage_header = 1; $display_percentage_header = 1;
@ -1030,15 +1034,13 @@ class SurveyUtil
$display_percentage_header = 0; $display_percentage_header = 0;
} elseif ($row['type'] == 'percentage') { } elseif ($row['type'] == 'percentage') {
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
} elseif ($row['type'] != 'comment' && $row['type'] != 'pagebreak' && $row['type'] != 'percentage') { } elseif ($row['type'] != 'pagebreak' && $row['type'] != 'percentage') {
echo '<th>'; echo '<th>';
echo $row['option_text']; echo $row['option_text'];
echo '</th>'; echo '</th>';
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
$display_percentage_header = 1; $display_percentage_header = 1;
} }
//no column at all if the question was not a question
// </hub>
} }
} }
@ -1071,7 +1073,10 @@ class SurveyUtil
); );
$answers_of_user = []; $answers_of_user = [];
} }
if (isset($questions[$row['question_id']]) && $questions[$row['question_id']]['type'] != 'open') { if (isset($questions[$row['question_id']]) &&
$questions[$row['question_id']]['type'] != 'open' &&
$questions[$row['question_id']]['type'] != 'comment'
) {
$answers_of_user[$row['question_id']][$row['option_id']] = $row; $answers_of_user[$row['question_id']][$row['option_id']] = $row;
} else { } else {
$answers_of_user[$row['question_id']][0] = $row; $answers_of_user[$row['question_id']][0] = $row;
@ -1141,7 +1146,7 @@ class SurveyUtil
if ($display_extra_user_fields) { if ($display_extra_user_fields) {
// Show user fields data, if any, for this user // Show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data( $user_fields_values = UserManager::get_extra_user_data(
intval($user), $user,
false, false,
false, false,
false, false,
@ -1151,10 +1156,10 @@ class SurveyUtil
echo '<td align="center">'.$value.'</td>'; echo '<td align="center">'.$value.'</td>';
} }
} }
if (is_array($possible_options)) { if (is_array($possible_options)) {
// <hub> modified to display open answers and percentage
foreach ($possible_options as $question_id => &$possible_option) { foreach ($possible_options as $question_id => &$possible_option) {
if ($questions[$question_id]['type'] == 'open') { if ($questions[$question_id]['type'] == 'open' || $questions[$question_id]['type'] == 'comment') {
echo '<td align="center">'; echo '<td align="center">';
echo $answers_of_user[$question_id]['0']['option_id']; echo $answers_of_user[$question_id]['0']['option_id'];
echo '</td>'; echo '</td>';
@ -1202,6 +1207,12 @@ class SurveyUtil
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
if (empty($surveyId)) {
return false;
}
// The first column // The first column
$return = ';'; $return = ';';
@ -1217,7 +1228,6 @@ class SurveyUtil
$num = count($extra_user_fields); $num = count($extra_user_fields);
$return .= str_repeat(';', $num); $return .= str_repeat(';', $num);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT $sql = "SELECT
@ -1227,9 +1237,9 @@ class SurveyUtil
count(options.question_option_id) as number_of_options count(options.question_option_id) as number_of_options
FROM $table_survey_question questions FROM $table_survey_question questions
LEFT JOIN $table_survey_question_option options LEFT JOIN $table_survey_question_option options
ON questions.question_id = options.question_id AND options.c_id = $course_id ON questions.question_id = options.question_id AND options.c_id = questions.c_id
WHERE WHERE
questions.survey_id = '".intval($_GET['survey_id'])."' AND questions.survey_id = '".$surveyId."' AND
questions.c_id = $course_id questions.c_id = $course_id
GROUP BY questions.question_id GROUP BY questions.question_id
ORDER BY questions.sort ASC"; ORDER BY questions.sort ASC";
@ -1244,8 +1254,8 @@ class SurveyUtil
in_array($row['question_id'], $_POST['questions_filter'])) in_array($row['question_id'], $_POST['questions_filter']))
) { ) {
// We do not show comment and pagebreak question types // We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['type'] != 'pagebreak') {
if ($row['number_of_options'] == 0 && $row['type'] == 'open') { if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) {
$return .= str_replace( $return .= str_replace(
"\r\n", "\r\n",
' ', ' ',
@ -1265,11 +1275,10 @@ class SurveyUtil
} }
} }
} }
$return .= "\n";
$return .= "\n";
// Getting all the questions and options // Getting all the questions and options
$return .= ';'; $return .= ';';
// Show the fields names for user fields // Show the fields names for user fields
if (!empty($extra_user_fields)) { if (!empty($extra_user_fields)) {
foreach ($extra_user_fields as &$field) { foreach ($extra_user_fields as &$field) {
@ -1297,9 +1306,9 @@ class SurveyUtil
LEFT JOIN $table_survey_question_option survey_question_option LEFT JOIN $table_survey_question_option survey_question_option
ON ON
survey_question.question_id = survey_question_option.question_id AND survey_question.question_id = survey_question_option.question_id AND
survey_question_option.c_id = $course_id survey_question_option.c_id = survey_question.c_id
WHERE WHERE
survey_question.survey_id = '".intval($_GET['survey_id'])."' AND survey_question.survey_id = '".$surveyId."' AND
survey_question.c_id = $course_id survey_question.c_id = $course_id
ORDER BY survey_question.sort ASC, survey_question_option.sort ASC"; ORDER BY survey_question.sort ASC, survey_question_option.sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
@ -1315,7 +1324,7 @@ class SurveyUtil
) )
) { ) {
// We do not show comment and pagebreak question types // We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['type'] != 'pagebreak') {
$row['option_text'] = str_replace(["\r", "\n"], ['', ''], $row['option_text']); $row['option_text'] = str_replace(["\r", "\n"], ['', ''], $row['option_text']);
$return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';'; $return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';';
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
@ -1329,7 +1338,7 @@ class SurveyUtil
$old_user = ''; $old_user = '';
$answers_of_user = []; $answers_of_user = [];
$sql = "SELECT * FROM $table_survey_answer $sql = "SELECT * FROM $table_survey_answer
WHERE c_id = $course_id AND survey_id='".intval($_GET['survey_id'])."'"; WHERE c_id = $course_id AND survey_id='".$surveyId."'";
if ($user_id != 0) { if ($user_id != 0) {
$sql .= "AND user='".Database::escape_string($user_id)."' "; $sql .= "AND user='".Database::escape_string($user_id)."' ";
} }
@ -1348,7 +1357,9 @@ class SurveyUtil
); );
$answers_of_user = []; $answers_of_user = [];
} }
if ($possible_answers_type[$row['question_id']] == 'open') { if ($possible_answers_type[$row['question_id']] == 'open' ||
$possible_answers_type[$row['question_id']] == 'comment'
) {
$temp_id = 'open'.$open_question_iterator; $temp_id = 'open'.$open_question_iterator;
$answers_of_user[$row['question_id']][$temp_id] = $row; $answers_of_user[$row['question_id']][$temp_id] = $row;
$open_question_iterator++; $open_question_iterator++;
@ -1516,7 +1527,7 @@ class SurveyUtil
count(options.question_option_id) as number_of_options count(options.question_option_id) as number_of_options
FROM $table_survey_question questions FROM $table_survey_question questions
LEFT JOIN $table_survey_question_option options LEFT JOIN $table_survey_question_option options
ON questions.question_id = options.question_id AND options.c_id = $course_id ON questions.question_id = options.question_id AND options.c_id = questions.c_id
WHERE WHERE
questions.survey_id = $surveyId AND questions.survey_id = $surveyId AND
questions.c_id = $course_id questions.c_id = $course_id
@ -1532,8 +1543,8 @@ class SurveyUtil
in_array($row['question_id'], $_POST['questions_filter'])) in_array($row['question_id'], $_POST['questions_filter']))
) { ) {
// We do not show comment and pagebreak question types // We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['type'] != 'pagebreak') {
if ($row['number_of_options'] == 0 && $row['type'] == 'open') { if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) {
$worksheet->setCellValueByColumnAndRow( $worksheet->setCellValueByColumnAndRow(
$column, $column,
$line, $line,
@ -1590,7 +1601,7 @@ class SurveyUtil
LEFT JOIN $table_survey_question_option survey_question_option LEFT JOIN $table_survey_question_option survey_question_option
ON ON
survey_question.question_id = survey_question_option.question_id AND survey_question.question_id = survey_question_option.question_id AND
survey_question_option.c_id = $course_id survey_question_option.c_id = survey_question.c_id
WHERE WHERE
survey_question.survey_id = $surveyId AND survey_question.survey_id = $surveyId AND
survey_question.c_id = $course_id survey_question.c_id = $course_id
@ -1607,7 +1618,7 @@ class SurveyUtil
in_array($row['question_id'], $_POST['questions_filter'])) in_array($row['question_id'], $_POST['questions_filter']))
) { ) {
// We do not show comment and pagebreak question types // We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['type'] != 'pagebreak') {
$worksheet->setCellValueByColumnAndRow( $worksheet->setCellValueByColumnAndRow(
$column, $column,
$line, $line,
@ -1654,7 +1665,7 @@ class SurveyUtil
$line++; $line++;
$column = 0; $column = 0;
} }
if ($possible_answers_type[$row['question_id']] == 'open') { if ($possible_answers_type[$row['question_id']] == 'open' || $possible_answers_type[$row['question_id']] == 'comment') {
$temp_id = 'open'.$open_question_iterator; $temp_id = 'open'.$open_question_iterator;
$answers_of_user[$row['question_id']][$temp_id] = $row; $answers_of_user[$row['question_id']][$temp_id] = $row;
$open_question_iterator++; $open_question_iterator++;

@ -105,6 +105,14 @@ class CDocument extends AbstractResource implements ResourceInterface
{ {
} }
/**
* @return string
*/
public function __toString()
{
return (string) $this->title;
}
public function __get($a) public function __get($a)
{ {
} }

Loading…
Cancel
Save