}
set_time_limit(0);
ini_set('max_execution_time', 0);
//extra javascript functions for in html head:
$htmlHeadXtra[] = "<script>\nfunction confirmation() {\n\tif (confirm(\" " . trim(get_lang('AreYouSureToDelete')) . " ?\")) {\n\t    return true;\n\t} else {\n\t    return false;\n\t}\n}\n</script>";
api_block_anonymous_users();
if (!api_is_allowed_to_edit() && !api_is_student_boss()) {
    api_not_allowed(true);
}
$cat_id = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : null;
$action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
$filterOfficialCode = isset($_POST['filter']) ? Security::remove_XSS($_POST['filter']) : null;
$filterOfficialCodeGet = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
switch ($action) {
    case 'export_all_certificates':
        if (api_is_student_boss()) {
            $userGroup = new UserGroup();
            $userList = $userGroup->getGroupUsersByUser(api_get_user_id());
        } else {
            $userList = array();
            if (!empty($filterOfficialCodeGet)) {
                $userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet);
            }
        }
        Category::exportAllCertificates($cat_id, $userList);
        break;
    case 'generate_all_certificates':
        $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
        if (!empty($user_list)) {
            foreach ($user_list as $user_info) {
                if ($user_info['status'] == INVITEE) {
示例#2
0
     } else {
         $columns = array('type', 'title', 'qualification', 'sent_date', 'actions');
     }
     $documents = getAllDocumentToWork($work_id, api_get_course_int_id());
     if (empty($documents)) {
         $whereCondition .= " AND u.user_id = " . api_get_user_id();
         $result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $whereCondition);
     } else {
         $result = get_work_user_list_from_documents($start, $limit, $sidx, $sord, $work_id, api_get_user_id(), $whereCondition);
     }
     break;
 case 'get_exercise_results':
     $course = api_get_course_info();
     // Used inside ExerciseLib::get_exam_results_data()
     $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
     if ($is_allowedToEdit || api_is_student_boss()) {
         $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'user_ip', 'status', 'lp', 'actions');
         $officialCodeInList = api_get_setting('exercise.show_official_code_exercise_result_list');
         if ($officialCodeInList === 'true') {
             $columns = array_merge(array('official_code'), $columns);
         }
     }
     $result = ExerciseLib::get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $whereCondition);
     break;
 case 'get_hotpotatoes_exercise_results':
     $course = api_get_course_info();
     $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
     if (api_is_allowed_to_edit()) {
         $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions');
     } else {
         $columns = array('exe_date', 'score', 'actions');
 */
//require_once '../inc/global.inc.php';
// Setting the tabs
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = api_get_jqgrid_js();
// Access control
api_protect_course_script(true, false, true);
// including additional libraries
require_once 'hotpotatoes.lib.php';
$_course = api_get_course_info();
// document path
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
$origin = isset($origin) ? $origin : null;
$path = isset($_GET['path']) ? Security::remove_XSS($_GET['path']) : null;
/* 	Constants and variables */
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh() || api_is_student_boss();
$is_tutor = api_is_allowed_to_edit(true);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$allowCoachFeedbackExercises = api_get_setting('exercise.allow_coach_feedback_exercises') === 'true';
$course_id = api_get_course_int_id();
$exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null;
$filter_user = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_by_user']) : null;
$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
if (empty($exercise_id)) {
    api_not_allowed(true);
}
if (!$is_allowedToEdit && !$allowCoachFeedbackExercises) {
示例#4
0
 /**
  * @param int $filter
  * @param string $view
  * @return string
  */
 public function displayActions($view, $filter = 0)
 {
     $courseInfo = api_get_course_info();
     $actionsLeft = '';
     $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>";
     $courseCondition = '';
     if (!empty($courseInfo)) {
         $courseCondition = api_get_cidreq();
     }
     $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>";
     $form = '';
     if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) {
         $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type);
         $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type);
         if ($this->type == 'course') {
             if (!isset($_GET['action'])) {
                 $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE);
                 $attributes = array('multiple' => false, 'id' => 'select_form_id_search');
                 $selectedValues = $this->parseAgendaFilter($filter);
                 $this->showToForm($form, $selectedValues, $attributes);
                 $form = $form->returnForm();
             }
         }
     }
     if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) {
         if ($this->type == 'personal') {
             $form = null;
             if (!isset($_GET['action'])) {
                 $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE);
                 $sessions = SessionManager::get_sessions_by_user(api_get_user_id());
                 $form->addHidden('type', 'personal');
                 $sessions = array_column($sessions, 'session_name', 'session_id');
                 $sessions = ['0' => get_lang('SelectAnOption')] + $sessions;
                 $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']);
                 //$form->addButtonFilter(get_lang('Filter'));
                 //$renderer = $form->defaultRenderer();
                 //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>');
                 $form->addButtonReset(get_lang('Reset'));
                 $form = $form->returnForm();
             }
         }
     }
     $actionsRight = '';
     if ($view == 'calendar') {
         $actionsRight .= $form;
     }
     $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false);
     return $toolbar;
 }
