コード例 #1
0
function slide_presentation_quiz(Quiz $quiz, $name)
{
    global $tr;
    $manageCourse = new CourseManager();
    $c = $manageCourse->getById($quiz->getCourseId());
    return "<div class='sp-presentation-content'>\r\n            <div>\r\n                <h4><strong>" . $tr->__("Author") . "</strong>: " . $name . "</h4>\r\n                <h4><strong>" . $tr->__("Course") . "</strong>: " . $c->getName() . "</h4>\r\n                <h4><strong>" . $tr->__("Duration") . "</strong>: " . $quiz->getDuration() . " min</h4>\r\n            </div>\r\n            <h2>" . $quiz->getName() . "</h2>\r\n\r\n        </div>";
}
コード例 #2
0
ファイル: user_info.soap.php プロジェクト: KRCM13/chamilo-lms
/**
 * Get a list of courses (code, url, title, teacher, language) for a specific
 * user and return to caller
 * Function registered as service. Returns strings in UTF-8.
 * @param string User name in Chamilo
 * @param string Signature (composed of the sha1(username+apikey)
 * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
 */
function WSCourseListOfUser($username, $signature)
{
    if (empty($username) or empty($signature)) {
        return -1;
    }
    global $_configuration;
    $info = api_get_user_info_from_username($username);
    $user_id = $info['user_id'];
    $list = UserManager::get_api_keys($user_id, 'dokeos');
    $key = '';
    foreach ($list as $key) {
        break;
    }
    $local_key = $username . $key;
    if (!api_is_valid_secret_key($signature, $local_key)) {
        return -1;
        // The secret key is incorrect.
    }
    $courses_list = array();
    $courses_list_tmp = CourseManager::get_courses_list_by_user_id($user_id);
    foreach ($courses_list_tmp as $index => $course) {
        $course_info = CourseManager::get_course_information($course['code']);
        $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
    }
    return $courses_list;
}
コード例 #3
0
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $hotCourses = \CourseManager::returnHotCourses();
     return $this->renderResponse($blockContext->getTemplate(), array('hot_courses' => $hotCourses, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
コード例 #4
0
function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;
    $xajax_response = new xajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        // xajax send utf8 datas... datas in db can be non-utf8 datas
        $needle = Database::escape_string($needle);
        $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
        $assigned_courses_code = array_keys($assigned_courses_to_hrm);
        foreach ($assigned_courses_code as &$value) {
            $value = "'" . $value . "'";
        }
        $without_assigned_courses = '';
        if (count($assigned_courses_code) > 0) {
            $without_assigned_courses = " AND c.code NOT IN(" . implode(',', $assigned_courses_code) . ")";
        }
        if (api_is_multiple_url_enabled()) {
            $sql = "SELECT c.code, c.title\n                    FROM {$tbl_course} c\n\t\t\t\t\tLEFT JOIN {$tbl_course_rel_access_url} a\n                    ON (a.c_id = c.id)\n                \tWHERE\n                \t\tc.code LIKE '{$needle}%' {$without_assigned_courses} AND\n                \t\taccess_url_id = " . api_get_current_access_url_id();
        } else {
            $sql = "SELECT c.code, c.title\n            \t\tFROM {$tbl_course} c\n                \tWHERE\n                \t\tc.code LIKE '{$needle}%'\n                \t\t{$without_assigned_courses} ";
        }
        $rs = Database::query($sql);
        $return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
        while ($course = Database::fetch_array($rs)) {
            $return .= '<option value="' . $course['code'] . '" title="' . htmlspecialchars($course['title'], ENT_QUOTES) . '">' . $course['title'] . ' (' . $course['code'] . ')</option>';
        }
        $return .= '</select>';
        $xajax_response->addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
    }
    return $xajax_response;
}
コード例 #5
0
/**
 *
 */
