コード例 #1
0
ファイル: api.course.php プロジェクト: abhinay100/forma_app
 public function getEditions($params)
 {
     require_once _lms_ . '/lib/lib.course.php';
     require_once _lms_ . '/lib/lib.edition.php';
     $output = array();
     $output['success'] = true;
     $course_id = isset($params['course_id']) ? (int) $params['course_id'] : false;
     $course_code = isset($params['course_code']) ? $params['course_code'] : false;
     if (empty($course_id) && empty($course_code)) {
         return false;
         // return array('success'=>true, 'debug'=>print_r($params, true));
     } else {
         if (empty($course_id) && !empty($course_code)) {
             // grab course info by code:
             $db = DbConn::getInstance();
             $qtxt = "SELECT * FROM %lms_course\r\n\t\t\t\t\tWHERE code='" . $course_code . "'\r\n\t\t\t\t\tLIMIT 0,1";
             $q = $db->query($qtxt);
             $course_info = $db->fetch_assoc($q);
             if (!empty($course_info)) {
                 $course_id = (int) $course_info['idCourse'];
             } else {
                 // course not found
                 return false;
                 // return array('success'=>'true', 'debug'=>print_r($course_info));
             }
         }
     }
     $edition_man = new EditionManager();
     $course_list = $edition_man->getEditionsInfoByCourses($course_id);
     $course_man = new Man_Course();
     $course = $course_man->getCourseInfo($course_id);
     foreach ($course_list[$course_id] as $key => $course_info) {
         $output[]['course_info'] = array('course_id' => $course['idCourse'], 'edition_id' => $course_info['id_edition'], 'code' => str_replace('&', '&', $course_info['code']), 'course_name' => str_replace('&', '&', $course_info['name']), 'course_description' => str_replace('&', '&', $course_info['description']), 'status' => $course_info['status'], 'selling' => $course['selling'], 'price' => $course_info['price'], 'subscribe_method' => $course['subscribe_method'], 'sub_start_date' => $course_info['sub_date_begin'], 'sub_end_date' => $course_info['sub_date_end'], 'date_begin' => $course_info['date_begin'], 'date_end' => $course_info['date_end'], 'course_link' => Get::sett('url') . _folder_lms_ . '/index.php?modname=course&op=aula&idCourse=' . $course['idCourse']);
     }
     //$output['debug']=print_r($course_list, true).print_r($course, true);
     return $output;
 }
コード例 #2
0
 public function sel_users_coursepath_actionTask()
 {
     $id_path = Get::Req('id_path', DOTY_INT, 0);
     if ($id_path <= 0) {
         //...
         return;
     }
     $selection = Get::req('userselector_input', DOTY_MIXED, true);
     $new_selection = $selection['coursepath_subscriptions'];
     $old_selection = $this->model->getCoursePathSubscriptionsList($id_path);
     $new_selection = explode(",", $new_selection);
     $new_selection = $this->acl_man->getAllUsersFromSelection($new_selection);
     $_common = array_intersect($new_selection, $old_selection);
     $_to_add = array_diff($new_selection, $_common);
     $_to_del = array_diff($old_selection, $_common);
     $res = true;
     if (!$res) {
         $result = 'err_subscribe';
     } else {
         $result = 'ok_subcribe';
     }
     require_once _lms_ . '/lib/lib.coursepath.php';
     $path_man = new CoursePath_Manager();
     //1 - get list of the courses of the coursepath
     $base_url = 'index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path;
     $courses = $path_man->getAllCourses(array($id_path));
     if (empty($courses)) {
         Util::jump_to($base_url);
     }
     //2 - check if there are any editions or classrooms
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $course_man = new Man_Course();
     $classroom = $course_man->getAllCourses(false, 'classroom', $courses);
     $edition = $course_man->getAllCourses(false, 'edition', $courses);
     //3 - if yes, then make a second step in order to choose editions and classrooms
     if (!empty($classroom) || !empty($edition)) {
         $classroom_list = array();
         if (!empty($classroom)) {
             require_once _lms_ . '/lib/lib.date.php';
             $date_man = new DateManager();
             foreach ($classroom as $id_course => $info) {
                 $classrooms = $date_man->getCourseDate($id_course, true);
                 $classrooms_for_dropdown = array();
                 $classrooms_for_dropdown[0] = Lang::t('_NO_CLASSROOM_SUBSCRIPTION', 'coursepath');
                 foreach ($classrooms as $classroom_info) {
                     $classrooms_for_dropdown[$classroom_info['id_date']] = $classroom_info['code'] . ' - ' . $classroom_info['name'] . ' - ' . Format::date($classroom_info['date_begin'], 'date') . ' - ' . Format::date($classroom_info['date_end'], 'date');
                 }
                 $classroom_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $classrooms_for_dropdown);
                 //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'classroom_'.$id_course, 'classroom_'.$id_course, $edition_for_dropdown));
             }
         }
         $edition_list = array();
         if (!empty($edition)) {
             require_once _lms_ . '/lib/lib.edition.php';
             $edition_man = new EditionManager();
             foreach ($edition as $id_course => $info) {
                 $editions = $edition_man->getEditionsInfoByCourses($id_course);
                 $editions_for_dropdown = array();
                 $editions_for_dropdown[0] = Lang::t('_NONE', 'coursepath');
                 foreach ($editions[$id_course] as $edition_info) {
                     $editions_for_dropdown[$edition_info['id_edition']] = $edition_info['code'] . ' - ' . $edition_info['name'] . ' - ' . Format::date($edition_info['date_begin'], 'date') . ' - ' . Format::date($edition_info['date_end'], 'date');
                 }
                 $edition_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $edition_for_dropdown);
                 //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'edition_'.$id_course, 'edition_'.$id_course, $edition_for_dropdown));
             }
         }
         $this->render('choose_editions_coursepath', array('id_path' => $id_path, 'courses_list' => $courses, 'editions_list' => $edition_list, 'classrooms_list' => $classroom_list, 'users_to_add' => $_to_add, 'users_to_del' => $_to_del, 'path_name' => $this->model->getCoursepathNameForSubscription($id_path)));
     } else {
         $path_man->subscribeUserToCoursePath($id_path, $_to_add);
         require_once _lms_ . '/lib/lib.course.php';
         foreach ($courses as $id_course) {
             $docebo_course = new DoceboCourse($id_course);
             $level_idst =& $docebo_course->getCourseLevel($id_course);
             if (count($level_idst) == 0 || $level_idst[1] == '') {
                 $level_idst =& $docebo_course->createCourseLevel($id_course);
             }
             foreach ($_to_add as $id_user) {
                 $level = 3;
                 //student
                 $waiting = false;
                 //$this->acl_man->addToGroup($level_idst[$level], $id_user);
                 $this->_addToCourseGroup($level_idst[$level], $id_user);
                 $this->model->id_course = $id_course;
                 $this->model->subscribeUser($id_user, $level, $waiting);
             }
         }
         Util::jump_to('index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path . '&res=' . $result);
     }
 }