示例#5
0
function get_users($from, $limit, $column, $direction)
{
    $active = isset($_GET['active']) ? $_GET['active'] : 1;
    $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
    $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
    $lastConnectionDate = null;
    if (!empty($sleepingDays)) {
        $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays . ' days ago'));
    }
    $is_western_name_order = api_is_western_name_order();
    $coach_id = api_get_user_id();
    $drhLoaded = false;
    if (api_is_drh()) {
        $column = 'u.user_id';
        if (api_drh_can_access_all_session_content()) {
            $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, $from, $limit, $column, $direction, $keyword, $active, $lastConnectionDate, null, null, api_is_student_boss() ? null : STUDENT);
            $drhLoaded = true;
        }
    }
    if ($drhLoaded == false) {
        $students = UserManager::getUsersFollowedByUser(api_get_user_id(), api_is_student_boss() ? null : STUDENT, false, false, false, $from, $limit, $column, $direction, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword);
    }
    $all_datas = array();
    foreach ($students as $student_data) {
        $student_id = $student_data['user_id'];
        if (isset($_GET['id_session'])) {
            $courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']);
        }
        $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0;
        $nb_courses_student = 0;
        if (!empty($courses)) {
            foreach ($courses as $course_code) {
                $courseInfo = api_get_course_info($course_code);
                $courseId = $courseInfo['real_id'];
                if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
                    $avg_time_spent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
                    $my_average = Tracking::get_avg_student_score($student_id, $course_code);
                    if (is_numeric($my_average)) {
                        $avg_student_score += $my_average;
                    }
                    $avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
                    $total_assignments += Tracking::count_student_assignments($student_id, $course_code);
                    $total_messages += Tracking::count_student_messages($student_id, $course_code);
                    $nb_courses_student++;
                }
            }
        }
        if ($nb_courses_student > 0) {
            $avg_time_spent = $avg_time_spent / $nb_courses_student;
            $avg_student_score = $avg_student_score / $nb_courses_student;
            $avg_student_progress = $avg_student_progress / $nb_courses_student;
        } else {
            $avg_time_spent = null;
            $avg_student_score = null;
            $avg_student_progress = null;
        }
        $row = array();
        if ($is_western_name_order) {
            $row[] = $student_data['firstname'];
            $row[] = $student_data['lastname'];
        } else {
            $row[] = $student_data['lastname'];
            $row[] = $student_data['firstname'];
        }
        $string_date = Tracking::get_last_connection_date($student_id, true);
        $first_date = Tracking::get_first_connection_date($student_id);
        $row[] = $first_date;
        $row[] = $string_date;
        if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '&id_coach=' . $coach_id . '&id_session=' . $_GET['id_session'] . '">
				          <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        } else {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '">
				             <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        }
        $row[] = $detailsLink;
        $all_datas[] = $row;
    }
    return $all_datas;
}
示例#6
0
<?php

/* For licensing terms, see /license.txt */
/**
 * Show the skills report
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
 * @package chamilo.social.skill
 */
