Exemplo n.º 1
0
     if ($editLesson->isUserActiveInLesson($editedUser)) {
         $editLesson->unConfirm($editedUser);
         $response['access'] = 0;
     } else {
         $editLesson->confirm($editedUser);
         $response['access'] = 1;
     }
     echo json_encode($response);
     exit;
 } else {
     if (isset($_GET['ajax']) && in_array($_GET['ajax'], array('lessonsTable'))) {
         $roles = EfrontLessonUser::getLessonsRoles(true);
         $smarty->assign("T_ROLES_ARRAY", $roles);
         $directionsTree = new EfrontDirectionsTree();
         $smarty->assign("T_DIRECTION_PATHS", $directionsTree->toPathString());
         $rolesBasic = EfrontLessonUser::getLessonsRoles();
         $smarty->assign("T_BASIC_ROLES_ARRAY", $rolesBasic);
         $smarty->assign("T_EDITED_USER_TYPE", $editedUser->user['user_types_ID'] ? $editedUser->user['user_types_ID'] : $editedUser->user['user_type']);
         if (isset($_GET['ajax']) && $_GET['ajax'] == 'lessonsTable') {
             $smarty->assign("T_DATASOURCE_COLUMNS", array('name', 'directions_ID', 'completed', 'active_in_lesson', 'user_type', 'score', 'has_lesson'));
             if ($_change_lessons_) {
                 $nonLessons = array();
                 foreach ($editedUser->getNonLessons(true) as $key => $lesson) {
                     if (!$lesson->lesson['course_only']) {
                         $nonLessons[$key] = $lesson;
                     }
                 }
                 if ($independentLessons = $editedUser->getUserStatusInIndependentLessons(true)) {
                     $lessons = $independentLessons + $nonLessons;
                 } else {
                     $lessons = $nonLessons;
Exemplo n.º 2
0
 private function handlePostAjaxRequestForSingleUser()
 {
     isset($_GET['user_type']) && in_array($_GET['user_type'], array_keys(EfrontLessonUser::getLessonsRoles())) ? $userType = $_GET['user_type'] : ($userType = 'student');
     $user = EfrontUserFactory::factory($_GET['login']);
     if (!$user->hasCourse($this) || $user->getUserTypeInCourse($this) != $userType) {
         $this->addUsers($user, $userType);
     } else {
         $this->archiveCourseUsers($user);
     }
 }
 /**
  * Get the user's role
  *
  * This function returns the user role for the specified lesson
  * <br/>Example:
  * <code>
  * $this -> getRole(4);								 //Get the role for lesson with id 4
  * </code>
  *
  * @param int $lessonId The lesson id to get the role for
  * @return string The user role for the lesson
  * @since 3.5.0
  * @access public
  */
 public function getRole($lessonId)
 {
     $roles = EfrontLessonUser::getLessonsRoles();
     if ($lessonId instanceof EfrontLesson) {
         $lessonId = $lessonId->lesson['id'];
     }
     if (in_array($lessonId, array_keys($this->getLessons()))) {
         $result = eF_getTableData("users_to_lessons", "user_type", "users_LOGIN='******'login'] . "' and lessons_ID=" . $lessonId);
         return $roles[$result[0]['user_type']];
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 /**
  * Get the possible roles for a user in a lesson. This function caches EfrontLessonUser :: getLessonsRoles() results
  * for improved efficiency
  *
  * @return array the possible users' roles in the lesson
  * @since 3.6.1
  * @access protected
  */
 private function getPossibleLessonRoles()
 {
     if (!isset($this->roles) || !$this->roles) {
         $this->roles = EfrontLessonUser::getLessonsRoles();
     }
     return $this->roles;
 }
Exemplo n.º 5
0
                             handleAjaxExceptions($e);
                         }
                         exit;
                     }
                 }
             }
         } else {
             if (!empty($skills)) {
                 $smarty->assign("T_SKILLS", $skills);
                 $smarty->assign("T_SKILLS_SIZE", sizeof($skills));
             }
         }
     }
     #cpp#endif
 }
 $roles = EfrontLessonUser::getLessonsRoles(true);
 $smarty->assign("T_ROLES", $roles);
 if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') {
     $constraints = array('archive' => false, 'active' => 1, 'return_objects' => false) + createConstraintsFromSortedTable();
     $users = $editLesson->getLessonUsersIncludingUnassigned($constraints);
     $totalEntries = $editLesson->countLessonUsersIncludingUnassigned($constraints);
     foreach ($users as $key => $user) {
         if (!$user['has_lesson']) {
             $user['user_types_ID'] ? $users[$key]['role'] = $user['user_types_ID'] : ($users[$key]['role'] = $user['user_type']);
         }
     }
     $dataSource = $users;
     $tableName = $_GET['ajax'];
     $alreadySorted = 1;
     $smarty->assign("T_TABLE_SIZE", $totalEntries);
     include "sorted_table.php";
    private function printCategoryCourses($iterator, $display, $userInfo, $options, $courses, $lessons, $checkLessons)
    {
        $roles = EfrontLessonUser::getLessonsRoles();
        $roleNames = EfrontLessonUser::getLessonsRoles(true);
        $treeString = '';
        $current = $iterator->current();
        if (isset($current['courses']) && sizeof($current['courses']) > 0) {
            $coursesTreeString = '';
            foreach ($current->offsetGet('courses') as $courseId) {
                $treeCourse = $courses[$courseId];
                if (isset($treeCourse->course['user_type']) && $treeCourse->course['user_type']) {
                    $roleInCourse = $treeCourse->course['user_type'];
                    $roleBasicType = $roles[$roleInCourse];
                    //Indicates that this is a catalog with user data
                    if ($roleBasicType == 'student') {
                        $this->hasLessonsAsStudent = true;
                    }
                } else {
                    $roleBasicType = null;
                }
                //				if ($_COOKIE['display_all_courses'] == '1' || $roleBasicType != 'student' || (!$treeCourse -> course['completed'] && (is_null($treeCourse -> course['remaining']) || $treeCourse -> course['remaining'] > 0))) {
                if ($options['course_lessons']) {
                    $meets_depends_on_criteria = true;
                    if ($treeCourse->course['depends_on']) {
                        if (!isset($courses[$treeCourse->course['depends_on']])) {
                            $meets_depends_on_criteria = false;
                        }
                    }
                    $coursesTreeString .= $treeCourse->toHTML($lessons, $options, $checkLessons, $meets_depends_on_criteria);
                } else {
                    $coursesTreeString .= '
						<table width = "100%">
							<tr class = "directionEntry">
								<td>';
                    $coursesTreeString .= $this->printCourseLinks($treeCourse, $options, $roleBasicType);
                    $coursesTreeString .= '
								</td>
							</tr>
						</table>';
                }
                //				}
            }
            if ($coursesTreeString) {
                $treeString .= '
							<tr id = "subtree' . $current['id'] . '" name = "default_visible" ' . ($iterator->getDepth() >= 1 ? '' : $display) . '>
								<td></td>
								<td class = "lessonsList_nocolor">&nbsp;</td>
								<td colspan = "2">
								' . $coursesTreeString . '
								</td>
							</tr>';
            }
        }
        return $treeString;
    }
Exemplo n.º 7
0
     }
     $uncompleteEntities = json_decode($_GET['uncomplete']);
     if (!empty($uncompleteEntities)) {
         $list = '"' . implode('","', $uncompleteEntities) . '"';
         $info = eF_getTableData("users_to_lessons", "users_LOGIN,lessons_ID,completed,score,to_timestamp,comments", "users_LOGIN IN (" . $list . ") and lessons_ID = " . $currentLesson->lesson['id']);
         foreach ($info as $value) {
             if ($value['completed'] == 1) {
                 eF_updateTableData("users_to_lessons", array("completed" => 0, "to_timestamp" => null, "score" => 0, "comments" => "", "issued_certificate" => ""), "users_LOGIN='******'users_LOGIN'] . "' and lessons_ID = " . $value['lessons_ID']);
             }
         }
     }
     exit;
 }
 if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') {
     $constraints = createConstraintsFromSortedTable() + array('archive' => false, 'return_objects' => false);
     foreach (EfrontLessonUser::getLessonsRoles() as $key => $value) {
         $value != 'student' or $studentRoles[] = $key;
     }
     if ($_SESSION['s_current_branch']) {
         $branches = array($_SESSION['s_current_branch']);
         $branchesTree = new EfrontBranchesTree();
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST));
         foreach ($iterator as $key => $value) {
             $branches[] = $key;
         }
         $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches) . ") AND filter_eb.assigned = 1)");
         $constraints['table_filters'] = $stats_filters;
     }
     $constraints['condition'] = "ul.user_type in ('" . implode("','", $studentRoles) . "')";
     $users = $currentLesson->getLessonStatusForUsers($constraints);
     $totalEntries = $currentLesson->countLessonUsers($constraints);