function get_course_usage($course_code, $session_id = 0)
{
    $table = Database::get_main_table(TABLE_MAIN_COURSE);
    $course_code = Database::escape_string($course_code);
    $sql = "SELECT * FROM {$table} WHERE code='" . $course_code . "'";
    $res = Database::query($sql);
    $course = Database::fetch_object($res);
    // Learnpaths
    $table = Database::get_course_table(TABLE_LP_MAIN);
    $usage[] = array(get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Forums
    $table = Database::get_course_table(TABLE_FORUM);
    $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Quizzes
    $table = Database::get_course_table(TABLE_QUIZ_TEST);
    $usage[] = array(get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Documents
    $table = Database::get_course_table(TABLE_DOCUMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Groups
    $table = Database::get_course_table(TABLE_GROUP);
    $usage[] = array(get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Calendar
    $table = Database::get_course_table(TABLE_AGENDA);
    $usage[] = array(get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Link
    $table = Database::get_course_table(TABLE_LINK);
    $usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Announcements
    $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    return $usage;
}
コード例 #6
0
/**
 * Get a list of courses (code, url, title, teacher, language) and return to caller
 * Function registered as service. Returns strings in UTF-8.
 * @param string Security key (the Dokeos install's API key)
 * @param mixed  Array or string. Type of visibility of course (public, public-registered, private, closed)
 * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
 */
function courses_list($security_key, $visibilities = 'public')
{
    global $_configuration;
    // Check if this script is launch by server and if security key is ok.
    if ($security_key != $_configuration['security_key']) {
        return array('error_msg' => 'Security check failed');
    }
    $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
    $courses_list = array();
    if (!is_array($visibilities)) {
        $tmp = $visibilities;
        $visibilities = array($tmp);
    }
    foreach ($visibilities as $visibility) {
        if (!in_array($visibility, array_keys($vis))) {
            return array('error_msg' => 'Security check failed');
        }
        $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
        foreach ($courses_list_tmp as $index => $course) {
            $course_info = CourseManager::get_course_information($course['code']);
            $courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
        }
    }
    return $courses_list;
}
コード例 #7
0
/**
 *	@package chamilo.survey
 *	@author Arnaud Ligot <*****@*****.**>
 *	@version $Id: $
 *
 *	A small peace of code to enable user to access images included into survey
 *	which are accessible by non authenticated users. This file is included
 *	by document/download.php
 */
function check_download_survey($course, $invitation, $doc_url)
{
    require_once 'survey.lib.php';
    // Getting all the course information
    $_course = CourseManager::get_course_information($course);
    $course_id = $_course['real_id'];
    // Database table definitions
    $table_survey = Database::get_course_table(TABLE_SURVEY);
    $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
    $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
    $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
    // Now we check if the invitationcode is valid
    $sql = "SELECT * FROM {$table_survey_invitation}\n\t        WHERE\n\t            c_id = {$course_id} AND\n\t            invitation_code = '" . Database::escape_string($invitation) . "'";
    $result = Database::query($sql);
    if (Database::num_rows($result) < 1) {
        Display::display_error_message(get_lang('WrongInvitationCode'), false);
        Display::display_footer();
        exit;
    }
    $survey_invitation = Database::fetch_assoc($result);
    // Now we check if the user already filled the survey
    if ($survey_invitation['answered'] == 1) {
        Display::display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false);
        Display::display_footer();
        exit;
    }
    // Very basic security check: check if a text field from a survey/answer/option contains the name of the document requested
    // Fetch survey ID
    // If this is the case there will be a language choice
    $sql = "SELECT * FROM {$table_survey}\n\t        WHERE\n\t            c_id = {$course_id} AND\n\t            code='" . Database::escape_string($survey_invitation['survey_code']) . "'";
    $result = Database::query($sql);
    if (Database::num_rows($result) > 1) {
        if ($_POST['language']) {
            $survey_invitation['survey_id'] = $_POST['language'];
        } else {
            echo '<form id="language" name="language" method="POST" action="' . api_get_self() . '?course=' . $_GET['course'] . '&invitationcode=' . $_GET['invitationcode'] . '">';
            echo '  <select name="language">';
            while ($row = Database::fetch_assoc($result)) {
                echo '<option value="' . $row['survey_id'] . '">' . $row['lang'] . '</option>';
            }
            echo '</select>';
            echo '  <input type="submit" name="Submit" value="' . get_lang('Ok') . '" />';
            echo '</form>';
            display::display_footer();
            exit;
        }
    } else {
        $row = Database::fetch_assoc($result);
        $survey_invitation['survey_id'] = $row['survey_id'];
    }
    $sql = "SELECT count(*)\n\t        FROM {$table_survey}\n\t        WHERE\n\t            c_id = {$course_id} AND\n\t            survey_id = " . $survey_invitation['survey_id'] . " AND (\n                    title LIKE '%{$doc_url}%'\n                    or subtitle LIKE '%{$doc_url}%'\n                    or intro LIKE '%{$doc_url}%'\n                    or surveythanks LIKE '%{$doc_url}%'\n                )\n\t\t    UNION\n\t\t        SELECT count(*)\n\t\t        FROM {$table_survey_question}\n\t\t        WHERE\n\t\t            c_id = {$course_id} AND\n\t\t            survey_id = " . $survey_invitation['survey_id'] . " AND (\n                        survey_question LIKE '%{$doc_url}%'\n                        or survey_question_comment LIKE '%{$doc_url}%'\n                    )\n\t\t    UNION\n\t\t        SELECT count(*)\n\t\t        FROM {$table_survey_question_option}\n\t\t        WHERE\n\t\t            c_id = {$course_id} AND\n\t\t            survey_id = " . $survey_invitation['survey_id'] . " AND (\n                        option_text LIKE '%{$doc_url}%'\n                    )";
    $result = Database::query($sql);
    if (Database::num_rows($result) == 0) {
        Display::display_error_message(get_lang('WrongInvitationCode'), false);
        Display::display_footer();
        exit;
    }
    return $_course;
}
コード例 #8
0
 /**
  * Constructor
  */
 public function __construct($user_id)
 {
     $this->user_id = $user_id;
     $this->path = 'block_daily';
     if ($this->is_block_visible_for_user($user_id)) {
         $this->courses = CourseManager::get_courses_followed_by_drh($user_id);
     }
 }
コード例 #9
0
 function get_user_courses()
 {
     if (!is_null($this->_get_user_courses)) {
         return $this->_get_user_courses;
     }
     $user_id = $this->user_id;
     return $this->_get_user_courses = CourseManager::get_courses_list_by_user_id($user_id);
 }
コード例 #10
0
 public function get_course_title($username, $password, $course_code)
 {
     if ($this->verifyUserPass($username, $password) == "valid") {
         $course_info = CourseManager::get_course_information($course_code);
         return $course_info['title'];
     } else {
         return get_lang('InvalidId');
     }
 }
コード例 #11
0
ファイル: myagenda.inc.php プロジェクト: ragebat/chamilo-lms
/**
 *	This function retrieves all the agenda items of all the courses the user is subscribed to
 */
function get_myagendaitems($user_id, $courses_dbs, $month, $year)
{
    global $setting_agenda_link;
    $user_id = intval($user_id);
    $items = array();
    $my_list = array();
    // get agenda-items for every course
    foreach ($courses_dbs as $key => $array_course_info) {
        //databases of the courses
        $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
        $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
        $group_memberships = GroupManager::get_group_ids($array_course_info["real_id"], $user_id);
        $course_user_status = CourseManager::get_user_in_course_status($user_id, $array_course_info["code"]);
        // if the user is administrator of that course we show all the agenda items
        if ($course_user_status == '1') {
            //echo "course admin";
            $sqlquery = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref\n\t\t\t\t\t\t\tFROM " . $TABLEAGENDA . " agenda,\n\t\t\t\t\t\t\t\t " . $TABLE_ITEMPROPERTY . " ip\n\t\t\t\t\t\t\tWHERE agenda.id = ip.ref\n\t\t\t\t\t\t\tAND MONTH(agenda.start_date)='" . $month . "'\n\t\t\t\t\t\t\tAND YEAR(agenda.start_date)='" . $year . "'\n\t\t\t\t\t\t\tAND ip.tool='" . TOOL_CALENDAR_EVENT . "'\n\t\t\t\t\t\t\tAND ip.visibility='1'\n\t\t\t\t\t\t\tGROUP BY agenda.id\n\t\t\t\t\t\t\tORDER BY start_date ";
        } else {
            // if the user is not an administrator of that course
            if (is_array($group_memberships) && count($group_memberships) > 0) {
                $sqlquery = "SELECT\tagenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref\n\t\t\t\t\t\t\t\tFROM " . $TABLEAGENDA . " agenda,\n\t\t\t\t\t\t\t\t\t" . $TABLE_ITEMPROPERTY . " ip\n\t\t\t\t\t\t\t\tWHERE agenda.id = ip.ref\n\t\t\t\t\t\t\t\tAND MONTH(agenda.start_date)='" . $month . "'\n\t\t\t\t\t\t\t\tAND YEAR(agenda.start_date)='" . $year . "'\n\t\t\t\t\t\t\t\tAND ip.tool='" . TOOL_CALENDAR_EVENT . "'\n\t\t\t\t\t\t\t\tAND\t( ip.to_user_id='" . $user_id . "' OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") )\n\t\t\t\t\t\t\t\tAND ip.visibility='1'\n\t\t\t\t\t\t\t\tORDER BY start_date ";
            } else {
                $sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref\n\t\t\t\t\t\t\t\tFROM " . $TABLEAGENDA . " agenda,\n\t\t\t\t\t\t\t\t\t" . $TABLE_ITEMPROPERTY . " ip\n\t\t\t\t\t\t\t\tWHERE agenda.id = ip.ref\n\t\t\t\t\t\t\t\tAND MONTH(agenda.start_date)='" . $month . "'\n\t\t\t\t\t\t\t\tAND YEAR(agenda.start_date)='" . $year . "'\n\t\t\t\t\t\t\t\tAND ip.tool='" . TOOL_CALENDAR_EVENT . "'\n\t\t\t\t\t\t\t\tAND ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0')\n\t\t\t\t\t\t\t\tAND ip.visibility='1'\n\t\t\t\t\t\t\t\tORDER BY start_date ";
            }
        }
        $result = Database::query($sqlquery);
        while ($item = Database::fetch_array($result, 'ASSOC')) {
            $agendaday = -1;
            if ($item['start_date'] != '0000-00-00 00:00:00') {
                $item['start_date'] = api_get_local_time($item['start_date']);
                $item['start_date_tms'] = api_strtotime($item['start_date']);
                $agendaday = date("j", $item['start_date_tms']);
            }
            if ($item['end_date'] != '0000-00-00 00:00:00') {
                $item['end_date'] = api_get_local_time($item['end_date']);
            }
            $url = api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?cidReq=" . urlencode($array_course_info["code"]) . "&day={$agendaday}&month={$month}&year={$year}#{$agendaday}";
            $item['url'] = $url;
            $item['course_name'] = $array_course_info['title'];
            $item['calendar_type'] = 'course';
            $item['course_id'] = $array_course_info['course_id'];
            $my_list[$agendaday][] = $item;
        }
    }
    // sorting by hour for every day
    $agendaitems = array();
    while (list($agendaday, $tmpitems) = each($items)) {
        if (!isset($agendaitems[$agendaday])) {
            $agendaitems[$agendaday] = '';
        }
        sort($tmpitems);
        while (list($key, $val) = each($tmpitems)) {
            $agendaitems[$agendaday] .= $val;
        }
    }
    return $my_list;
}
コード例 #12
0
 /**
  * @Route("/courses/{cidReq}/{sessionId}")
  * @Method({"GET"})
  *
  * @param string $cidReq
  * @param int $id_session
  * @return Response
  */
 public function indexAction($cidReq, $id_session = null)
 {
     $courseCode = api_get_course_id();
     $sessionId = api_get_session_id();
     $userId = $this->getUser()->getUserId();
     $coursesAlreadyVisited = $this->getRequest()->getSession()->get('coursesAlreadyVisited');
     $result = $this->autolaunch();
     $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning'];
     $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning'];
     if ($showAutoLaunchLpWarning) {
         $this->getTemplate()->assign('lp_warning', Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'), 'warning'));
     }
     if ($showAutoLaunchExerciseWarning) {
         $this->getTemplate()->assign('exercise_warning', Display::return_message(get_lang('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'), 'warning'));
     }
     if ($this->isCourseTeacher()) {
         $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('course_home.controller:iconListAction', array('course' => api_get_course_id())));
         $this->getTemplate()->assign('edit_icons', $editIcons);
     }
     if (!isset($coursesAlreadyVisited[$courseCode])) {
         event_access_course();
         $coursesAlreadyVisited[$courseCode] = 1;
         $this->getRequest()->getSession()->set('coursesAlreadyVisited', $coursesAlreadyVisited);
     }
     $this->getRequest()->getSession()->remove('toolgroup');
     $this->getRequest()->getSession()->remove('_gid');
     $isSpecialCourse = \CourseManager::is_special_course($courseCode);
     if ($isSpecialCourse) {
         $autoreg = $this->getRequest()->get('autoreg');
         if ($autoreg == 1) {
             \CourseManager::subscribe_user($userId, $courseCode, STUDENT);
         }
     }
     $script = 'activity.php';
     if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') {
         $script = 'activity.php';
     } elseif (api_get_setting('homepage_view') == '2column') {
         $script = '2column.php';
     } elseif (api_get_setting('homepage_view') == '3column') {
         $script = '3column.php';
     } elseif (api_get_setting('homepage_view') == 'vertical_activity') {
         $script = 'vertical_activity.php';
     }
     $result = (require_once api_get_path(SYS_CODE_PATH) . 'course_home/' . $script);
     $toolList = $result['tool_list'];
     $this->getTemplate()->assign('icons', $result['content']);
     $introduction = Display::return_introduction_section($this->get('url_generator'), TOOL_COURSE_HOMEPAGE, $toolList);
     $this->getTemplate()->assign('introduction_text', $introduction);
     if (api_get_setting('show_session_data') == 'true' && $sessionId) {
         $sessionInfo = \CourseHome::show_session_data($sessionId);
         $this->getTemplate()->assign('session_info', $sessionInfo);
     }
     $response = $this->get('template')->render_template($this->getTemplatePath() . 'index.tpl');
     return new Response($response, 200, array());
 }
コード例 #13
0
/**
 * @param integer
 * @return void
 */
function exit_of_chat($user_id)
{
    $user_id = intval($user_id);
    $list_course = CourseManager::get_courses_list_by_user_id($user_id);
    $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
    foreach ($list_course as $course) {
        $response = user_connected_in_chat($user_id);
        $sql = 'DELETE FROM ' . $tbl_chat_connected . ' WHERE c_id = ' . $course['real_id'] . ' AND user_id = ' . $user_id;
        Database::query($sql);
    }
}
コード例 #14
0
 /**
  * Constructor
  */
 public function __construct($user_id)
 {
     $this->user_id = $user_id;
     $this->path = 'block_course';
     if ($this->is_block_visible_for_user($user_id)) {
         /*if (api_is_platform_admin()) {
         			$this->courses = CourseManager::get_real_course_list();
         		} else  {*/
         $this->courses = CourseManager::get_courses_followed_by_drh($user_id);
         //}
     }
 }
コード例 #15
0
	/**
	 * Constructor
	 */
    public function __construct($user_id)
    {
    	$this->path = 'block_evaluation_graph';
    	$this->user_id 	= $user_id;
    	$this->bg_width = 450;
    	$this->bg_height = 350;
    	if ($this->is_block_visible_for_user($user_id)) {
            if (!api_is_session_admin()) {
                $this->courses  = CourseManager::get_courses_followed_by_drh($user_id);
            }
            $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
    	}
    }
コード例 #16
0
 function trainingDelete()
 {
     $course_id = intval(Convert::raw2sql(@$_GET['course_id']));
     if ($course_id > 0) {
         $course = $this->course_repository->getBydId($course_id);
         $training = $course->training();
         if (!Member::currentUser()->canEditTraining($training->getIdentifier())) {
             die;
         }
         $this->course_manager->unRegister($course_id);
     }
     $this->redirect('training');
 }
コード例 #17
0
 function trainingDelete()
 {
     $course_id = intval(Convert::raw2sql(@$_GET['course_id']));
     if ($course_id > 0) {
         $course = $this->course_repository->getById($course_id);
         $training = $course->getTraining();
         if (Member::currentUser()->canEditTraining($training->getIdentifier())) {
             $this->setMessage('Success', 'Training Course deleted.');
             $this->course_manager->unRegister($course_id);
         } else {
             $this->setMessage('Danger', "You don't have the permission required to edit this Training Curse");
         }
     }
     $this->redirect('training');
 }
コード例 #18
0
 /**
  * @Route("/", name="course_home")
  * @Route("/index.php")
  * @Method({"GET"})
  *
  * @param Request $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $sessionId = api_get_session_id();
     $course = $this->getCourse();
     $courseCode = $course->getId();
     $result = $this->autoLaunch();
     $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning'];
     $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning'];
     if ($showAutoLaunchLpWarning) {
         $this->addFlash('warning', $this->trans('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'));
     }
     if ($showAutoLaunchExerciseWarning) {
         $this->addFlash('warning', $this->trans('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'));
     }
     if (true) {
         $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('chamilo_course_home_home_iconlist', array('course' => api_get_course_id())));
     }
     $isSpecialCourse = \CourseManager::isSpecialCourse($courseCode);
     if ($isSpecialCourse) {
         $user = $this->getUser();
         if (!empty($user)) {
             $userId = $this->getUser()->getId();
             $autoreg = $request->get('autoreg');
             if ($autoreg == 1) {
                 \CourseManager::subscribe_user($userId, $courseCode, STUDENT);
             }
         }
     }
     $homeView = api_get_setting('course.homepage_view');
     if ($homeView == 'activity' || $homeView == 'activity_big') {
         $result = $this->renderActivityView();
     } elseif ($homeView == '2column') {
         $result = $this->render2ColumnView();
     } elseif ($homeView == '3column') {
         $result = $this->render3ColumnView();
     } elseif ($homeView == 'vertical_activity') {
         $result = $this->renderVerticalActivityView();
     }
     $toolList = $result['tool_list'];
     $introduction = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, $toolList);
     $sessionInfo = null;
     if (api_get_setting('session.show_session_data') == 'true' && $sessionId) {
         $sessionInfo = CourseHome::show_session_data($sessionId);
     }
     return $this->render('ChamiloCourseBundle:Home:index.html.twig', array('course' => $course, 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null));
 }
コード例 #19
0
/**
 * Loads the data and injects it into the Chamilo database, using the Chamilo
 * internal functions.
 * @return  array  List of user IDs for the users that have just been inserted
 */
function fill_courses()
{
    $eol = PHP_EOL;
    $courses = array();
    //declare only to avoid parsing notice
    require_once 'data_courses.php';
    //fill the $users array
    $output = array();
    $output[] = array('title' => 'Courses Filling Report: ');
    $i = 1;
    foreach ($courses as $i => $course) {
        //first check that the first item doesn't exist already
        $output[$i]['line-init'] = $course['title'];
        $output[$i]['line-info'] = $res = CourseManager::create_course($course) ? $res : get_lang('NotInserted');
        $i++;
    }
    return $output;
}
コード例 #20
0
 private function get_announcements($username, $course_code, $announcement_id = 0)
 {
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $announcement_id = $announcement_id == 0 ? "" : "AND announcement.id=" . $announcement_id;
     $user_id = UserManager::get_user_id_from_username($username);
     //$listOfCourses = CourseManager::get_course_information_by_id($course_id);
     $course_info = CourseManager::get_course_information($course_code);
     $course_db = $course_info['db_name'];
     $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db);
     $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db);
     $maximum = '12';
     $group_memberships = GroupManager::get_group_ids($course_info['real_id'], $user_id);
     if (api_get_group_id() == 0) {
         $cond_user_id = " AND ( ip.to_user_id='" . $user_id . "'" . "OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")) ";
     } else {
         $cond_user_id = " AND ( ip.to_user_id='" . $user_id . "'" . "OR ip.to_group_id IN (0, " . api_get_group_id() . ")) ";
     }
     // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
     if (is_array($group_memberships) && count($group_memberships) > 0) {
         $sql = "SELECT\n                            announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n                            FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                            WHERE announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            AND ip.visibility='1'\n                            {$announcement_id}\n                            {$cond_user_id}\n                            {$condition_session}\n                            GROUP BY ip.ref\n                            ORDER BY display_order DESC\n                            LIMIT 0,{$maximum}";
     } else {
         // the user is not member of any group
         // this is an identified user => show the general announcements AND his personal announcements
         if ($user_id) {
             if (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
                 $cond_user_id = " AND (ip.lastedit_user_id = '" . api_get_user_id() . "' OR ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0')) ";
             } else {
                 $cond_user_id = " AND ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0') ";
             }
             $sql = "SELECT\n                                    announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n                                    FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                                    WHERE announcement.id = ip.ref\n                                    AND ip.tool='announcement'\n                                    AND ip.visibility='1'\n                                    {$announcement_id}\n                                    {$cond_user_id}\n                                    {$condition_session}\n                                    GROUP BY ip.ref\n                                    ORDER BY display_order DESC\n                                    LIMIT 0,{$maximum}";
         } else {
             if (api_get_course_setting('allow_user_edit_announcement')) {
                 $cond_user_id = " AND (ip.lastedit_user_id = '" . api_get_user_id() . "' OR ip.to_group_id='0') ";
             } else {
                 $cond_user_id = " AND ip.to_group_id='0' ";
             }
             // the user is not identiefied => show only the general announcements
             $sql = "SELECT\n                                    announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n                                    FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n                                    WHERE announcement.id = ip.ref\n                                    AND ip.tool='announcement'\n                                    AND ip.visibility='1'\n                                    AND ip.to_group_id='0'\n                                    {$announcement_id}\n                                    {$condition_session}\n                                    GROUP BY ip.ref\n                                    ORDER BY display_order DESC\n                                    LIMIT 0,{$maximum}";
         }
     }
     $result = Database::query($sql);
     return $result;
 }