//require_once '../inc/global.inc.php';
$isStudent = api_is_student();
$isStudentBoss = api_is_student_boss();
$isDRH = api_is_drh();
if (!$isStudent && !$isStudentBoss && !$isDRH) {
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php');
    exit;
}
$userId = api_get_user_id();
$skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tableRows = array();
//$tpl = new Template(get_lang('Skills'));
$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
$tplPath = null;
$tpl->addGlobal('allowSkillsTool', api_get_setting('skill.allow_skills_tool') == 'true');
$tpl->addGlobal('allowDrhSkillsManagement', api_get_setting('skill.allow_hr_skills_management') == 'true');
if ($isStudent) {
    $sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory\n            FROM {$skillTable} s\n            INNER JOIN {$skillRelUserTable} sru\n            ON s.id = sru.skill_id\n            INNER JOIN {$courseTable} c\n            ON sru.course_id = c.id\n            WHERE sru.user_id = {$userId}";
    $result = Database::query($sql);
    while ($resultData = Database::fetch_assoc($result)) {
        $tableRow = array('skillName' => $resultData['name'], 'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER), 'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_MEDIUM, null, true), 'courseName' => $resultData['title']);
示例#7
0
 /**
  * Gets the exam'data results
  * @todo this function should be moved in a library  + no global calls
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param int $exercise_id
  * @param null $extra_where_conditions
  * @param bool $get_count
  * @return array
  */
 public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
 {
     //@todo replace all this globals
     global $documentPath, $filter;
     $course_id = api_get_course_int_id();
     $sessionId = api_get_session_id();
     $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
     $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
     $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
     $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
     $TBL_GROUP = Database::get_course_table(TABLE_GROUP);
     $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
     $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
     $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
     $exercise_id = intval($exercise_id);
     $exercise_where = '';
     if (!empty($exercise_id)) {
         $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . '  ';
     }
     $hotpotatoe_where = '';
     if (!empty($_GET['path'])) {
         $hotpotatoe_path = Database::escape_string($_GET['path']);
         $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '"  ';
     }
     // sql for chamilo-type tests for teacher / tutor view
     $sql_inner_join_tbl_track_exercices = "\n        (\n            SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n            FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n            ON (ttte.exe_id = tr.exe_id)\n            WHERE\n                c_id = {$course_id} AND\n                exe_exo_id = {$exercise_id} AND\n                ttte.session_id = " . $sessionId . "\n        )";
     if ($is_allowedToEdit) {
         //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
         // Hack in order to filter groups
         $sql_inner_join_tbl_user = '';
         if (strpos($extra_where_conditions, 'group_id')) {
             $sql_inner_join_tbl_user = "\n                (\n                    SELECT\n                        u.user_id,\n                        firstname,\n                        lastname,\n                        official_code,\n                        email,\n                        username,\n                        g.name as group_name,\n                        g.id as group_id\n                    FROM {$TBL_USER} u\n                    INNER JOIN {$TBL_GROUP_REL_USER} gru\n                    ON (gru.user_id = u.user_id AND gru.c_id=" . $course_id . ")\n                    INNER JOIN {$TBL_GROUP} g\n                    ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n                )";
         }
         if (strpos($extra_where_conditions, 'group_all')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_all'  )", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions);
             $sql_inner_join_tbl_user = "\n                (\n                    SELECT\n                        u.user_id,\n                        firstname,\n                        lastname,\n                        official_code,\n                        email,\n                        username,\n                        '' as group_name,\n                        '' as group_id\n                    FROM {$TBL_USER} u\n                )";
             $sql_inner_join_tbl_user = null;
         }
         if (strpos($extra_where_conditions, 'group_none')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_none'  )", "AND (  group_id is null  )", $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND (  group_id is null  )", $extra_where_conditions);
             $sql_inner_join_tbl_user = "\n            (\n                SELECT\n                    u.user_id,\n                    firstname,\n                    lastname,\n                    official_code,\n                    email,\n                    username,\n                    g.name as group_name,\n                    g.id as group_id\n                FROM {$TBL_USER} u\n                LEFT OUTER JOIN {$TBL_GROUP_REL_USER} gru\n                ON ( gru.user_id = u.user_id AND gru.c_id=" . $course_id . " )\n                LEFT OUTER JOIN {$TBL_GROUP} g\n                ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n            )";
         }
         // All
         $is_empty_sql_inner_join_tbl_user = false;
         if (empty($sql_inner_join_tbl_user)) {
             $is_empty_sql_inner_join_tbl_user = true;
             $sql_inner_join_tbl_user = "\n            (\n                SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code\n                FROM {$TBL_USER} u\n                WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n            )";
         }
         $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru ";
         $sqlWhereOption = "  AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id ";
         $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
         if ($get_count) {
             $sql_select = "SELECT count(te.exe_id) ";
         } else {
             $sql_select = "SELECT DISTINCT\n                    user_id,\n                    {$first_and_last_name},\n                    official_code,\n                    ce.title,\n                    username,\n                    te.exe_result,\n                    te.exe_weighting,\n                    te.exe_date,\n                    te.exe_id,\n                    email as exemail,\n                    te.start_date,\n                    steps_counter,\n                    exe_user_id,\n                    te.exe_duration,\n                    propagate_neg,\n                    revised,\n                    group_name,\n                    group_id,\n                    orig_lp_id,\n                    te.user_ip";
         }
         $sql = " {$sql_select}\n                FROM {$TBL_EXERCICES} AS ce\n                INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n                ON (te.exe_exo_id = ce.id)\n                INNER JOIN {$sql_inner_join_tbl_user} AS user\n                ON (user.user_id = exe_user_id)\n                WHERE\n                    te.status != 'incomplete' AND\n                    te.c_id = " . $course_id . " {$session_id_and} AND\n                    ce.active <>-1 AND ce.c_id = " . $course_id . "\n                    {$exercise_where}\n                    {$extra_where_conditions}\n                ";
         // sql for hotpotatoes tests for teacher / tutor view
         if ($get_count) {
             $hpsql_select = "SELECT count(username)";
         } else {
             $hpsql_select = "SELECT\n                    {$first_and_last_name} ,\n                    username,\n                    official_code,\n                    tth.exe_name,\n                    tth.exe_result ,\n                    tth.exe_weighting,\n                    tth.exe_date";
         }
         $hpsql = " {$hpsql_select}\n                FROM\n                    {$TBL_TRACK_HOTPOTATOES} tth,\n                    {$TBL_USER} user\n                    {$sqlFromOption}\n                WHERE\n                    user.user_id=tth.exe_user_id\n                    AND tth.c_id = " . $course_id . "\n                    {$hotpotatoe_where}\n                    {$sqlWhereOption}\n                    AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n                ORDER BY\n                    tth.c_id ASC,\n                    tth.exe_date DESC";
     }
     if ($get_count) {
         $resx = Database::query($sql);
         $rowx = Database::fetch_row($resx, 'ASSOC');
         return $rowx[0];
     }
     $teacher_list = CourseManager::getTeacherListFromCourse(api_get_course_int_id());
     $teacher_id_list = array();
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher) {
             $teacher_id_list[] = $teacher['user_id'];
         }
     }
     $list_info = array();
     // Simple exercises
     if (empty($hotpotatoe_where)) {
         $column = !empty($column) ? Database::escape_string($column) : null;
         $from = intval($from);
         $number_of_items = intval($number_of_items);
         if (!empty($column)) {
             $sql .= " ORDER BY {$column} {$direction} ";
         }
         $sql .= " LIMIT {$from}, {$number_of_items}";
         $results = array();
         $resx = Database::query($sql);
         while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
             $results[] = $rowx;
         }
         $group_list = GroupManager::get_group_list();
         $clean_group_list = array();
         if (!empty($group_list)) {
             foreach ($group_list as $group) {
                 $clean_group_list[$group['id']] = $group['name'];
             }
         }
         $lp_list_obj = new LearnpathList(api_get_user_id());
         $lp_list = $lp_list_obj->get_flat_list();
         if (is_array($results)) {
             $users_array_id = array();
             $from_gradebook = false;
             if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
                 $from_gradebook = true;
             }
             $sizeof = count($results);
             $user_list_id = array();
             $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
             // Looping results
             for ($i = 0; $i < $sizeof; $i++) {
                 $revised = $results[$i]['revised'];
                 if ($from_gradebook && $is_allowedToEdit) {
                     if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) {
                         continue;
                     }
                     $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'];
                 }
                 $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null;
                 $lp_name = null;
                 if ($lp_obj) {
                     $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
                     $lp_name = Display::url($lp_obj['lp_name'], $url, array('target' => '_blank'));
                 }
                 //Add all groups by user
                 $group_name_list = null;
                 if ($is_empty_sql_inner_join_tbl_user) {
                     $group_list = GroupManager::get_group_ids(api_get_course_int_id(), $results[$i]['user_id']);
                     foreach ($group_list as $id) {
                         $group_name_list .= $clean_group_list[$id] . '<br/>';
                     }
                     $results[$i]['group_name'] = $group_name_list;
                 }
                 $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0;
                 $user_list_id[] = $results[$i]['exe_user_id'];
                 $id = $results[$i]['exe_id'];
                 $dt = api_convert_and_format_date($results[$i]['exe_weighting']);
                 // we filter the results if we have the permission to
                 if (isset($results[$i]['results_disabled'])) {
                     $result_disabled = intval($results[$i]['results_disabled']);
                 } else {
                     $result_disabled = 0;
                 }
                 if ($result_disabled == 0) {
                     $my_res = $results[$i]['exe_result'];
                     $my_total = $results[$i]['exe_weighting'];
                     $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']);
                     $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']);
                     if (!$results[$i]['propagate_neg'] && $my_res < 0) {
                         $my_res = 0;
                     }
                     $score = self::show_score($my_res, $my_total);
                     $actions = '';
                     if ($is_allowedToEdit) {
                         if (isset($teacher_id_list)) {
                             if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) {
                                 $actions .= Display::return_icon('teachers.gif', get_lang('Teacher'));
                             }
                         }
                         if ($revised) {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id={$id}'>" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL);
                             $actions .= '&nbsp;';
                         } else {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id={$id}'>" . Display::return_icon('quiz.gif', get_lang('Qualify'));
                             $actions .= '&nbsp;';
                         }
                         $actions .= "</a>";
                         if ($filter == 2) {
                             $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . Display::return_icon('history.gif', get_lang('ViewHistoryChange')) . '</a>';
                         }
                         //Admin can always delete the attempt
                         if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
                             $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false);
                             $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">';
                             $actions .= Display::return_icon('info.png', $ip, ['title' => $ip]);
                             $actions .= '</a>';
                             $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user=' . intval($_GET['filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '"
                             onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $results[$i]['username'], $dt) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
                             $delete_link = utf8_encode($delete_link);
                             if (api_is_drh() && !api_is_platform_admin()) {
                                 $delete_link = null;
                             }
                             $actions .= $delete_link . '&nbsp;';
                         }
                     } else {
                         $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
                         $attempt_link = Display::url(get_lang('Show'), $attempt_url, ['class' => 'ajax btn btn-default', 'data-title' => get_lang('Show')]);
                         $actions .= $attempt_link;
                     }
                     if ($revised) {
                         $revised = Display::label(get_lang('Validated'), 'success');
                     } else {
                         $revised = Display::label(get_lang('NotValidated'), 'info');
                     }
                     if ($is_allowedToEdit) {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['lp'] = $lp_name;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     } else {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     }
                 }
             }
         }
     } else {
         $hpresults = StatsUtils::getManyResultsXCol($hpsql, 6);
         // Print HotPotatoes test results.
         if (is_array($hpresults)) {
             for ($i = 0; $i < sizeof($hpresults); $i++) {
                 $hp_title = GetQuizName($hpresults[$i][3], $documentPath);
                 if ($hp_title == '') {
                     $hp_title = basename($hpresults[$i][3]);
                 }
                 $hp_date = api_get_local_time($hpresults[$i][6], null, date_default_timezone_get());
                 $hp_result = round($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1) * 100, 2) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')';
                 if ($is_allowedToEdit) {
                     $list_info[] = array($hpresults[$i][0], $hpresults[$i][1], $hpresults[$i][2], '', $hp_title, '-', $hp_date, $hp_result, '-');
                 } else {
                     $list_info[] = array($hp_title, '-', $hp_date, $hp_result, '-');
                 }
             }
         }
     }
     return $list_info;
 }
