Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2731/head
Angel Fernando Quiroz Campos 7 years ago
commit f23eed95c7
  1. 2
      main/attendance/attendance_controller.php
  2. 2
      main/attendance/attendance_sheet.php
  3. 1
      main/gradebook/index.php
  4. 8
      main/inc/lib/attendance.lib.php
  5. 2
      main/inc/lib/lp_item.lib.php
  6. 2
      main/inc/lib/template.lib.php
  7. 7
      main/inc/lib/tracking.lib.php
  8. 6
      main/lp/learnpath.class.php
  9. 12
      main/survey/reporting.php
  10. 123
      main/survey/surveyUtil.class.php
  11. 57
      main/tracking/courseLog.php

@ -303,7 +303,7 @@ class AttendanceController
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(), api_get_user_id(),
api_get_course_info() api_get_course_info()
); ) || api_is_drh();
if ($edit == true) { if ($edit == true) {
if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) { if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) {

@ -16,7 +16,7 @@ api_protect_course_script(true);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(), api_get_user_id(),
api_get_course_info() api_get_course_info()
); ) || api_is_drh();
if (api_is_allowed_to_edit(null, true) || if (api_is_allowed_to_edit(null, true) ||
api_is_coach(api_get_session_id(), api_get_course_int_id()) || api_is_coach(api_get_session_id(), api_get_course_int_id()) ||

@ -786,7 +786,6 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
} }
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
if (((empty($selectCat)) || (isset($_GET['cidReq']) && $_GET['cidReq'] !== '')) || if (((empty($selectCat)) || (isset($_GET['cidReq']) && $_GET['cidReq'] !== '')) ||
(isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false')
) { ) {

@ -154,8 +154,9 @@ class Attendance
while ($attendance = Database::fetch_row($res)) { while ($attendance = Database::fetch_row($res)) {
$student_param = ''; $student_param = '';
if (api_is_drh() && $_GET['student_id']) { $studentRequestId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0;
$student_param = '&student_id='.intval($_GET['student_id']); if (api_is_drh() && !empty($studentRequestId)) {
$student_param = '&student_id='.$studentRequestId;
} }
$session_star = ''; $session_star = '';
@ -166,8 +167,7 @@ class Attendance
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(), api_get_user_id(),
api_get_course_info() api_get_course_info()
); ) || api_is_drh();
if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) { if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) {
// Link to edit // Link to edit
$attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; $attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star;

@ -46,7 +46,7 @@ class LpItem
$sql = "SELECT * FROM $item_view_table $sql = "SELECT * FROM $item_view_table
WHERE WHERE
c_id=".intval($in_c_id)." AND c_id=".intval($in_c_id)." AND
id=".intval($in_id); iid=".intval($in_id);
$res = Database::query($sql); $res = Database::query($sql);
$data = Database::fetch_array($res); $data = Database::fetch_array($res);

@ -1916,7 +1916,9 @@ class Template
/** /**
* Get platform meta image tag (check meta_image_path setting, then use the logo). * Get platform meta image tag (check meta_image_path setting, then use the logo).
*
* @param string $imageAlt The alt attribute for the image * @param string $imageAlt The alt attribute for the image
*
* @return string The meta image HTML tag, or empty * @return string The meta image HTML tag, or empty
*/ */
private function getMetaPortalImagePath($imageAlt = '') private function getMetaPortalImagePath($imageAlt = '')

@ -7448,8 +7448,9 @@ class TrackingCourseLog
$direction, $direction,
$includeInvitedUsers = false $includeInvitedUsers = false
) { ) {
global $user_ids, $course_code, $export_csv, $csv_content, $session_id; global $user_ids, $course_code, $export_csv, $session_id;
$csv_content = [];
$course_code = Database::escape_string($course_code); $course_code = Database::escape_string($course_code);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -7696,6 +7697,10 @@ class TrackingCourseLog
$users[] = array_values($user_row); $users[] = array_values($user_row);
} }
if ($export_csv) {
Session::write('csv_content', $csv_content);
}
Session::erase('additional_user_profile_info'); Session::erase('additional_user_profile_info');
Session::erase('extra_field_info'); Session::erase('extra_field_info');

@ -10332,13 +10332,13 @@ class learnpath
$selectedMinScore = []; $selectedMinScore = [];
$selectedMaxScore = []; $selectedMaxScore = [];
$masteryScore = []; $masteryScore = [];
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
if ($row['id'] == $item_id) { if ($row['iid'] == $item_id) {
$selectedMinScore[$row['prerequisite']] = $row['prerequisite_min_score']; $selectedMinScore[$row['prerequisite']] = $row['prerequisite_min_score'];
$selectedMaxScore[$row['prerequisite']] = $row['prerequisite_max_score']; $selectedMaxScore[$row['prerequisite']] = $row['prerequisite_max_score'];
$masteryScore[$row['prerequisite']] = $row['mastery_score'];
} }
$masteryScore[$row['iid']] = $row['mastery_score'];
$arrLP[] = [ $arrLP[] = [
'id' => $row['iid'], 'id' => $row['iid'],
'item_type' => $row['item_type'], 'item_type' => $row['item_type'],

@ -62,21 +62,13 @@ if (!empty($exportReport) && !empty($format)) {
switch ($format) { switch ($format) {
case 'xls': case 'xls':
$filename = 'survey_results_'.$survey_id.'.xlsx'; $filename = 'survey_results_'.$survey_id.'.xlsx';
$data = SurveyUtil::export_complete_report_xls( $data = SurveyUtil::export_complete_report_xls($survey_data, $filename, $userId);
$survey_data,
$filename,
$userId
);
exit; exit;
break; break;
case 'csv': case 'csv':
default: default:
$data = SurveyUtil::export_complete_report( $data = SurveyUtil::export_complete_report($survey_data, $userId);
$survey_data,
$userId
);
$filename = 'survey_results_'.$survey_id.'.csv'; $filename = 'survey_results_'.$survey_id.'.csv';
header('Content-type: application/octet-stream'); header('Content-type: application/octet-stream');
header('Content-Type: application/force-download'); header('Content-Type: application/force-download');

@ -225,7 +225,7 @@ class SurveyUtil
*/ */
public static function handle_reporting_actions($survey_data, $people_filled) public static function handle_reporting_actions($survey_data, $people_filled)
{ {
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : '';
// Getting the number of question // Getting the number of question
$temp_questions_data = SurveyManager::get_questions($_GET['survey_id']); $temp_questions_data = SurveyManager::get_questions($_GET['survey_id']);
@ -243,20 +243,22 @@ class SurveyUtil
// Counting the number of questions that are relevant for the reporting // Counting the number of questions that are relevant for the reporting
$survey_data['number_of_questions'] = count($questions_data); $survey_data['number_of_questions'] = count($questions_data);
if ($action == 'questionreport') { switch ($action) {
case 'questionreport':
self::display_question_report($survey_data); self::display_question_report($survey_data);
} break;
if ($action == 'userreport') { case 'userreport':
self::display_user_report($people_filled, $survey_data); self::display_user_report($people_filled, $survey_data);
} break;
if ($action == 'comparativereport') { case 'comparativereport':
self::display_comparative_report(); self::display_comparative_report();
} break;
if ($action == 'completereport') { case 'completereport':
self::display_complete_report($survey_data); self::display_complete_report($survey_data);
} break;
if ($action == 'deleteuserreport') { case 'deleteuserreport':
self::delete_user_report($_GET['survey_id'], $_GET['user']); self::delete_user_report($_GET['survey_id'], $_GET['user']);
break;
} }
} }
@ -373,7 +375,7 @@ class SurveyUtil
echo '<select name="user" onchange="jumpMenu(\'parent\',this,0)">'; echo '<select name="user" onchange="jumpMenu(\'parent\',this,0)">';
echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=' echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='
.Security::remove_XSS($_GET['action']).'&survey_id='.intval($_GET['survey_id']).'">' .Security::remove_XSS($_GET['action']).'&survey_id='.$surveyId.'&'.api_get_cidreq().'">'
.get_lang('SelectUser').'</option>'; .get_lang('SelectUser').'</option>';
foreach ($people_filled as $key => &$person) { foreach ($people_filled as $key => &$person) {
@ -389,8 +391,8 @@ class SurveyUtil
$id = $person; $id = $person;
} }
echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=' echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='
.Security::remove_XSS($_GET['action']).'&survey_id='.intval($_GET['survey_id']).'&user=' .Security::remove_XSS($_GET['action']).'&survey_id='.$surveyId.'&user='
.Security::remove_XSS($id).'" '; .Security::remove_XSS($id).'&'.api_get_cidreq().'" ';
if (isset($_GET['user']) && $_GET['user'] == $id) { if (isset($_GET['user']) && $_GET['user'] == $id) {
echo 'selected="selected"'; echo 'selected="selected"';
} }
@ -425,7 +427,8 @@ class SurveyUtil
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 = $course_id
WHERE WHERE
survey_question.survey_id = '".intval($_GET['survey_id'])."' AND survey_question NOT LIKE '%{{%' AND
survey_question.survey_id = '".$surveyId."' AND
survey_question.c_id = $course_id survey_question.c_id = $course_id
ORDER BY survey_question.sort, survey_question_option.sort ASC"; ORDER BY survey_question.sort, survey_question_option.sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
@ -445,7 +448,7 @@ class SurveyUtil
$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
user = '".Database::escape_string($_GET['user'])."'"; user = '".Database::escape_string($_GET['user'])."'";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -577,6 +580,7 @@ class SurveyUtil
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".$surveyId."' AND survey_id='".$surveyId."' AND
survey_question NOT LIKE '%{{%' AND
type <>'pagebreak' type <>'pagebreak'
ORDER BY sort ASC ORDER BY sort ASC
$limitStatement"; $limitStatement";
@ -957,6 +961,7 @@ class SurveyUtil
LEFT JOIN $table_survey_question_option o LEFT JOIN $table_survey_question_option o
ON q.question_id = o.question_id AND q.c_id = o.c_id ON q.question_id = o.question_id AND q.c_id = o.c_id
WHERE WHERE
survey_question NOT LIKE '%{{%' AND
q.survey_id = '".$surveyId."' AND q.survey_id = '".$surveyId."' AND
q.c_id = $course_id q.c_id = $course_id
GROUP BY q.question_id GROUP BY q.question_id
@ -1016,6 +1021,7 @@ class SurveyUtil
LEFT JOIN $table_survey_question_option sqo LEFT JOIN $table_survey_question_option sqo
ON sq.question_id = sqo.question_id AND sq.c_id = sqo.c_id ON sq.question_id = sqo.question_id AND sq.c_id = sqo.c_id
WHERE WHERE
survey_question NOT LIKE '%{{%' AND
sq.survey_id = '".$surveyId."' AND sq.survey_id = '".$surveyId."' AND
sq.c_id = $course_id sq.c_id = $course_id
ORDER BY sq.sort ASC, sqo.sort ASC"; ORDER BY sq.sort ASC, sqo.sort ASC";
@ -1169,7 +1175,9 @@ class SurveyUtil
foreach ($possible_options as $question_id => &$possible_option) { foreach ($possible_options as $question_id => &$possible_option) {
if ($questions[$question_id]['type'] == 'open' || $questions[$question_id]['type'] == 'comment') { if ($questions[$question_id]['type'] == 'open' || $questions[$question_id]['type'] == 'comment') {
echo '<td align="center">'; echo '<td align="center">';
if (isset($answers_of_user[$question_id]) && isset($answers_of_user[$question_id]['0'])) {
echo $answers_of_user[$question_id]['0']['option_id']; echo $answers_of_user[$question_id]['0']['option_id'];
}
echo '</td>'; echo '</td>';
} else { } else {
foreach ($possible_option as $option_id => &$value) { foreach ($possible_option as $option_id => &$value) {
@ -1210,17 +1218,16 @@ class SurveyUtil
*/ */
public static function export_complete_report($survey_data, $user_id = 0) public static function export_complete_report($survey_data, $user_id = 0)
{ {
// Database table definitions
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0; $surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
if (empty($surveyId)) { if (empty($surveyId)) {
return false; return false;
} }
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
// The first column // The first column
$return = ';'; $return = ';';
@ -1245,12 +1252,17 @@ 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 = questions.c_id ON
questions.question_id = options.question_id AND
options.c_id = questions.c_id
WHERE WHERE
questions.survey_id = '".$surveyId."' AND survey_question NOT LIKE '%{{%' AND
questions.type <> 'pagebreak' 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";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
// We show the questions if // We show the questions if
@ -1261,9 +1273,7 @@ class SurveyUtil
is_array($_POST['questions_filter']) && is_array($_POST['questions_filter']) &&
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 if ($row['number_of_options'] == 0) {
if ($row['type'] != 'pagebreak') {
if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) {
$return .= str_replace( $return .= str_replace(
"\r\n", "\r\n",
' ', ' ',
@ -1282,7 +1292,6 @@ class SurveyUtil
} }
} }
} }
}
$return .= "\n"; $return .= "\n";
// Getting all the questions and options // Getting all the questions and options
@ -1300,7 +1309,7 @@ class SurveyUtil
} }
} }
$sql = "SELECT $sql = "SELECT DISTINCT
survey_question.question_id, survey_question.question_id,
survey_question.survey_id, survey_question.survey_id,
survey_question.survey_question, survey_question.survey_question,
@ -1316,7 +1325,9 @@ class SurveyUtil
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 = survey_question.c_id survey_question_option.c_id = survey_question.c_id
WHERE WHERE
survey_question.survey_id = '".$surveyId."' AND survey_question NOT LIKE '%{{%' AND
survey_question.type <> 'pagebreak' 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);
@ -1331,30 +1342,35 @@ 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
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'];
$possible_answers_type[$row['question_id']] = $row['type']; $possible_answers_type[$row['question_id']] = $row['type'];
} }
} }
}
$return .= "\n"; $return .= "\n";
// Getting all the answers of the users // Getting all the answers of the users
$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='".$surveyId."'"; 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)."' ";
} }
$sql .= "ORDER BY user ASC"; $sql .= ' ORDER BY user ASC ';
$questionIdList = array_keys($possible_answers_type);
$open_question_iterator = 1; $open_question_iterator = 1;
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result, 'ASSOC')) {
if (!in_array($row['question_id'], $questionIdList)) {
continue;
}
if ($old_user != $row['user'] && $old_user != '') { if ($old_user != $row['user'] && $old_user != '') {
$return .= self::export_complete_report_row( $return .= self::export_complete_report_row(
$survey_data, $survey_data,
@ -1365,6 +1381,7 @@ 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' $possible_answers_type[$row['question_id']] == 'comment'
) { ) {
@ -1376,6 +1393,7 @@ class SurveyUtil
} }
$old_user = $row['user']; $old_user = $row['user'];
} }
// This is to display the last user // This is to display the last user
$return .= self::export_complete_report_row( $return .= self::export_complete_report_row(
$survey_data, $survey_data,
@ -1535,8 +1553,12 @@ 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 = questions.c_id ON
questions.question_id = options.question_id AND
options.c_id = questions.c_id
WHERE WHERE
survey_question NOT LIKE '%{{%' AND
questions.type <> 'pagebreak' AND
questions.survey_id = $surveyId 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
@ -1550,9 +1572,9 @@ class SurveyUtil
(isset($_POST['submit_question_filter']) && is_array($_POST['questions_filter']) && (isset($_POST['submit_question_filter']) && is_array($_POST['questions_filter']) &&
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 if ($row['number_of_options'] == 0 &&
if ($row['type'] != 'pagebreak') { ($row['type'] == 'open' || $row['type'] == 'comment')
if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) { ) {
$worksheet->setCellValueByColumnAndRow( $worksheet->setCellValueByColumnAndRow(
$column, $column,
$line, $line,
@ -1577,7 +1599,6 @@ class SurveyUtil
} }
} }
} }
}
$line++; $line++;
$column = 1; $column = 1;
@ -1611,6 +1632,8 @@ class SurveyUtil
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 = survey_question.c_id survey_question_option.c_id = survey_question.c_id
WHERE WHERE
survey_question NOT LIKE '%{{%' AND
survey_question.type <> 'pagebreak' AND
survey_question.survey_id = $surveyId 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";
@ -1625,8 +1648,6 @@ class SurveyUtil
(isset($_POST['questions_filter']) && is_array($_POST['questions_filter']) && (isset($_POST['questions_filter']) && is_array($_POST['questions_filter']) &&
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
if ($row['type'] != 'pagebreak') {
$worksheet->setCellValueByColumnAndRow( $worksheet->setCellValueByColumnAndRow(
$column, $column,
$line, $line,
@ -1640,7 +1661,6 @@ class SurveyUtil
$column++; $column++;
} }
} }
}
// Getting all the answers of the users // Getting all the answers of the users
$line++; $line++;
@ -1652,7 +1672,7 @@ class SurveyUtil
if ($user_id != 0) { if ($user_id != 0) {
$sql .= " AND user='".intval($user_id)."' "; $sql .= " AND user='".intval($user_id)."' ";
} }
$sql .= " ORDER BY user ASC"; $sql .= ' ORDER BY user ASC';
$open_question_iterator = 1; $open_question_iterator = 1;
$result = Database::query($sql); $result = Database::query($sql);
@ -1673,7 +1693,9 @@ class SurveyUtil
$line++; $line++;
$column = 0; $column = 0;
} }
if ($possible_answers_type[$row['question_id']] == 'open' || $possible_answers_type[$row['question_id']] == 'comment') { 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++;
@ -1843,6 +1865,13 @@ class SurveyUtil
$optionsY = ['----']; $optionsY = ['----'];
$defaults = []; $defaults = [];
foreach ($questions as $key => &$question) { foreach ($questions as $key => &$question) {
// Ignored tagged questions
if ($question) {
if (strpos($question['question'], '{{') !== false) {
$question = null;
continue;
}
}
if (is_array($allowed_question_types)) { if (is_array($allowed_question_types)) {
if (in_array($question['type'], $allowed_question_types)) { if (in_array($question['type'], $allowed_question_types)) {
if (isset($_GET['xaxis']) && $_GET['xaxis'] == $question['question_id']) { if (isset($_GET['xaxis']) && $_GET['xaxis'] == $question['question_id']) {
@ -1853,8 +1882,8 @@ class SurveyUtil
$defaults['yaxis'] = $question['question_id']; $defaults['yaxis'] = $question['question_id'];
} }
$optionsX[$question['question_id']] = api_substr(strip_tags($question['question']), 0, 50); $optionsX[$question['question_id']] = api_substr(strip_tags($question['question']), 0, 90);
$optionsY[$question['question_id']] = api_substr(strip_tags($question['question']), 0, 50); $optionsY[$question['question_id']] = api_substr(strip_tags($question['question']), 0, 90);
} }
} }
} }
@ -2848,7 +2877,7 @@ class SurveyUtil
); );
$actions[] = Display::url( $actions[] = Display::url(
Display::return_icon('multiplicate_survey.png', get_lang('MultiplicateSurvey')), Display::return_icon('multiplicate_survey.png', get_lang('MultiplicateQuestions')),
$codePath.'survey/survey_list.php?' $codePath.'survey/survey_list.php?'
.http_build_query($params + ['action' => 'multiplicate', 'survey_id' => $survey_id]) .http_build_query($params + ['action' => 'multiplicate', 'survey_id' => $survey_id])
); );