コード例 #21
0
/**
 * Get a list of courses (code, url, title, teacher, language) and return to caller
 * Function registered as service. Returns strings in UTF-8.
 * @param string User name in Chamilo
 * @param string Signature (composed of the sha1(username+apikey)
 * @param mixed  Array or string. Type of visibility of course (public, public-registered, private, closed)
 * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
 */
function WSCourseList($username, $signature, $visibilities = 'public')
{
    if (empty($username) or empty($signature)) {
        return -1;
    }
    global $_configuration;
    $info = api_get_user_info_from_username($username);
    $user_id = $info['user_id'];
    if (!UserManager::is_admin($user_id)) {
        return -1;
    }
    $list = UserManager::get_api_keys($user_id, 'dokeos');
    $key = '';
    foreach ($list as $key) {
        break;
    }
    $local_key = $username . $key;
    if (!api_is_valid_secret_key($signature, $local_key) && !api_is_valid_secret_key($signature, $username . $_configuration['security_key'])) {
        return -1;
        // The secret key is incorrect.
    }
    //public-registered = open
    $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
    $courses_list = array();
    if (!is_array($visibilities)) {
        $visibilities = split(',', $visibilities);
    }
    foreach ($visibilities as $visibility) {
        if (!in_array($visibility, array_keys($vis))) {
            return array('error_msg' => 'Security check failed');
        }
        $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
        foreach ($courses_list_tmp as $index => $course) {
            $course_info = CourseManager::get_course_information($course['code']);
            $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
        }
    }
    return $courses_list;
}
コード例 #22
0
 /**
  * @param $content
  * @param $course_code
  * @return mixed
  */
 public static function parse_content($content, $course_code)
 {
     $reader_info = api_get_user_info(api_get_user_id());
     $course_info = api_get_course_info($course_code);
     $teacher_list = CourseManager::get_teacher_list_from_course_code($course_info['real_id']);
     $teacher_name = '';
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher_data) {
             $teacher_name = api_get_person_name($teacher_data['firstname'], $teacher_data['lastname']);
             $teacher_email = $teacher_data['email'];
             break;
         }
     }
     $course_link = api_get_course_url();
     $data['username'] = $reader_info['username'];
     $data['teacher_name'] = $teacher_name;
     $data['teacher_email'] = $teacher_email;
     $data['course_title'] = $course_info['name'];
     $data['course_link'] = Display::url($course_link, $course_link);
     $content = str_replace(self::get_tags(), $data, $content);
     return $content;
 }