示例#8
0
 /**
  * @param string $keyword
  * @param string $active
  * @param string $lastConnectionDate
  * @param array $sessionIdList
  * @param array $studentIdList
  * @param int $userStatus STUDENT|COURSEMANAGER constants
  *
  * @return array|int
  */
 public static function getCountUserTracking($keyword = null, $active = null, $lastConnectionDate = null, $sessionIdList = array(), $studentIdList = array(), $filterUserStatus = null)
 {
     $userId = api_get_user_id();
     $drhLoaded = false;
     if (api_is_drh()) {
         if (api_drh_can_access_all_session_content()) {
             $count = self::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, true, null, null, null, null, $keyword, $active, $lastConnectionDate, $sessionIdList, $studentIdList, $filterUserStatus);
             $drhLoaded = true;
         }
     }
     if ($drhLoaded == false) {
         $count = UserManager::getUsersFollowedByUser($userId, $filterUserStatus, false, false, true, null, null, null, null, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword);
     }
     return $count;
 }
示例#9
0
                         <param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=' . $questionId . '&exe_id=' . $id . '&from_db=1" />
                     </object>
                 </td>
             </tr>
             </table>';
         }
     }
 }
 if ($show_results) {
     if ($answerType != HOT_SPOT) {
         echo '</table>';
     }
 }
 $comnt = null;
 if ($show_results) {
     if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss() && $isCoachAllowedToEdit) {
         $isFeedbackAllowed = true;
     } else {
         if (!$isCoachAllowedToEdit && $allowCoachFeedbackExercises) {
             $isFeedbackAllowed = true;
         }
     }
     $marksname = '';
     if ($isFeedbackAllowed) {
         $name = "fckdiv" . $questionId;
         $marksname = "marksName" . $questionId;
         if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
             $url_name = get_lang('EditCommentsAndMarks');
         } else {
             if ($action == 'edit') {
                 $url_name = get_lang('EditIndividualComment');
示例#10
0
                // @todo delete the stats.track_e_exercises records.
                // First implement this http://support.chamilo.org/issues/1334
                $message = Display::return_message(get_lang('LPWasReset'), 'success');
            }
            break;
        default:
            break;
    }
    Security::clear_token();
}
// user info
$user_info = api_get_user_info($student_id);
$courses_in_session = array();
//See #4676
$drh_can_access_all_courses = false;
if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
    $drh_can_access_all_courses = true;
}
$courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
$courses_in_session_by_coach = array();
$sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
// RRHH or session admin
if (api_is_session_admin() || api_is_drh()) {
    $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
    $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
    if (!empty($session_by_session_admin)) {
        foreach ($session_by_session_admin as $session_coached_by_user) {
            $courses_followed_by_coach = Tracking::get_courses_list_from_session($session_coached_by_user['id']);
            $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
        }
    }
示例#11
0
 /**
  * Get HTML code block for user skills
  * @param int $userId The user ID
  * @return string
  */
 public static function getSkillBlock($userId)
 {
     if (api_get_setting('skill.allow_skills_tool') !== 'true') {
         return null;
     }
     $skill = new Skill();
     $ranking = $skill->get_user_skill_ranking($userId);
     $skills = $skill->get_user_skills($userId, true);
     return Container::getTemplating()->render('@template_style/social/skills_block.html.twig', ['ranking' => $ranking, 'skills' => $skills, 'user_id' => $userId, 'show_skills_report_link' => api_is_student() || api_is_student_boss() || api_is_drh()]);
 }
示例#12
0
function return_navigation_array()
{
    $navigation = array();
    $menu_navigation = array();
    $possible_tabs = get_tabs();
    // Campus Homepage
    if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
        $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    } else {
        $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    }
    if (api_get_user_id() && !api_is_anonymous()) {
        // My Courses
        if (api_get_setting('show_tabs', 'my_courses') == 'true') {
            $navigation['mycourses'] = $possible_tabs['mycourses'];
        } else {
            $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
        }
        // My Profile
        if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('social.allow_social_tool') != 'true') {
            $navigation['myprofile'] = $possible_tabs['myprofile'];
        } else {
            $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
        }
        // My Agenda
        if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
            $navigation['myagenda'] = $possible_tabs['myagenda'];
        } else {
            $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
        }
        // Gradebook
        if (api_get_setting('gradebook_enable') == 'true') {
            if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
                $navigation['mygradebook'] = $possible_tabs['mygradebook'];
            } else {
                $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
            }
        }
        // Reporting
        if (api_get_setting('show_tabs', 'reporting') == 'true') {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) {
                $navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        } else {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        }
        // Social Networking
        if (api_get_setting('show_tabs', 'social') == 'true') {
            if (api_get_setting('social.allow_social_tool') == 'true') {
                $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
            }
        } else {
            $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
        }
        // Dashboard
        if (api_get_setting('show_tabs', 'dashboard') == 'true') {
            if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
                $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
            }
        } else {
            $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
        }
        // Administration
        if (api_is_platform_admin(true)) {
            if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
                $navigation['platform_admin'] = $possible_tabs['platform_admin'];
            } else {
                $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
            }
        }
        // Reports
        if (!empty($possible_tabs['reports'])) {
            if (api_get_setting('show_tabs', 'reports') == 'true') {
                if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
                    $navigation['reports'] = $possible_tabs['reports'];
                }
            } else {
                $menu_navigation['reports'] = $possible_tabs['reports'];
            }
        }
        // Custom tabs
        $customTabs = getCustomTabs();
        if (!empty($customTabs)) {
            foreach ($customTabs as $tab) {
                if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' && isset($possible_tabs[$tab['subkey']])) {
                    $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                    $navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                } else {
                    if (isset($possible_tabs[$tab['subkey']])) {
                        $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                        $menu_navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                    }
                }
            }
        }
    }
    return array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
}
示例#13
0
 /**
  * Get HTML code block for user skills
  * @param int $userId The user ID
  * @return string
  */
 public static function getSkillBlock($userId)
 {
     if (api_get_setting('allow_skills_tool') !== 'true') {
         return null;
     }
     $entityManager = Database::getManager();
     $user = $entityManager->find('ChamiloUserBundle:User', $userId);
     if (!$user) {
         return null;
     }
     $achievedSkills = $user->getAchievedSkills();
     $ranking = $achievedSkills->count();
     $skillsInfo = [];
     foreach ($achievedSkills as $userSkill) {
         $skillsInfo[] = ['id' => $userSkill->getSkill()->getId(), 'name' => $userSkill->getSkill()->getName(), 'icon' => $userSkill->getSkill()->getWebIconPath(true), 'source_name' => $userSkill->getSourceName(), 'issue_url' => $userSkill->getIssueUrl()];
     }
     $template = new Template(null, false, false, false, false, false);
     $template->assign('ranking', $ranking);
     $template->assign('skills', $skillsInfo);
     $template->assign('show_skills_report_link', api_is_student() || api_is_student_boss() || api_is_drh());
     $skillBlock = $template->get_template('social/skills_block.tpl');
     return $template->fetch($skillBlock);
 }
示例#14
0
 /**
  * Get HTML code block for user skills
  * @param int $userId The user ID
  * @return string
  */
 public static function getSkillBlock($userId)
 {
     if (api_get_setting('allow_skills_tool') !== 'true') {
         return null;
     }
     $skill = new Skill();
     $ranking = $skill->get_user_skill_ranking($userId);
     $skills = $skill->get_user_skills($userId, true);
     $template = new Template(null, false, false, false, false, false);
     $template->assign('ranking', $ranking);
     $template->assign('skills', $skills);
     $template->assign('show_skills_report_link', api_is_student() || api_is_student_boss() || api_is_drh());
     $skillBlock = $template->get_template('social/skills_block.tpl');
     return $template->fetch($skillBlock);
 }