diff --git a/main/gradebook/lib/be/exerciselink.class.php b/main/gradebook/lib/be/exerciselink.class.php index 169d0a8141..dc6af44323 100755 --- a/main/gradebook/lib/be/exerciselink.class.php +++ b/main/gradebook/lib/be/exerciselink.class.php @@ -102,10 +102,12 @@ class ExerciseLink extends AbstractLink } $cats = []; + $exerciseList = []; if (isset($result)) { if (Database::num_rows($result) > 0) { while ($data = Database::fetch_array($result)) { $cats[] = [$data['iid'], $data['title']]; + $exerciseList[] = $data; } } } @@ -138,12 +140,22 @@ class ExerciseLink extends AbstractLink } if (!empty($exerciseInLP)) { + $allExercises = array_column($exerciseList, 'iid'); + foreach ($exerciseInLP as $exercise) { - $lpName = strip_tags($exercise['lp_name']); - $cats[] = [ + if (in_array($exercise['iid'], $allExercises)) { + continue; + } + $allExercises[] = $exercise['iid']; + //$lpName = strip_tags($exercise['lp_name']); + /*$cats[] = [ $exercise['iid'], strip_tags(Exercise::get_formated_title_variable($exercise['title'])). ' ('.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(); $courseId = $this->getCourseId(); $exerciseData = $this->get_exercise_data(); - $exerciseId = isset($exerciseData['id']) ? (int) $exerciseData['id'] : 0; $stud_id = (int) $stud_id; @@ -280,26 +291,32 @@ class ExerciseLink extends AbstractLink c_id = $courseId "; } else { - $lpId = null; + $lpCondition = null; if (!empty($exercise->lpList)) { - $lpId = $exercise->getLpBySession($sessionId); - $lpId = $lpId['lp_id']; + //$lpId = $exercise->getLpBySession($sessionId); + $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 * FROM $tblStats WHERE exe_exo_id = $exerciseId AND - orig_lp_id = $lpId AND + $lpCondition status <> 'incomplete' AND session_id = $sessionId AND c_id = $courseId "; } - if (!empty($stud_id) && 'ranking' != $type) { + if (!empty($stud_id) && 'ranking' !== $type) { $sql .= " AND exe_user_id = $stud_id "; } - $sql .= ' ORDER BY exe_id DESC'; + $sql .= ' ORDER BY exe_id DESC '; } else { $sql = "SELECT * FROM $tblHp hp INNER JOIN $tblDoc doc @@ -346,7 +363,6 @@ class ExerciseLink extends AbstractLink $bestResult = 0; $weight = 0; $sumResult = 0; - $studentList = $this->getStudentList(); $studentIdList = []; if (!empty($studentList)) { diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 05b7ec7fa2..bbe501dd5d 100755 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -1,4 +1,5 @@ '. Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM).''; - $pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null; - $perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null; + $pageNum = isset($_GET['flatviewlist_page_nr']) ? (int) $_GET['flatviewlist_page_nr'] : null; + $perPage = isset($_GET['flatviewlist_per_page']) ? (int) $_GET['flatviewlist_per_page'] : null; $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $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().'">'. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).''; - 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 ) { $actionsRight .= ''; if ($is_course_admin) { - $header .= ''.Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).''; - $header .= ''.Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).''; + $header .= ''. + Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).''; + $header .= ''. + Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).''; } elseif (!(isset($_GET['studentoverview']))) { - $header .= ''.Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').''; + $header .= ''. + Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').''; } else { - $header .= ''.Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).''; + $header .= ''. + Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).''; } $header .= ''; echo $header; @@ -674,8 +679,10 @@ class DisplayGradebook for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($userId); - $my_score_denom = ($score[1] == 0) ? 1 : $score[1]; - $item_value += $score[0] / $my_score_denom * $item->get_weight(); + if ($score) { + $my_score_denom = ($score[1] == 0) ? 1 : $score[1]; + $item_value += $score[0] / $my_score_denom * $item->get_weight(); + } $item_total += $item->get_weight(); } $item_value = api_number_format($item_value, 2); @@ -688,7 +695,7 @@ class DisplayGradebook $info .= '
'; $info .= get_lang('Name').' : '.$user['complete_name_with_message_link'].'
'; - if (api_get_setting('show_email_addresses') == 'true') { + if (api_get_setting('show_email_addresses') === 'true') { $info .= get_lang('Email').' : '.$user['email'].'
'; } diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index 645e7a8b1f..cf13e4a86a 100755 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -1239,10 +1239,10 @@ class GradebookTable extends SortableTable $extra .= $item->getSkillsFromItem(); $text .= " ".$extra.$show_message; - if ($item instanceof ExerciseLink) { + /*if ($item instanceof ExerciseLink) { $spaces = str_repeat(' ', $spaces); $text .= '

'.$spaces.$item->getLpListToString(); - } + }*/ $cc = $this->currentcat->get_course_code(); if (empty($cc)) { diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index d18ce82346..fd670b9741 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -202,9 +202,9 @@ class FlatViewDataGenerator $label = $item->get_name(); } - if ($item instanceof ExerciseLink) { + /*if ($item instanceof ExerciseLink) { $label .= '

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

'.$item->getLpListToString(); - } + }*/ $headers[] = $label; } diff --git a/main/gradebook/user_stats.php b/main/gradebook/user_stats.php index 2b042db816..012323bc59 100755 --- a/main/gradebook/user_stats.php +++ b/main/gradebook/user_stats.php @@ -1,4 +1,5 @@ content_to_pdf($html); exit; } -$actions = '
'; +$actions = '
'; if (!empty($categoryId)) { $interbreadcrumb[] = [ 'url' => 'gradebook_flatview.php?selectcat='.$categoryId.'&'.api_get_cidreq(), @@ -130,5 +131,5 @@ $actions .= '
'; Display::display_header(get_lang('ResultsPerUser')); echo $actions; DisplayGradebook::display_header_user($_GET['userid'], $category[0]->get_id()); -$user_table->display(); +$userTable->display(); Display::display_footer(); diff --git a/main/mySpace/work_stats.php b/main/mySpace/work_stats.php new file mode 100644 index 0000000000..f7081b0925 --- /dev/null +++ b/main/mySpace/work_stats.php @@ -0,0 +1,205 @@ + 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(); diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index f8cdbe36a1..14b70575a5 100755 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -305,7 +305,7 @@ if (count($_POST) > 0) { } else { // All the other question types (open question, multiple choice, percentage, ...) if (isset($types[$survey_question_id]) && - 'percentage' == $types[$survey_question_id]) { + 'percentage' === $types[$survey_question_id]) { $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND @@ -378,7 +378,6 @@ if (count($_POST) > 0) { $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); $option_value = $row['value']; - //$option_value = 0; $survey_question_answer = $value; // 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(); - if ($user_id == 0) { $user_id = $survey_invitation['user']; } @@ -1079,7 +1077,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') || $questions = []; while ($row = Database::fetch_array($result, 'ASSOC')) { // 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']]['survey_id'] = $row['survey_id']; $questions[$row['sort']]['survey_question'] = $row['survey_question']; @@ -1193,7 +1191,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') || $questions = []; while ($row = Database :: fetch_array($result, 'ASSOC')) { // 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']]['survey_id'] = $row['survey_id']; $questions[$row['sort']]['survey_question'] = $row['survey_question']; @@ -1270,6 +1268,11 @@ $form = new FormValidator( ); $form->addHidden('language', $p_l); +$showNumber = true; +if (SurveyManager::hasDependency($survey_data)) { + $showNumber = false; +} + if (isset($questions) && is_array($questions)) { $originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0; $questionCounter = 1; @@ -1306,7 +1309,9 @@ if (isset($questions) && is_array($questions)) { // @todo move this in a function. $form->addHtml('
'); - $form->addHtml('
'.$questionNumber.'.
'); + if ($showNumber) { + $form->addHtml('
'.$questionNumber.'.
'); + } $form->addHtml('
'.Security::remove_XSS($question['survey_question']).'
'); $userAnswerData = SurveyUtil::get_answers_of_question_by_user($question['survey_id'], $question['question_id']); diff --git a/main/survey/preview.php b/main/survey/preview.php index 77b45acced..bbe2c43a1b 100755 --- a/main/survey/preview.php +++ b/main/survey/preview.php @@ -93,13 +93,13 @@ if (isset($_GET['show'])) { if (Database::num_rows($result)) { while ($row = Database::fetch_array($result)) { if (1 == $survey_data['one_question_per_page']) { - if ('pagebreak' != $row['type']) { + if ('pagebreak' !== $row['type']) { $paged_questions[$counter][] = $row['question_id']; $counter++; continue; } } else { - if ('pagebreak' == $row['type']) { + if ('pagebreak' === $row['type']) { $counter++; } else { $paged_questions[$counter][] = $row['question_id']; @@ -143,7 +143,7 @@ if (isset($_GET['show'])) { $result = Database::query($sql); while ($row = Database::fetch_array($result)) { // 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']; $questions[$sort]['question_id'] = $row['question_id']; $questions[$sort]['survey_id'] = $row['survey_id']; @@ -191,6 +191,11 @@ if (is_array($questions) && count($questions) > 0) { $counter = $before + 1; } + $showNumber = true; + if (SurveyManager::hasDependency($survey_data)) { + $showNumber = false; + } + $js = ''; foreach ($questions as $key => &$question) { $ch_type = 'ch_'.$question['type']; @@ -211,7 +216,9 @@ if (is_array($questions) && count($questions) > 0) { $js .= survey_question::getQuestionJs($question); $form->addHtml('
'); - $form->addHtml('
'.$counter.'.
'); + if ($showNumber) { + $form->addHtml('
'.$counter.'.
'); + } $form->addHtml('
'.Security::remove_XSS($question['survey_question']).'
'); $display->render($form, $question); $form->addHtml('
'); diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index 970d9a7e54..e384344a48 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -2515,6 +2515,42 @@ class SurveyManager 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 * @@ -2526,8 +2562,8 @@ class SurveyManager return 0; } - $courseId = $survey['c_id']; - $surveyId = $survey['survey_id']; + $courseId = (int) $survey['c_id']; + $surveyId = (int) $survey['survey_id']; $table = Database::get_course_table(TABLE_SURVEY_QUESTION); @@ -2625,7 +2661,8 @@ class SurveyManager $groupId = 0 ) { $invitationRepo = Database::getManager()->getRepository('ChamiloCourseBundle:CSurveyInvitation'); - $invitations = $invitationRepo->findBy( + + return $invitationRepo->findBy( [ 'user' => $userId, 'cId' => $courseId, @@ -2635,8 +2672,6 @@ class SurveyManager ], ['invitationDate' => 'DESC'] ); - - return $invitations; } /** @@ -2694,7 +2729,12 @@ class SurveyManager if (empty($sessionId)) { $subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode); } 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! diff --git a/plugin/whispeakauth/ajax/authentify_password.php b/plugin/whispeakauth/ajax/authentify_password.php index 8c633f53e7..ef75d7b675 100644 --- a/plugin/whispeakauth/ajax/authentify_password.php +++ b/plugin/whispeakauth/ajax/authentify_password.php @@ -3,8 +3,6 @@ use Chamilo\PluginBundle\Entity\WhispeakAuth\LogEvent; -$cidReset = true; - require_once __DIR__.'/../../../main/inc/global.inc.php'; api_block_anonymous_users(false); diff --git a/plugin/whispeakauth/ajax/record_audio.php b/plugin/whispeakauth/ajax/record_audio.php index c3418be4a7..f0d8bf9458 100644 --- a/plugin/whispeakauth/ajax/record_audio.php +++ b/plugin/whispeakauth/ajax/record_audio.php @@ -4,8 +4,6 @@ use Chamilo\PluginBundle\WhispeakAuth\Controller\AuthenticationController; use Chamilo\PluginBundle\WhispeakAuth\Controller\EnrollmentController; -$cidReset = true; - require_once __DIR__.'/../../../main/inc/global.inc.php'; $action = isset($_POST['action']) ? $_POST['action'] : 'enrollment';