コード例 #23
0
 /**
  * @param int    $courseId
  * @param int    $sessionId
  * @param string $filePath
  */
 public function warnUsersByEmail($courseId, $sessionId, $filePath = null)
 {
     $courseInfo = api_get_course_info_by_id($courseId);
     $courseCode = $courseInfo['code'];
     if (empty($sessionId)) {
         $students = CourseManager::get_student_list_from_course_code($courseCode, false);
     } else {
         $students = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId);
     }
     $url = api_get_course_url($courseCode, $sessionId);
     $url = Display::url($url, $url);
     $subject = $this->get_lang("AgreementUpdated");
     $message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url);
     $dataFile = array();
     if (!empty($filePath)) {
         $dataFile = array('path' => $filePath, 'filename' => basename($filePath));
         $message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url) . " \n";
         $message .= $this->get_lang("TheAgreementIsAttachedInThisEmail");
     }
     if (!empty($students)) {
         foreach ($students as $student) {
             $userInfo = api_get_user_info($student['user_id']);
             api_mail_html($userInfo['complete_name'], $userInfo['email'], $subject, $message, null, null, null, $dataFile);
             //MessageManager::send_message_simple($student['user_id'], $subject, $message);
         }
     }
 }
コード例 #24
0
    $courses = is_array($_POST['CourseList']) ? $_POST['CourseList'] : array();
    $first_letter_user = $_POST['firstLetterUser'];
    $first_letter_course = $_POST['firstLetterCourse'];
    foreach ($users as $key => $value) {
        $users[$key] = intval($value);
    }
    if ($form_sent == 1) {
        if (count($users) == 0 || count($courses) == 0) {
            Display::display_error_message(get_lang('AtLeastOneUserAndOneCourse'));
        } else {
            $errorDrh = 0;
            foreach ($courses as $course_code) {
                foreach ($users as $user_id) {
                    $user = api_get_user_info($user_id);
                    if ($user['status'] != DRH) {
                        CourseManager::subscribe_user($user_id, $course_code);
                    } else {
                        $errorDrh = 1;
                    }
                }
            }
            if ($errorDrh == 0) {
                Display::display_confirmation_message(get_lang('UsersAreSubscibedToCourse'));
            } else {
                Display::display_error_message(get_lang('HumanResourcesManagerShouldNotBeRegisteredToCourses'));
            }
        }
    }
}
/* Display GUI */
if (empty($first_letter_user)) {
コード例 #25
0
 /**
  * @param string $courseCode
  * @param array $rules
  * @param array $columns
  * @param array $column_model
  * @return array
  */
 public static function getRules($courseCode, &$rules, &$columns, &$column_model, $questionFields, $checkFields = false)
 {
     // sessions
     // course
     // categories
     // exercises
     // difficult
     // type
     if (empty($courseCode)) {
         // Session.
         $sessionList = SessionManager::get_sessions_by_general_coach(api_get_user_id());
         $fields = array();
         if (!empty($sessionList)) {
             $new_options = array();
             $new_options[] = "-1:" . get_lang('All');
             foreach ($sessionList as $session) {
                 $new_options[] = "{$session['id']}:{$session['name']}";
             }
             $string = implode(';', $new_options);
             $fields[] = array('field_display_text' => get_lang('Session'), 'field_variable' => 'session_id', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
         }
     } else {
         // $courseList = array(api_get_course_info());
         //$courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
     }
     // Courses.
     $courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
     if (!empty($courseList)) {
         $new_options = array();
         $new_options[] = "-1:" . get_lang('All');
         foreach ($courseList as $course) {
             $new_options[] = "{$course['id']}:{$course['title']}";
         }
         $string = implode(';', $new_options);
         $fields[] = array('field_display_text' => get_lang('Course'), 'field_variable' => 'c_id', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
     }
     // Categories.
     $string = null;
     if (!empty($courseList)) {
         $new_options = array();
         $new_options[] = "-1:" . get_lang('All');
         // Global categories
         // @todo use tree view
         $categories = Testcategory::getCategoriesIdAndName(0);
         if (!empty($categories)) {
             foreach ($categories as $id => $category) {
                 if (!empty($id)) {
                     $new_options[] = "{$id}:[Global] - " . $category;
                 }
             }
         }
         foreach ($courseList as $course) {
             $categories = Testcategory::getCategoriesIdAndName($course['real_id']);
             if (!empty($categories)) {
                 foreach ($categories as $id => $category) {
                     if (!empty($id)) {
                         $new_options[] = "{$id}:" . $course['title'] . " - " . $category;
                     }
                 }
             }
         }
         $string = implode(';', $new_options);
         $fields[] = array('field_display_text' => get_lang('Category'), 'field_variable' => 'category_id', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
     }
     $course = api_get_course_int_id();
     $sessionId = api_get_session_id();
     // Exercises.
     $exerciseList = ExerciseLib::get_all_exercises_for_course_id($sessionId, $course);
     if (!empty($exerciseList)) {
         $new_options = array();
         $new_options[] = "-1:" . get_lang('All');
         $new_options[] = "0:" . get_lang('Orphan');
         foreach ($exerciseList as $exercise) {
             $new_options[] = "{$exercise['iid']}:{$exercise['title']}";
         }
         $string = implode(';', $new_options);
         $fields[] = array('field_display_text' => get_lang('Exercise'), 'field_variable' => 'exercise_id', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
     }
     // Question type.
     $questionList = Question::get_question_type_list();
     if (!empty($questionList)) {
         $new_options = array();
         $new_options[] = "-1:" . get_lang('All');
         foreach ($questionList as $key => $question) {
             $new_options[] = "{$key}:" . get_lang($question['1']);
         }
         $string = implode(';', $new_options);
         $fields[] = array('field_display_text' => get_lang('AnswerType'), 'field_variable' => 'question_type', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
     }
     // Difficult.
     $levels = Question::get_default_levels();
     if (!empty($levels)) {
         $new_options = array();
         $new_options[] = "-1:" . get_lang('All');
         foreach ($levels as $key => $level) {
             $new_options[] = "{$key}:{$level}";
         }
         $string = implode(';', $new_options);
         $fields[] = array('field_display_text' => get_lang('Difficulty'), 'field_variable' => 'difficulty', 'field_type' => ExtraField::FIELD_TYPE_SELECT, 'field_default_value' => null, 'field_options' => $string);
     }
     $questionFieldsKeys = array();
     if (!empty($questionFields)) {
         foreach ($questionFields as $question) {
             $questionFieldsKeys[] = $question['field'];
         }
     }
     if (!empty($fields)) {
         foreach ($fields as $field) {
             $search_options = array();
             $type = 'text';
             if (in_array($field['field_type'], array(ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_DOUBLE_SELECT))) {
                 $type = 'select';
                 $search_options['sopt'] = array('eq', 'ne');
                 //equal not equal
                 //$search_options['sopt'] = array('cn', 'nc'); //contains not contains
             } else {
                 $search_options['sopt'] = array('cn', 'nc');
                 //contains not contains
             }
             $search_options['searchhidden'] = 'true';
             $search_options['defaultValue'] = isset($search_options['field_default_value']) ? $search_options['field_default_value'] : null;
             $search_options['value'] = $field['field_options'];
             $column_model[] = array('name' => 'question_' . $field['field_variable'], 'index' => 'question_' . $field['field_variable'], 'width' => '100', 'hidden' => 'true', 'search' => 'true', 'stype' => $type, 'searchoptions' => $search_options);
             $columns[] = $field['field_display_text'];
             $rules[] = array('field' => 'question_' . $field['field_variable'], 'op' => 'eq');
         }
     }
     return $rules;
 }
コード例 #26
0
 /**
  * Accepts a given by its id course request. The requested course gets created immediately after the request acceptance.
  * @param int/string $id              The id (an integer number) of the corresponding database record.
  * @return string/bool                Returns the code of the newly created course or FALSE on failure.
  */
 public static function accept_course_request($id)
 {
     $id = (int) $id;
     // Retrieve request's data
     $course_request_info = self::get_course_request_info($id);
     if (!is_array($course_request_info)) {
         return false;
     }
     // Make all the checks again before the new course creation.
     /*if (CourseManager::course_code_exists($wanted_code)) {
           return false;
       }*/
     $user_id = (int) $course_request_info['user_id'];
     if ($user_id <= 0) {
         return false;
     }
     $user_info = api_get_user_info($user_id);
     if (!is_array($user_info)) {
         return false;
     }
     // Create the requested course
     $params = array();
     $params['title'] = $course_request_info['title'];
     $params['course_category'] = $course_request_info['category_code'];
     $params['course_language'] = $course_request_info['course_language'];
     $params['exemplary_content'] = intval($course_request_info['exemplary_content']) > 0;
     $params['wanted_code'] = $course_request_info['code'];
     $params['user_id'] = $course_request_info['user_id'];
     $params['tutor_name'] = api_get_person_name($user_info['firstname'], $user_info['lastname']);
     $course_info = CourseManager::create_course($params);
     if (!empty($course_info)) {
         // Mark the request as accepted.
         $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_COURSE_REQUEST) . "\n                    SET status = " . COURSE_REQUEST_ACCEPTED . "\n                    WHERE id = " . $id;
         Database::query($sql);
         // E-mail notification.
         // E-mail language: The platform language seems to be the best choice
         $email_language = api_get_setting('platformLanguage');
         $email_subject = sprintf(get_lang('CourseRequestAcceptedEmailSubject', null, $email_language), '[' . api_get_setting('siteName') . ']', $course_info['code']);
         $email_body = get_lang('Dear', null, $email_language) . ' ';
         $email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language) . ",\n\n";
         $email_body .= sprintf(get_lang('CourseRequestAcceptedEmailText', null, $email_language), $wanted_code, $course_info['code'], api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/') . "\n";
         $email_body .= "\n" . get_lang('Formula', null, $email_language) . "\n";
         $email_body .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language) . "\n";
         $email_body .= get_lang('Manager', null, $email_language) . ' ' . api_get_setting('siteName') . "\n";
         $email_body .= get_lang('Phone', null, $email_language) . ': ' . api_get_setting('administratorTelephone') . "\n";
         $email_body .= get_lang('Email', null, $email_language) . ': ' . api_get_setting('emailAdministrator', null, $email_language) . "\n";
         $email_body .= "\n" . get_lang('CourseRequestLegalNote', null, $email_language) . "\n";
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
         $sender_email = api_get_setting('emailAdministrator');
         $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
         $recipient_email = $user_info['mail'];
         $extra_headers = 'Bcc: ' . $sender_email;
         $additionalParameters = array('smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE_APPROVED, 'userId' => $user_id, 'courseCode' => $course_info['code']);
         api_mail_html($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email, null, null, null, $additionalParameters);
         return $course_info['code'];
     }
     return false;
 }
コード例 #27
0
ファイル: delete_course.php プロジェクト: ragebat/chamilo-lms
// Language files that need to be included
$language_file = array('admin', 'course_info');
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/category.class.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_course_script(true);
$_course = api_get_course_info();
$current_course_code = $_course['official_code'];
$current_course_name = $_course['name'];
if (!api_is_allowed_to_edit()) {
    api_not_allowed(true);
}
$tool_name = get_lang('DelCourse');
if (isset($_GET['delete']) && $_GET['delete'] == 'yes') {
    CourseManager::delete_course($_course['sysCode']);
    $obj_cat = new Category();
    $obj_cat->update_category_delete($_course['sysCode']);
    // DELETE CONFIRMATION MESSAGE
    Session::erase('_cid');
    Session::erase('_real_cid');
    $noPHP_SELF = true;
    $message = '<h2>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h2>';
    $message .= get_lang('HasDel');
    $message .= '<br /><br /><a href="../../index.php">' . get_lang('BackHome') . ' ' . api_get_setting('platform.site_name') . '</a>';
} else {
    $message = '<h3>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h3>';
    $message .= '<p>' . get_lang('ByDel') . '</p>';
    $message .= '<p><a class="btn btn-primary" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/maintenance.php?' . api_get_cidreq() . '">' . get_lang('No') . '</a>&nbsp;<a class="btn" href="' . api_get_self() . '?delete=yes&' . api_get_cidreq() . '">' . get_lang('Yes') . '</a></p>';
    $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
}
コード例 #28
0
    /**
     * Set footer parameters
     */
    private function set_footer_parameters()
    {
        global $_configuration;

        //Show admin data
        //$this->assign('show_administrator_data', api_get_setting('show_administrator_data'));

        if (api_get_setting('show_administrator_data') == 'true') {
            //Administrator name
            $administrator_data = get_lang('Manager').' : '.Display::encrypted_mailto_link(
                    api_get_setting('emailAdministrator'),
                    api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))
                );
            $this->assign('administrator_name', $administrator_data);
        }

        //Loading footer extra content
        if (!api_is_platform_admin()) {
            $extra_footer = trim(api_get_setting('footer_extra_content'));
            if (!empty($extra_footer)) {
                $this->assign('footer_extra_content', $extra_footer);
            }
        }

        //Tutor name
        if (api_get_setting('show_tutor_data') == 'true') {
            // Course manager
            $id_course  = api_get_course_id();
            $id_session = api_get_session_id();
            if (isset($id_course) && $id_course != -1) {
                $tutor_data = '';
                if ($id_session != 0) {
                    $coachs_email = CourseManager::get_email_of_tutor_to_session($id_session, $id_course);
                    $email_link   = array();
                    foreach ($coachs_email as $coach) {
                        $email_link[] = Display::encrypted_mailto_link($coach['email'], $coach['complete_name']);
                    }
                    if (count($coachs_email) > 1) {
                        $tutor_data .= get_lang('Coachs').' : ';
                        $tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR);
                    } elseif (count($coachs_email) == 1) {
                        $tutor_data .= get_lang('Coach').' : ';
                        $tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR);
                    } elseif (count($coachs_email) == 0) {
                        $tutor_data .= '';
                    }
                }
                $this->assign('session_teachers', $tutor_data);
            }
        }

        if (api_get_setting('show_teacher_data') == 'true') {
            // course manager
            $id_course = api_get_course_id();
            if (isset($id_course) && $id_course != -1) {
                $teacher_data = '';
                $mail         = CourseManager::get_emails_of_tutors_to_course($id_course);
                if (!empty($mail)) {
                    $teachers_parsed = array();
                    foreach ($mail as $value) {
                        foreach ($value as $email => $name) {
                            $teachers_parsed[] = Display::encrypted_mailto_link($email, $name);
                        }
                    }
                    $label = get_lang('Teacher');
                    if (count($mail) > 1) {
                        $label = get_lang('Teachers');
                    }
                    $teacher_data .= $label.' : '.array_to_string($teachers_parsed, CourseManager::USER_SEPARATOR);
                }
                $this->assign('teachers', $teacher_data);
            }
        }
        /* $stats = '';
          $this->assign('execution_stats', $stats); */
    }
コード例 #29
0
    private function build_edit_column($item)
    {
        $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
        $locked_status = $this->evaluation->get_locked();
        if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
            //api_is_course_admin()
            $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '&' . api_get_cidreq() . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', '22') . '</a>';
            $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '&' . api_get_cidreq() . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', '22') . '</a>';
        }
        if ($this->evaluation->get_course_code() == null) {
            $edit_column .= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">
			<img src="../img/delete.gif" border="0" title="' . get_lang('Delete') . '" alt="" /></a>';
            $edit_column .= '&nbsp;<a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&' . api_get_cidreq() . '">
		    <img src="../img/statistics.gif" width="17px" border="0" title="' . get_lang('Statistics') . '" alt="" /></a>';
        }
        // Evaluation's origin is a link
        if ($this->evaluation->get_category_id() < 0) {
            $link = LinkFactory::get_evaluation_link($this->evaluation->get_id());
            $doc_url = $link->get_view_url($item['id']);
            if ($doc_url != null) {
                $edit_column .= '&nbsp;<a href="' . $doc_url . '" target="_blank">' . '<img src="' . api_get_path(WEB_CODE_PATH) . 'img/link.gif" border="0" title="' . get_lang('OpenDocument') . '" alt="" />' . '</a>';
            }
        }
        return $edit_column;
    }
コード例 #30
0
$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) {
                    continue;
                }
                Category::register_user_certificate($cat_id, $user_info['user_id']);
            }
        }
        break;
    case 'delete_all_certificates':
        Category::deleteAllCertificates($cat_id);
        break;
}
$course_code = api_get_course_id();
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?', 'name' => get_lang('Gradebook'));