示例#1
0
             $smarty->assign("T_SUPERVISOR_APPROVALS", $pendingCourses);
         }
         if (isset($_GET['ajax']) && $_GET['ajax'] == 'approval') {
             try {
                 $course = new EfrontCourse($_GET['course_id']);
                 $course->confirm($_GET['users_login']);
                 echo json_encode(array('status' => 1));
                 exit;
             } catch (Exception $e) {
                 handleAjaxExceptions($e);
             }
         } elseif (isset($_GET['ajax']) && $_GET['ajax'] == 'cancel') {
             try {
                 if (eF_checkParameter($_GET['course_id'], 'id')) {
                     $course = new EfrontCourse($_GET['course_id']);
                     $course->removeUsers($_GET['users_login']);
                     $event = array("type" => EfrontEvent::COURSE_USER_REFUSAL, "users_LOGIN" => $_GET['users_login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name']);
                     EfrontEvent::triggerEvent($event);
                     echo json_encode(array('status' => 1));
                     exit;
                 }
             } catch (Exception $e) {
                 handleAjaxExceptions($e);
             }
         }
     }
 }
 #cpp#endif
 if ($currentUser->coreAccess['dashboard'] != 'hidden') {
     $myCoursesOptions[] = array('text' => _DASHBOARD, 'image' => "32x32/user.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=personal");
 }
示例#2
0
 public function getUserCourseStatus($course, $user, $options, $courseLessons = false)
 {
     if (!$user instanceof EfrontUser) {
         $user = EfrontUserFactory::factory($user);
         $user = $user->user;
     }
     if (!$course instanceof EfrontCourse) {
         $course = new EfrontCourse($course);
     }
     $roles = EfrontLessonUser::getLessonsRoles();
     foreach ($roles as $key => $value) {
         $value == 'student' ? $studentLessonRoles[] = $key : null;
     }
     if ($courseLessons == false) {
         $courseLessons = $course->getCourseLessons();
     }
     $lessonsStatus = self::getUsersLessonStatus($courseLessons, $user['login'], $options);
     $result = eF_getTableData("users_to_courses", "*", "courses_ID = " . $course->course['id'] . " and users_LOGIN='******'login'] . "'");
     if (sizeof($result) > 0) {
         if ($course->course['duration'] && $result[0]['from_timestamp']) {
             $result[0]['remaining'] = $result[0]['from_timestamp'] + $course->course['duration'] * 3600 * 24 - time();
         } else {
             $result[0]['remaining'] = null;
         }
         //Check whether the course registration is expired. If so, set $result[0]['from_timestamp'] to false, so that the effect is to appear disabled
         if ($course->course['duration'] && $result[0]['from_timestamp'] && $course->course['duration'] * 3600 * 24 + $result[0]['from_timestamp'] < time()) {
             $course->removeUsers($result[0]['users_LOGIN']);
         } else {
             $usersCourses[$result[0]['courses_ID']][$result[0]['users_LOGIN']] = $result[0];
             $usersCoursesTypes[$result[0]['courses_ID']][$result[0]['users_LOGIN']] = $roles[$result[0]['user_type']];
             //Handy since we need to know whether a course has any students
         }
     }
     $courseStatus = array();
     //transpose and filter s statistics array, for convenience, from  lesson id => login to login => lesson id
     foreach ($lessonsStatus as $lessonId => $info) {
         if (in_array($lessonId, array_keys($courseLessons))) {
             foreach ($info as $login => $stats) {
                 $userLessonStatus[$lessonId] = $stats;
             }
         }
     }
     if (sizeof($usersCourses[$course->course['id']]) > 0) {
         foreach ($usersCourses[$course->course['id']] as $login => $value) {
             $courseStatus = array('login' => $login, 'name' => $user['name'], 'surname' => $user['surname'], 'basic_user_type' => $user['user_type'], 'user_type' => $value['user_type'], 'user_types_ID' => $user['user_types_ID'], 'different_role' => !$users[$login]['user_types_ID'] && $value['user_type'] != $users[$login]['user_type'] || $users[$login]['user_types_ID'] && $value['user_type'] != $users[$login]['user_types_ID'], 'active' => $user['active'], 'course_name' => $course->course['name'], 'from_timestamp' => $value['from_timestamp'], 'remaining' => $value['remaining']);
             //Student - specific information
             if ($roles[$value['user_type']] == 'student') {
                 $courseStatus['completed'] = $value['completed'];
                 $courseStatus['score'] = $value['score'];
                 $courseStatus['completion_date'] = $value['to_timestamp'];
                 $courseStatus['comments'] = $value['comments'];
                 $courseStatus['issued_certificate'] = $value['issued_certificate'];
                 $courseStatus['total_lessons'] = sizeof($courseLessons);
                 //Count completed lessons
                 $completedLessons = 0;
                 if (isset($userLessonStatus)) {
                     foreach ($userLessonStatus as $lesson) {
                         if ($lesson['completed']) {
                             $completedLessons++;
                         }
                     }
                 }
                 $courseStatus['completed_lessons'] = $completedLessons;
             }
             //Append the course's lessons information
             $courseStatus['lesson_status'] = $userLessonStatus;
         }
     }
     return $courseStatus;
 }