@ -35,7 +35,6 @@ $is_allowedToTrack = Tracking::isAllowToTrack($session_id);
if (!$is_allowedToTrack) { if (!$is_allowedToTrack) {
api_not_allowed(true); api_not_allowed(true);
exit;
} }
// If the user is a HR director (drh) // If the user is a HR director (drh)
@ -73,7 +72,6 @@ if (api_is_drh()) {
$coursesFollowedList = array_keys($coursesFollowedList); $coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array($courseId, $coursesFollowedList)) { if (!in_array($courseId, $coursesFollowedList)) {
api_not_allowed(true); api_not_allowed(true);
exit;
} }
} }
} }
@ -342,7 +340,7 @@ if ($showReporting) {
// Show the charts part only if there are students subscribed to this course/session // Show the charts part only if there are students subscribed to this course/session
if ($nbStudents > 0) { if ($nbStudents > 0) {
$usersTracking = TrackingCourseLog::get_user_data(null, $nbStudents, null, 'DESC'); $usersTracking = TrackingCourseLog::get_user_data(null, $nbStudents, null, 'DESC', false);
$numberStudentsCompletedLP = 0; $numberStudentsCompletedLP = 0;
$averageStudentsTestScore = 0; $averageStudentsTestScore = 0;
$scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; $scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
@ -412,7 +410,7 @@ if ($nbStudents > 0) {
$tpl->assign('number_students', $nbStudents); $tpl->assign('number_students', $nbStudents);
$tpl->assign('top_students', $userScoreList); $tpl->assign('top_students', $userScoreList);
$trackingSummaryLayout = $tpl->get_template("tracking/tracking_course_log.tpl"); $trackingSummaryLayout = $tpl->get_template('tracking/tracking_course_log.tpl');
$content = $tpl->fetch($trackingSummaryLayout); $content = $tpl->fetch($trackingSummaryLayout);
echo $content; echo $content;
@ -508,21 +506,50 @@ if (count($a_students) > 0) {
$table->set_header(3, get_lang('Login'), false); $table->set_header(3, get_lang('Login'), false);
$headers['login'] = get_lang('Login'); $headers['login'] = get_lang('Login');
$table->set_header(4, get_lang('TrainingTime').'&nbsp;'. $table->set_header(
Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']); 4,
get_lang('TrainingTime').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
);
$headers['training_time'] = get_lang('TrainingTime'); $headers['training_time'] = get_lang('TrainingTime');
$table->set_header(5, get_lang('CourseProgress').'&nbsp;'. $table->set_header(5, get_lang('CourseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']); Display::return_icon(
'info3.gif',
get_lang('ScormAndLPProgressTotalAverage'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['course_progress'] = get_lang('CourseProgress'); $headers['course_progress'] = get_lang('CourseProgress');
$table->set_header(6, get_lang('ExerciseProgress').'&nbsp;'. $table->set_header(6, get_lang('ExerciseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseProgressInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']); Display::return_icon(
'info3.gif',
get_lang('ExerciseProgressInfo'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['exercise_progress'] = get_lang('ExerciseProgress'); $headers['exercise_progress'] = get_lang('ExerciseProgress');
$table->set_header(7, get_lang('ExerciseAverage').'&nbsp;'. $table->set_header(7, get_lang('ExerciseAverage').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']); Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
);
$headers['exercise_average'] = get_lang('ExerciseAverage'); $headers['exercise_average'] = get_lang('ExerciseAverage');
$table->set_header(8, get_lang('Score').'&nbsp;'. $table->set_header(8, get_lang('Score').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']); Display::return_icon(
'info3.gif',
get_lang('ScormAndLPTestTotalAverage'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['score'] = get_lang('Score'); $headers['score'] = get_lang('Score');
$table->set_header(9, get_lang('Student_publication'), false); $table->set_header(9, get_lang('Student_publication'), false);
$headers['student_publication'] = get_lang('Student_publication'); $headers['student_publication'] = get_lang('Student_publication');
@ -633,19 +660,21 @@ if ($export_csv) {
} }
ob_end_clean(); ob_end_clean();
$csvContentInSession = Session::read('csv_content');
// Adding headers before the content. // Adding headers before the content.
array_unshift($csv_content, $csv_headers); array_unshift($csvContentInSession, $csv_headers);
if ($session_id) { if ($session_id) {
$sessionData = []; $sessionData = [];
$sessionInfo = api_get_session_info($session_id); $sessionInfo = api_get_session_info($session_id);
$sessionDates = SessionManager::parseSessionDates($sessionInfo); $sessionDates = SessionManager::parseSessionDates($sessionInfo);
array_unshift($csv_content, [get_lang('Date'), $sessionDates['access']]); array_unshift($csvContentInSession, [get_lang('Date'), $sessionDates['access']]);
array_unshift($csv_content, [get_lang('SessionName'), $sessionInfo['name']]); array_unshift($csvContentInSession, [get_lang('SessionName'), $sessionInfo['name']]);
} }
Export::arrayToCsv($csv_content, 'reporting_student_list'); Export::arrayToCsv($csvContentInSession, 'reporting_student_list');
exit; exit;
} }
Display::display_footer(); Display::display_footer();

Loading…
Cancel
Save