Exemplo n.º 8
0
 public function getUserLessonStatus($lesson, $user, $options)
 {
     $times = new EfrontTimes();
     $usersTimesInLessonContent = array();
     if ($lesson instanceof EfrontLesson) {
         $lessonId = $lesson->lesson['id'];
     } else {
         $lessonId = $lesson;
     }
     //$usersTimesInLessonContent[$user] = $times->getUserSessionTimeInLessonContent($user, $lessonId);
     $usersTimesInLessonContent[$user] = EfrontLesson::getUserActiveTimeInLesson($user, $lessonId);
     $usersDoneContent = EfrontStats::getStudentsSeenContent($lesson, $user, $options);
     //Calculate the done content for users in this lesson
     $usersAssignedProjects = array();
     if (!isset($options['noprojects']) || !$options['noprojects']) {
         $usersAssignedProjects = EfrontStats::getStudentsAssignedProjects($lesson, $user);
     }
     $usersDoneTests = array();
     if (!isset($options['notests']) || !$options['notests']) {
         $usersDoneTests = EfrontStats::getStudentsDoneTests($lesson, $user);
     }
     $roles = EfrontLessonUser::getLessonsRoles();
     //transpose projects array, from (login => array(project id => project)) to array(lesson id => array(login => array(project id => project)))
     $temp = array();
     foreach ($usersAssignedProjects as $login => $userProjects) {
         foreach ($userProjects as $projectId => $project) {
             $temp[$project['lessons_ID']][$login][$projectId] = $project;
         }
     }
     $usersAssignedProjects = $temp;
     //transpose tests array, from (login => array(test id => test)) to array(lesson id => array(login => array(test id => test)))
     $temp0 = eF_getTableData("content", "id,ctg_type");
     //filter feedbacks
     foreach ($temp0 as $value) {
         $checkctg[$value['id']] = $value['ctg_type'];
     }
     $temp = array();
     foreach ($usersDoneTests as $login => $userTests) {
         foreach ($userTests as $contentID => $test) {
             if ($checkctg[$contentID] != 'feedback') {
                 $temp[$test['lessons_ID']][$login][$contentID] = $test;
             }
         }
     }
     $usersDoneTests = $temp;
     if (!$user instanceof EfrontUser) {
         $user = EfrontUserFactory::factory($user);
         $user = $user->user;
     }
     if (!$lesson instanceof EfrontLesson) {
         $lesson = new EfrontLesson($lesson);
     }
     $result = eF_getTableData("users_to_lessons", "*", "users_LOGIN ='******'login'] . "' and lessons_ID = " . $lesson->lesson['id']);
     if (sizeof($result[0]['users_LOGIN']) > 0) {
         if ($lesson->lesson['duration'] && $result[0]['from_timestamp']) {
             $result[0]['remaining'] = $result[0]['from_timestamp'] + $lesson->lesson['duration'] * 3600 * 24 - time();
         } else {
             $result[0]['remaining'] = null;
         }
         //Check whether the lesson registration is expired. If so, set $result[0]['from_timestamp'] to false, so that the effect is to appear disabled
         if ($lesson->lesson['duration'] && $result[0]['from_timestamp'] && $lesson->lesson['duration'] * 3600 * 24 + $result[0]['from_timestamp'] < time()) {
             $lesson->removeUsers($result[0]['users_LOGIN']);
         } else {
             $usersLessons[$result[0]['lessons_ID']][$result[0]['users_LOGIN']] = $result[0];
             $usersLessonsTypes[$result[0]['lessons_ID']][$result[0]['users_LOGIN']] = $roles[$result[0]['user_type']];
             //Handy since we need to know whether a lesson has any students
         }
     }
     //Build a caching set for conditions, so that we avoid looping queries inside $lesson -> getConditions();
     $result = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $lesson->lesson['id']);
     $conditions = array();
     foreach ($result as $value) {
         $conditions[$value['lessons_ID']][] = $value;
     }
     $lessonStatus = array();
     if (in_array('student', $usersLessonsTypes[$lesson->lesson['id']])) {
         //Calculate these statistics only if the lesson has students
         !isset($conditions[$lesson->lesson['id']]) ? $conditions[$lesson->lesson['id']] = array() : null;
         $lessonConditions = $lesson->getConditions($conditions[$lesson->lesson['id']]);
         $lessonContent = new EfrontContentTree($lesson);
         $doneContent = isset($usersDoneContent[$lesson->lesson['id']]) ? $usersDoneContent[$lesson->lesson['id']] : array();
         $doneTests = isset($usersDoneTests[$lesson->lesson['id']]) ? $usersDoneTests[$lesson->lesson['id']] : array();
         $assignedProjects = isset($usersAssignedProjects[$lesson->lesson['id']]) ? $usersAssignedProjects[$lesson->lesson['id']] : array();
         $visitableContentIds = array();
         $visitableExampleIds = array();
         $visitableTestIds = array();
         $testIds = array();
         foreach ($iterator = new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST))) as $key => $value) {
             if ($value['active']) {
                 switch ($value->offsetGet('ctg_type')) {
                     case 'theory':
                     case 'scorm':
                     case 'feedback':
                         $visitableContentIds[$key] = $key;
                         //Get the not-test unit ids for this content
                         break;
                     case 'examples':
                         $visitableExampleIds[$key] = $key;
                         //Get the not-test unit ids for this content
                         break;
                     case 'tests':
                     case 'scorm_test':
                         $visitableTestIds[$key] = $key;
                         //Get the scorm test unit ids for this content
                         $testIds[$key] = $key;
                         //Get the test unit ids for this content
                         break;
                 }
             }
         }
         $visitableUnits = $visitableContentIds + $visitableExampleIds + $visitableTestIds;
     }
     foreach ($usersLessons[$lesson->lesson['id']] as $login => $value) {
         $lessonStatus = 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' => $value['user_type'] != $user['user_type'] && $value['user_type'] != $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'], 'lesson_name' => $lesson->lesson['name'], 'from_timestamp' => $value['from_timestamp'], 'remaining' => $value['remaining']);
         //Student - specific information
         if ($roles[$value['user_type']] == 'student') {
             !isset($doneContent[$login]) ? $doneContent[$login] = array() : null;
             !isset($assignedProjects[$login]) ? $assignedProjects[$login] = array() : null;
             list($conditionsMet, $lessonPassed) = self::checkConditions($doneContent[$login], $lessonConditions, $visitableUnits, $visitableTestIds, $usersTimesInLessonContent[$login]);
             //Content progress is theory and examples units seen
             $contentProgress = 0;
             if (isset($doneContent[$login]) && sizeof($doneContent[$login]) > 0 && (sizeof($visitableContentIds) > 0 || sizeof($visitableExampleIds) > 0)) {
                 $contentProgress = round(100 * sizeof(array_diff_key($doneContent[$login], $visitableTestIds)) / (sizeof($visitableContentIds) + sizeof($visitableExampleIds)), 2);
             }
             //Calculate tests average score and progress
             $testsProgress = 0;
             $numCompletedTests = 0;
             $testsAvgScore = array();
             if (sizeof($testIds) > 0 && isset($doneTests[$login]) && sizeof($doneTests[$login]) > 0) {
                 foreach ($doneTests[$login] as $doneTest) {
                     $testsAvgScore[] = $doneTest['active_score'];
                 }
                 $testsAvgScore = array_sum($testsAvgScore) / sizeof($testsAvgScore);
                 $numCompletedTests = 0;
                 if (!isset($doneTest[$login['lesson_status']]) || $doneTest[$login['lesson_status']] == 'passed' || $doneTest[$login['lesson_status']] == 'completed') {
                     $numCompletedTests++;
                 }
                 $testsProgress = round(100 * $numCompletedTests / sizeof($visitableTestIds), 2);
             } else {
                 $testsAvgScore = 0;
             }
             //Calculate projects average score and build done projects list, since we don't have this automatically
             $doneProjects = array();
             $projectsAvgScore = array();
             $projectsProgress = 0;
             if (sizeof($assignedProjects[$login]) > 0) {
                 foreach ($assignedProjects[$login] as $id => $project) {
                     if ($project['grade'] !== '' || $project['upload_timestamp']) {
                         $doneProjects[$id] = $project;
                         $projectsAvgScore[] = $project['grade'];
                     }
                 }
                 sizeof($doneProjects) > 0 ? $projectsAvgScore = array_sum($projectsAvgScore) / sizeof($projectsAvgScore) : ($projectsAvgScore = 0);
                 $projectsProgress = round(100 * sizeof($doneProjects) / sizeof($assignedProjects[$login]), 2);
             } else {
                 $projectsAvgScore = 0;
             }
             //Calculate overall progress, the number of done content + done (passed for SCORM) tests divided with the total units number
             $overallProgress = 0;
             if (sizeof($visitableUnits) > 0) {
                 $overallProgress = round(100 * sizeof(array_intersect(array_keys($visitableUnits), array_keys($doneContent[$login]))) / sizeof($visitableUnits), 2);
             }
             $lessonStatus['assigned_projects'] = $assignedProjects[$login];
             //the total assigned projects to the user, with information for each one.
             $lessonStatus['projects_progress'] = $projectsProgress;
             //the projects percentage done
             $lessonStatus['projects_avg_score'] = $projectsAvgScore;
             //the projects average score
             $lessonStatus['tests_progress'] = $testsProgress;
             //the tests percentage done
             $lessonStatus['tests_avg_score'] = $testsAvgScore;
             //the tests average score
             $lessonStatus['content_progress'] = $contentProgress;
             //the content (theory_examples) percentage done
             $lessonStatus['overall_progress'] = $overallProgress;
             //the total percentage done, including content and tests
             $lessonStatus['lesson_passed'] = $lessonPassed;
             $lessonStatus['total_conditions'] = sizeof($lessonConditions);
             $lessonStatus['conditions_passed'] = array_sum($conditionsMet);
             $lessonStatus['completed'] = $value['completed'];
             $lessonStatus['score'] = $value['score'];
             $lessonStatus['comments'] = $value['comments'] ? $value['comments'] : 0;
         }
     }
     return $lessonStatus;
 }
