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

pull/3388/head
Yannick Warnier 5 years ago
commit 3bf712580b
  1. 34
      main/gradebook/lib/be/exerciselink.class.php
  2. 23
      main/gradebook/lib/fe/displaygradebook.php
  3. 4
      main/gradebook/lib/fe/gradebooktable.class.php
  4. 8
      main/gradebook/lib/flatview_data_generator.class.php
  5. 7
      main/gradebook/user_stats.php
  6. 205
      main/mySpace/work_stats.php
  7. 15
      main/survey/fillsurvey.php
  8. 13
      main/survey/preview.php
  9. 52
      main/survey/survey.lib.php
  10. 2
      plugin/whispeakauth/ajax/authentify_password.php
  11. 2
      plugin/whispeakauth/ajax/record_audio.php

@ -102,10 +102,12 @@ class ExerciseLink extends AbstractLink
} }
$cats = []; $cats = [];
$exerciseList = [];
if (isset($result)) { if (isset($result)) {
if (Database::num_rows($result) > 0) { if (Database::num_rows($result) > 0) {
while ($data = Database::fetch_array($result)) { while ($data = Database::fetch_array($result)) {
$cats[] = [$data['iid'], $data['title']]; $cats[] = [$data['iid'], $data['title']];
$exerciseList[] = $data;
} }
} }
} }
@ -138,12 +140,22 @@ class ExerciseLink extends AbstractLink
} }
if (!empty($exerciseInLP)) { if (!empty($exerciseInLP)) {
$allExercises = array_column($exerciseList, 'iid');
foreach ($exerciseInLP as $exercise) { foreach ($exerciseInLP as $exercise) {
$lpName = strip_tags($exercise['lp_name']); if (in_array($exercise['iid'], $allExercises)) {
$cats[] = [ continue;
}
$allExercises[] = $exercise['iid'];
//$lpName = strip_tags($exercise['lp_name']);
/*$cats[] = [
$exercise['iid'], $exercise['iid'],
strip_tags(Exercise::get_formated_title_variable($exercise['title'])). strip_tags(Exercise::get_formated_title_variable($exercise['title'])).
' ('.get_lang('ToolLearnpath').' - '.$lpName.')', ' ('.get_lang('ToolLearnpath').' - '.$lpName.')',
];*/
$cats[] = [
$exercise['iid'],
strip_tags(Exercise::get_formated_title_variable($exercise['title'])),
]; ];
} }
} }
@ -243,7 +255,6 @@ class ExerciseLink extends AbstractLink
$sessionId = $this->get_session_id(); $sessionId = $this->get_session_id();
$courseId = $this->getCourseId(); $courseId = $this->getCourseId();
$exerciseData = $this->get_exercise_data(); $exerciseData = $this->get_exercise_data();
$exerciseId = isset($exerciseData['id']) ? (int) $exerciseData['id'] : 0; $exerciseId = isset($exerciseData['id']) ? (int) $exerciseData['id'] : 0;
$stud_id = (int) $stud_id; $stud_id = (int) $stud_id;
@ -280,23 +291,29 @@ class ExerciseLink extends AbstractLink
c_id = $courseId c_id = $courseId
"; ";
} else { } else {
$lpId = null; $lpCondition = null;
if (!empty($exercise->lpList)) { if (!empty($exercise->lpList)) {
$lpId = $exercise->getLpBySession($sessionId); //$lpId = $exercise->getLpBySession($sessionId);
$lpId = $lpId['lp_id']; $lpList = [];
foreach ($exercise->lpList as $lpData) {
if ((int) $lpData['session_id'] == $sessionId) {
$lpList[] = $lpData['lp_id'];
}
}
$lpCondition = ' orig_lp_id = 0 OR (orig_lp_id IN ("'.implode('", "', $lpList).'")) AND ';
} }
$sql = "SELECT * $sql = "SELECT *
FROM $tblStats FROM $tblStats
WHERE WHERE
exe_exo_id = $exerciseId AND exe_exo_id = $exerciseId AND
orig_lp_id = $lpId AND $lpCondition
status <> 'incomplete' AND status <> 'incomplete' AND
session_id = $sessionId AND session_id = $sessionId AND
c_id = $courseId "; c_id = $courseId ";
} }
if (!empty($stud_id) && 'ranking' != $type) { if (!empty($stud_id) && 'ranking' !== $type) {
$sql .= " AND exe_user_id = $stud_id "; $sql .= " AND exe_user_id = $stud_id ";
} }
$sql .= ' ORDER BY exe_id DESC '; $sql .= ' ORDER BY exe_id DESC ';
@ -346,7 +363,6 @@ class ExerciseLink extends AbstractLink
$bestResult = 0; $bestResult = 0;
$weight = 0; $weight = 0;
$sumResult = 0; $sumResult = 0;
$studentList = $this->getStudentList(); $studentList = $this->getStudentList();
$studentIdList = []; $studentIdList = [];
if (!empty($studentList)) { if (!empty($studentList)) {

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -152,8 +153,8 @@ class DisplayGradebook
$header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'. $header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'.
Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
$pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null; $pageNum = isset($_GET['flatviewlist_page_nr']) ? (int) $_GET['flatviewlist_page_nr'] : null;
$perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null; $perPage = isset($_GET['flatviewlist_per_page']) ? (int) $_GET['flatviewlist_per_page'] : null;
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([ $exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
@ -484,7 +485,7 @@ class DisplayGradebook
).'&cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'. ).'&cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' && if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true' &&
api_get_course_setting('customcertificate_course_enable') == 1 api_get_course_setting('customcertificate_course_enable') == 1
) { ) {
$actionsRight .= '<a href="'.api_get_path( $actionsRight .= '<a href="'.api_get_path(
@ -630,12 +631,16 @@ class DisplayGradebook
$header = '<div class="actions">'; $header = '<div class="actions">';
if ($is_course_admin) { if ($is_course_admin) {
$header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>'; $header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
$header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
} elseif (!(isset($_GET['studentoverview']))) { } elseif (!(isset($_GET['studentoverview']))) {
$header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat='.$catobj->get_id().'">'.Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').'</a>'; $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat='.$catobj->get_id().'">'.
Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').'</a>';
} else { } else {
$header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">'.Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).'</a>'; $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">'.
Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).'</a>';
} }
$header .= '</div>'; $header .= '</div>';
echo $header; echo $header;
@ -674,8 +679,10 @@ class DisplayGradebook
for ($count = 0; $count < count($evals_links); $count++) { for ($count = 0; $count < count($evals_links); $count++) {
$item = $evals_links[$count]; $item = $evals_links[$count];
$score = $item->calc_score($userId); $score = $item->calc_score($userId);
if ($score) {
$my_score_denom = ($score[1] == 0) ? 1 : $score[1]; $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
$item_value += $score[0] / $my_score_denom * $item->get_weight(); $item_value += $score[0] / $my_score_denom * $item->get_weight();
}
$item_total += $item->get_weight(); $item_total += $item->get_weight();
} }
$item_value = api_number_format($item_value, 2); $item_value = api_number_format($item_value, 2);
@ -688,7 +695,7 @@ class DisplayGradebook
$info .= '<div class="col-md-6">'; $info .= '<div class="col-md-6">';
$info .= get_lang('Name').' : '.$user['complete_name_with_message_link'].'<br />'; $info .= get_lang('Name').' : '.$user['complete_name_with_message_link'].'<br />';
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') === 'true') {
$info .= get_lang('Email').' : <a href="mailto:'.$user['email'].'">'.$user['email'].'</a><br />'; $info .= get_lang('Email').' : <a href="mailto:'.$user['email'].'">'.$user['email'].'</a><br />';
} }

@ -1239,10 +1239,10 @@ class GradebookTable extends SortableTable
$extra .= $item->getSkillsFromItem(); $extra .= $item->getSkillsFromItem();
$text .= "&nbsp;".$extra.$show_message; $text .= "&nbsp;".$extra.$show_message;
if ($item instanceof ExerciseLink) { /*if ($item instanceof ExerciseLink) {
$spaces = str_repeat('&nbsp;', $spaces); $spaces = str_repeat('&nbsp;', $spaces);
$text .= '<br /><br />'.$spaces.$item->getLpListToString(); $text .= '<br /><br />'.$spaces.$item->getLpListToString();
} }*/
$cc = $this->currentcat->get_course_code(); $cc = $this->currentcat->get_course_code();
if (empty($cc)) { if (empty($cc)) {

@ -202,9 +202,9 @@ class FlatViewDataGenerator
$label = $item->get_name(); $label = $item->get_name();
} }
if ($item instanceof ExerciseLink) { /*if ($item instanceof ExerciseLink) {
$label .= '<br /><br />'.$item->getLpListToString(); $label .= '<br /><br />'.$item->getLpListToString();
} }*/
$headers[] = $label; $headers[] = $label;
$evaluationsAdded[] = $item->get_id(); $evaluationsAdded[] = $item->get_id();
@ -225,9 +225,9 @@ class FlatViewDataGenerator
$label = $item->get_name(); $label = $item->get_name();
} }
if ($item instanceof ExerciseLink) { /*if ($item instanceof ExerciseLink) {
$label .= '<br /><br />'.$item->getLpListToString(); $label .= '<br /><br />'.$item->getLpListToString();
} }*/
$headers[] = $label; $headers[] = $label;
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -37,7 +38,7 @@ if (!empty($categoryId)) {
]; ];
} }
$user_table = new UserTable($userId, $allevals, $alllinks, $addparams); $userTable = new UserTable($userId, $allevals, $alllinks, $addparams);
if (isset($_GET['exportpdf'])) { if (isset($_GET['exportpdf'])) {
$datagen = new UserDataGenerator($userId, $allevals, $alllinks); $datagen = new UserDataGenerator($userId, $allevals, $alllinks);
@ -96,8 +97,8 @@ if (isset($_GET['exportpdf'])) {
$pdf->content_to_pdf($html); $pdf->content_to_pdf($html);
exit; exit;
} }
$actions = '<div class="actions">';
$actions = '<div class="actions">';
if (!empty($categoryId)) { if (!empty($categoryId)) {
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => 'gradebook_flatview.php?selectcat='.$categoryId.'&'.api_get_cidreq(), 'url' => 'gradebook_flatview.php?selectcat='.$categoryId.'&'.api_get_cidreq(),
@ -130,5 +131,5 @@ $actions .= '</div>';
Display::display_header(get_lang('ResultsPerUser')); Display::display_header(get_lang('ResultsPerUser'));
echo $actions; echo $actions;
DisplayGradebook::display_header_user($_GET['userid'], $category[0]->get_id()); DisplayGradebook::display_header_user($_GET['userid'], $category[0]->get_id());
$user_table->display(); $userTable->display();
Display::display_footer(); Display::display_footer();

@ -0,0 +1,205 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
api_protect_course_script();
$allowToTrack = api_is_platform_admin() || api_is_allowed_to_edit();
if (!$allowToTrack) {
api_not_allowed(true);
}
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
if (false === $consideredWorkingTime) {
api_not_allowed(true);
}
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$nameTools = get_lang('Students');
$this_section = SECTION_TRACKING;
$webCodePath = api_get_path(WEB_CODE_PATH);
$interbreadcrumb[] = [
'url' => api_is_student_boss() ? '#' : 'index.php',
'name' => get_lang('MySpace'),
];
function get_count_users()
{
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
return CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
null,
null,
null,
true
);
}
function get_users($from, $number_of_items, $column, $direction)
{
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$webCodePath = api_get_path(WEB_CODE_PATH);
$lastConnectionDate = null;
$is_western_name_order = api_is_western_name_order();
$limit = null;
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$limit = 'LIMIT '.$from.','.$number_of_items;
$students = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
$limit,
null,
null,
false
);
$url = $webCodePath.'mySpace/myStudents.php';
$workList = getWorkListTeacher(0, 100, null, null, null);
$workTimeList = [];
foreach ($workList as $work) {
$fieldValue = new ExtraFieldValue('work');
$resultExtra = $fieldValue->getAllValuesForAnItem(
$work['id'],
true
);
foreach ($resultExtra as $field) {
$field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) {
$time = $field->getValue();
$parsed = date_parse($time);
$workTimeList[$work['id']] = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
break;
}
}
}
$all_datas = [];
foreach ($students as $studentData) {
$studentId = $studentData['user_id'];
$studentData = api_get_user_info($studentId);
$urlDetails = $url."?student=$studentId&details=true&course=$courseCode&id_session=$sessionId";
$row = [];
if ($is_western_name_order) {
$first = Display::url($studentData['firstname'], $urlDetails);
$last = Display::url($studentData['lastname'], $urlDetails);
} else {
$first = Display::url($studentData['lastname'], $urlDetails);
$last = Display::url($studentData['firstname'], $urlDetails);
}
$row[] = $first;
$row[] = $last;
$timeInSeconds = Tracking::get_time_spent_on_the_course(
$studentId,
$courseId,
$sessionId
);
$row[] = api_time_to_hms($timeInSeconds);
$userWorkTime = 0;
foreach ($workList as $work) {
$userWorks = get_work_user_list(
0,
100,
null,
null,
$work['id'],
null,
$studentId,
false,
$courseId,
$sessionId
);
if ($userWorks) {
foreach ($userWorks as $work) {
$userWorkTime += $workTimeList[$work['parent_id']];
}
}
}
$row[] = api_time_to_hms($userWorkTime);
$status = '';
if ($userWorkTime && $timeInSeconds) {
if ($userWorkTime > $timeInSeconds) {
$status = Display::label('TimeToFix', 'warning');
} else {
$status = Display::label('Ok', 'success');
}
}
$row[] = $status;
/*$detailsLink = Display::url(
Display::return_icon('2rightarrow.png', get_lang('Details').' '.$studentData['username']),
$urlDetails,
['id' => 'details_'.$studentData['username']]
);
$row[] = $detailsLink;*/
$all_datas[] = $row;
}
return $all_datas;
}
$is_western_name_order = api_is_western_name_order();
$sort_by_first_name = api_sort_by_first_name();
$actionsLeft = '';
$toolbar = Display::toolbarAction('toolbar-student', [$actionsLeft]);
$itemPerPage = 10;
$perPage = api_get_configuration_value('my_space_users_items_per_page');
if ($perPage) {
$itemPerPage = (int) $perPage;
}
$table = new SortableTable(
'tracking_work_student',
'get_count_users',
'get_users',
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
$itemPerPage
);
$parameters = ['cidReq' => $courseCode, 'id_session' => $sessionId];
$table->set_additional_parameters($parameters);
if ($is_western_name_order) {
$table->set_header(0, get_lang('FirstName'), false);
$table->set_header(1, get_lang('LastName'), false);
} else {
$table->set_header(0, get_lang('LastName'), false);
$table->set_header(1, get_lang('FirstName'), false);
}
$table->set_header(2, get_lang('TimeSpentInTheCourse'), false);
$table->set_header(3, get_lang('TimeSpentInWork'), false);
$table->set_header(4, get_lang('Status'), false);
Display::display_header($nameTools);
echo $toolbar;
echo Display::page_subheader($nameTools);
$table->display();
Display::display_footer();