コード例 #3
0
ファイル: coursepath.php プロジェクト: abhinay100/forma_app
 function addsubscription()
 {
     checkPerm('subscribe');
     require_once _base_ . '/lib/lib.form.php';
     require_once _adm_ . '/class.module/class.directory.php';
     require_once _lms_ . '/lib/lib.subscribe.php';
     require_once _lms_ . '/lib/lib.coursepath.php';
     $id_path = importVar('id_path', true, 0);
     $lang =& DoceboLanguage::createInstance('coursepath', 'lms');
     $out =& $GLOBALS['page'];
     $acl_man =& Docebo::user()->getAclManager();
     if (isset($_POST['cancelselector'])) {
         Util::jump_to('index.php?modname=coursepath&amp;op=pathlist');
     }
     $user_select = new UserSelector();
     $user_select->show_user_selector = TRUE;
     $user_select->show_group_selector = TRUE;
     $user_select->show_orgchart_selector = TRUE;
     $user_select->show_orgchart_simple_selector = TRUE;
     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
         $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
         $user_select->setUserFilter('user', $admin_users);
         $user_select->setUserFilter('group', $admin_tree);
     }
     $query_pathlist = "\r\n\tSELECT path_name, subscribe_method\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\tWHERE id_path = '" . $id_path . "'\r\n\tORDER BY path_name ";
     list($path_name, $subscribe_method) = sql_fetch_row(sql_query($query_pathlist));
     if (isset($_GET['load'])) {
         $cp_man = new CoursePath_Manager();
         $users = $cp_man->getSubscribed($id_path);
         $user_select->resetSelection($users);
     }
     if (isset($_POST['okselector'])) {
         $acl_manager = new DoceboACLManager();
         $user_selected = $user_select->getSelection($_POST);
         $user_selected =& $acl_manager->getAllUsersFromIdst($user_selected);
         $user_selected = array_unique($user_selected);
         $cp_man = new CoursePath_Manager();
         $users = $cp_man->getSubscribed($id_path);
         $user_selected = array_diff($user_selected, $users);
         if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
             require_once _base_ . '/lib/lib.preference.php';
             $adminManager = new AdminPreference();
             $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
             $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
             $user_selected = array_intersect($user_selected, $admin_users);
         }
         if (empty($user_selected)) {
             Util::jump_to('index.php?modname=coursepath&amp;op=pathlist');
         }
         $cpath_man = new CoursePath_Manager();
         $subs_man = new CourseSubscribe_Management();
         $courses = $cpath_man->getAllCourses(array($id_path));
         require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php';
         $course_man = new Man_Course();
         $classroom = $course_man->getAllCourses(false, 'classroom', $courses);
         $edition = $course_man->getAllCourses(false, 'edition', $courses);
         if (!empty($classroom) || !empty($edition)) {
             $user_selected_post = urlencode(serialize($user_selected));
             cout(getTitleArea(array('index.php?modname=coursepath&amp;op=pathlist' => $lang->def('_COURSEPATH'), $path_name), 'coursepath') . '<div class="std_block">' . Form::openForm('edition_selection_form', 'index.php?modname=coursepath&amp;op=addsubscriptionedition&amp;id_path=' . $id_path) . Form::getHidden('users', 'users', $user_selected_post));
             if (!empty($classroom)) {
                 require_once _lms_ . '/lib/lib.date.php';
                 $date_man = new DateManager();
                 foreach ($classroom as $id_course => $info) {
                     $editions = $date_man->getCourseDate($id_course, true);
                     $edition_for_dropdown = array();
                     $edition_for_dropdown[0] = Lang::t('_NONE', 'coursepath');
                     foreach ($editions as $editions_info) {
                         $edition_for_dropdown[$editions_info['id_date']] = $editions_info['code'] . ' - ' . $editions_info['name'] . ' - ' . Format::date($editions_info['date_begin'], 'date') . ' - ' . Format::date($editions_info['date_end'], 'date');
                     }
                     cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath') . ' : ' . $info['code'] . ' - ' . $info['name'], 'classroom_' . $id_course, 'classroom_' . $id_course, $edition_for_dropdown));
                 }
             }
             if (!empty($edition)) {
                 require_once _lms_ . '/lib/lib.edition.php';
                 $edition_man = new EditionManager();
                 foreach ($edition as $id_course => $info) {
                     $editions = $edition_man->getEditionsInfoByCourses($id_course);
                     $edition_for_dropdown = array();
                     $edition_for_dropdown[0] = Lang::t('_NONE', 'coursepath');
                     foreach ($editions[$id_course] as $editions_info) {
                         $edition_for_dropdown[$editions_info['id_edition']] = $editions_info['code'] . ' - ' . $editions_info['name'] . ' - ' . Format::date($editions_info['date_begin'], 'date') . ' - ' . Format::date($editions_info['date_end'], 'date');
                     }
                     cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath') . ' : ' . $info['code'] . ' - ' . $info['name'], 'edition_' . $id_course, 'edition_' . $id_course, $edition_for_dropdown));
                 }
             }
             cout(Form::openButtonSpace() . Form::getButton('save', 'save', Lang::t('_SAVE', 'coursepath')) . Form::getButton('undo', 'undo', Lang::t('_UNDO', 'coursepath')) . Form::closeButtonSpace() . Form::closeForm() . '</div>');
         } else {
             $re = true;
             if ($subscribe_method != 1 && !checkPerm('moderate', true)) {
                 $waiting = 1;
             } else {
                 $waiting = 0;
             }
             $users_subsc = array();
             require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php';
             $course_man = new Man_Course();
             $assessment = $course_man->getAllCourses(false, 'assessment', $courses);
             while (list(, $id_user) = each($user_selected)) {
                 $text_query = "\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath_user\r\n\t\t\t\t( id_path, idUser, waiting, subscribed_by ) VALUES\r\n\t\t\t\t( '" . $id_path . "', '" . $id_user . "', '" . $waiting . "', '" . getLogUserId() . "' )";
                 $re_s = sql_query($text_query);
                 if ($re_s == true) {
                     $users_subsc[] = $id_user;
                 }
                 $re &= $re_s;
                 foreach ($assessment as $id_assessment => $assessment_info) {
                     sql_query("INSERT INTO %lms_assessment_user (id_assessment, id_user, type_of) VALUES ('" . $id_assessment . "', '" . $id_user . "', 'user')");
                 }
             }
             // now subscribe user to all the course
             if ($waiting == 0) {
                 $re &= $subs_man->multipleSubscribe($users_subsc, $courses, 3);
             }
             Util::jump_to('index.php?modname=coursepath&amp;op=pathlist&result=' . ($re ? 'ok' : 'err'));
         }
     } else {
         $user_select->setPageTitle(getTitleArea(array('index.php?modname=coursepath&amp;op=pathlist' => $lang->def('_COURSEPATH'), $path_name), 'coursepath'));
         $user_select->loadSelector('index.php?modname=coursepath&amp;op=addsubscription&amp;id_path=' . $id_path, $lang->def('_SUBSCRIBE'), false, true);
     }
 }