Exemplo n.º 9
0
 private function handlePostAjaxRequestForSingleUser()
 {
     isset($_GET['user_type']) && in_array($_GET['user_type'], array_keys(EfrontLessonUser::getLessonsRoles())) ? $userType = $_GET['user_type'] : ($userType = 'student');
     $user = EfrontUserFactory::factory($_GET['login']);
     if (!$user->hasCourse($this) || $user->getUserTypeInCourse($this) != $userType) {
         $this->addUsers($user, $userType);
         echo "added";
     } else {
         $this->archiveCourseUsers($user);
         // Delete notifications related to the user and this course
         $notifications_to_delete = eF_getTableData("notifications", "id", "recipient='" . $user->user['login'] . "' AND id_type_entity LIKE '%_%_" . $this->course['id'] . "'");
         foreach ($notifications_to_delete as $notification) {
             eF_deleteTableData("notifications", "id = '" . $notification['id'] . "'");
         }
         echo "removed";
     }
 }
Exemplo n.º 10
0
if (!EfrontUser::isOptionVisible('statistics')) {
    eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
}
$loadScripts[] = 'scriptaculous/excanvas';
$loadScripts[] = 'scriptaculous/flotr';
$loadScripts[] = 'scriptaculous/controls';
$loadScripts[] = 'includes/graphs';
$loadScripts[] = 'includes/statistics';
$loadScripts[] = 'scriptaculous/canvastext';
$smarty->assign("T_CATEGORY", 'statistics');
//$smarty -> assign("T_BASIC_TYPE", $currentUser -> user['user_type']);
$smarty->assign("T_BASIC_TYPE", $_SESSION['s_lesson_user_type'] != "" ? $_SESSION['s_lesson_user_type'] : $currentUser->user['user_type']);
$isProfessor = 0;
$isStudent = 0;
//check to see if the user has any lessons as a student and any lessons as professor
$lessonRoles = EfrontLessonUser::getLessonsRoles();
if ($currentUser->user['user_type'] != 'administrator') {
    $lessons = $currentUser->getLessons(false);
    foreach ($lessons as $key => $type) {
        if ($lessonRoles[$type] == 'professor') {
            $isProfessor = 1;
            $professorLessons[] = $key;
        } else {
            if ($type == 'student') {
                $isStudent = 1;
                $studentLessons[] = $key;
            }
        }
    }
}
if (G_VERSIONTYPE == 'enterprise') {