@ -305,7 +305,7 @@ if (count($_POST) > 0) {
} else { } else {
// All the other question types (open question, multiple choice, percentage, ...) // All the other question types (open question, multiple choice, percentage, ...)
if (isset($types[$survey_question_id]) && if (isset($types[$survey_question_id]) &&
'percentage' == $types[$survey_question_id]) { 'percentage' === $types[$survey_question_id]) {
$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
@ -378,7 +378,6 @@ if (count($_POST) > 0) {
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
$option_value = $row['value']; $option_value = $row['value'];
//$option_value = 0;
$survey_question_answer = $value; $survey_question_answer = $value;
// We save the answer after making sure that a possible previous attempt is deleted // We save the answer after making sure that a possible previous attempt is deleted
@ -406,7 +405,6 @@ if (count($_POST) > 0) {
} }
$user_id = api_get_user_id(); $user_id = api_get_user_id();
if ($user_id == 0) { if ($user_id == 0) {
$user_id = $survey_invitation['user']; $user_id = $survey_invitation['user'];
} }
@ -1079,7 +1077,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') ||
$questions = []; $questions = [];
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
// If the type is not a pagebreak we store it in the $questions array // If the type is not a pagebreak we store it in the $questions array
if ('pagebreak' != $row['type']) { if ('pagebreak' !== $row['type']) {
$questions[$row['sort']]['question_id'] = $row['question_id']; $questions[$row['sort']]['question_id'] = $row['question_id'];
$questions[$row['sort']]['survey_id'] = $row['survey_id']; $questions[$row['sort']]['survey_id'] = $row['survey_id'];
$questions[$row['sort']]['survey_question'] = $row['survey_question']; $questions[$row['sort']]['survey_question'] = $row['survey_question'];
@ -1193,7 +1191,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') ||
$questions = []; $questions = [];
while ($row = Database :: fetch_array($result, 'ASSOC')) { while ($row = Database :: fetch_array($result, 'ASSOC')) {
// If the type is not a pagebreak we store it in the $questions array // If the type is not a pagebreak we store it in the $questions array
if ('pagebreak' != $row['type']) { if ('pagebreak' !== $row['type']) {
$questions[$row['sort']]['question_id'] = $row['question_id']; $questions[$row['sort']]['question_id'] = $row['question_id'];
$questions[$row['sort']]['survey_id'] = $row['survey_id']; $questions[$row['sort']]['survey_id'] = $row['survey_id'];
$questions[$row['sort']]['survey_question'] = $row['survey_question']; $questions[$row['sort']]['survey_question'] = $row['survey_question'];
@ -1270,6 +1268,11 @@ $form = new FormValidator(
); );
$form->addHidden('language', $p_l); $form->addHidden('language', $p_l);
$showNumber = true;
if (SurveyManager::hasDependency($survey_data)) {
$showNumber = false;
}
if (isset($questions) && is_array($questions)) { if (isset($questions) && is_array($questions)) {
$originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0; $originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0;
$questionCounter = 1; $questionCounter = 1;
@ -1306,7 +1309,9 @@ if (isset($questions) && is_array($questions)) {
// @todo move this in a function. // @todo move this in a function.
$form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">'); $form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">');
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$questionNumber.'. </div>'); $form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$questionNumber.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> '); $form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$userAnswerData = SurveyUtil::get_answers_of_question_by_user($question['survey_id'], $question['question_id']); $userAnswerData = SurveyUtil::get_answers_of_question_by_user($question['survey_id'], $question['question_id']);

@ -93,13 +93,13 @@ if (isset($_GET['show'])) {
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
if (1 == $survey_data['one_question_per_page']) { if (1 == $survey_data['one_question_per_page']) {
if ('pagebreak' != $row['type']) { if ('pagebreak' !== $row['type']) {
$paged_questions[$counter][] = $row['question_id']; $paged_questions[$counter][] = $row['question_id'];
$counter++; $counter++;
continue; continue;
} }
} else { } else {
if ('pagebreak' == $row['type']) { if ('pagebreak' === $row['type']) {
$counter++; $counter++;
} else { } else {
$paged_questions[$counter][] = $row['question_id']; $paged_questions[$counter][] = $row['question_id'];
@ -143,7 +143,7 @@ if (isset($_GET['show'])) {
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
// If the type is not a pagebreak we store it in the $questions array // If the type is not a pagebreak we store it in the $questions array
if ('pagebreak' != $row['type']) { if ('pagebreak' !== $row['type']) {
$sort = $row['sort']; $sort = $row['sort'];
$questions[$sort]['question_id'] = $row['question_id']; $questions[$sort]['question_id'] = $row['question_id'];
$questions[$sort]['survey_id'] = $row['survey_id']; $questions[$sort]['survey_id'] = $row['survey_id'];
@ -191,6 +191,11 @@ if (is_array($questions) && count($questions) > 0) {
$counter = $before + 1; $counter = $before + 1;
} }
$showNumber = true;
if (SurveyManager::hasDependency($survey_data)) {
$showNumber = false;
}
$js = ''; $js = '';
foreach ($questions as $key => &$question) { foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type']; $ch_type = 'ch_'.$question['type'];
@ -211,7 +216,9 @@ if (is_array($questions) && count($questions) > 0) {
$js .= survey_question::getQuestionJs($question); $js .= survey_question::getQuestionJs($question);
$form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">'); $form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">');
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$counter.'. </div>'); $form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$counter.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> '); $form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$display->render($form, $question); $display->render($form, $question);
$form->addHtml('</div>'); $form->addHtml('</div>');

@ -2515,6 +2515,42 @@ class SurveyManager
return true; return true;
} }
public static function hasDependency($survey)
{
if (false === api_get_configuration_value('survey_question_dependency')) {
return false;
}
if (empty($survey)) {
return false;
}
if (!isset($survey['survey_id'])) {
return false;
}
$courseId = (int) $survey['c_id'];
$surveyId = (int) $survey['survey_id'];
$table = Database::get_course_table(TABLE_SURVEY_QUESTION);
$sql = "SELECT COUNT(iid) count FROM $table
WHERE
c_id = $courseId AND
survey_id = $surveyId AND
parent_option_id <> 0
LIMIT 1
";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if ($row) {
return $row['count'] > 0;
}
return false;
}
/** /**
* @param array $survey * @param array $survey
* *
@ -2526,8 +2562,8 @@ class SurveyManager
return 0; return 0;
} }
$courseId = $survey['c_id']; $courseId = (int) $survey['c_id'];
$surveyId = $survey['survey_id']; $surveyId = (int) $survey['survey_id'];
$table = Database::get_course_table(TABLE_SURVEY_QUESTION); $table = Database::get_course_table(TABLE_SURVEY_QUESTION);
@ -2625,7 +2661,8 @@ class SurveyManager
$groupId = 0 $groupId = 0
) { ) {
$invitationRepo = Database::getManager()->getRepository('ChamiloCourseBundle:CSurveyInvitation'); $invitationRepo = Database::getManager()->getRepository('ChamiloCourseBundle:CSurveyInvitation');
$invitations = $invitationRepo->findBy(
return $invitationRepo->findBy(
[ [
'user' => $userId, 'user' => $userId,
'cId' => $courseId, 'cId' => $courseId,
@ -2635,8 +2672,6 @@ class SurveyManager
], ],
['invitationDate' => 'DESC'] ['invitationDate' => 'DESC']
); );
return $invitations;
} }
/** /**
@ -2694,7 +2729,12 @@ class SurveyManager
if (empty($sessionId)) { if (empty($sessionId)) {
$subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode); $subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode);
} else { } else {
$subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode, true, $sessionId); $subscribe = CourseManager::is_user_subscribed_in_course(
$userId,
$courseCode,
true,
$sessionId
);
} }
// User is not subscribe skip! // User is not subscribe skip!

@ -3,8 +3,6 @@
use Chamilo\PluginBundle\Entity\WhispeakAuth\LogEvent; use Chamilo\PluginBundle\Entity\WhispeakAuth\LogEvent;
$cidReset = true;
require_once __DIR__.'/../../../main/inc/global.inc.php'; require_once __DIR__.'/../../../main/inc/global.inc.php';
api_block_anonymous_users(false); api_block_anonymous_users(false);

@ -4,8 +4,6 @@
use Chamilo\PluginBundle\WhispeakAuth\Controller\AuthenticationController; use Chamilo\PluginBundle\WhispeakAuth\Controller\AuthenticationController;
use Chamilo\PluginBundle\WhispeakAuth\Controller\EnrollmentController; use Chamilo\PluginBundle\WhispeakAuth\Controller\EnrollmentController;
$cidReset = true;
require_once __DIR__.'/../../../main/inc/global.inc.php'; require_once __DIR__.'/../../../main/inc/global.inc.php';
$action = isset($_POST['action']) ? $_POST['action'] : 'enrollment'; $action = isset($_POST['action']) ? $_POST['action'] : 'enrollment';

Loading…
Cancel
Save