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;
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); } }
/** * Delete user * * This function is used to delete a user from the system. * The user cannot be deleted if he is the last system administrator. * <br/>Example: * <code> * $user = EfrontUserFactory :: factory('jdoe'); * $user -> delete(); * </code> * * @return boolean True if the user was deleted successfully * @since 3.5.0 * @access public */ public function delete() { parent::delete(); $userDoneTests = eF_getTableData("done_tests", "id", "users_LOGIN='******'login'] . "'"); if (sizeof($userDoneTests) > 0) { eF_deleteTableData("done_questions", "done_tests_ID IN (" . implode(",", $userDoneTests['id']) . ")"); eF_deleteTableData("done_tests", "users_LOGIN='******'login'] . "'"); } eF_deleteTableData("users_to_lessons", "users_LOGIN='******'login'] . "'"); eF_deleteTableData("users_to_courses", "users_LOGIN='******'login'] . "'"); /* foreach ($this -> getCourses() as $id => $value) { $cacheKey = "user_course_status:course:".$id."user:"******"users_to_projects", "users_LOGIN='******'login'] . "'"); //eF_deleteTableData("users_to_done_tests", "users_LOGIN='******'login']."'"); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD eF_deleteTableData("users_to_skillgap_tests", "users_LOGIN='******'login'] . "'"); } #cpp#endif } #cpp#endif eF_deleteTableData("completed_tests", "users_LOGIN='******'login'] . "'"); }
/** * 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; }
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";
/** * Get group courses * * This function returns the list of courses that are part of this group, including unassigned * * @param array $constraints The constraints for the query * @return array An array of EfrontCourse objects or course arrays * @since 3.6.2 * @access public */ public function getGroupCoursesAggregatingResultsIncludingUnassigned($constraints = array()) { !empty($constraints) or $constraints = array('archive' => false, 'active' => true); list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints); $select = "c.*, (rr.courses_ID is not null OR r.courses_ID is not null) as has_course,\n \t(select count( * ) from courses l where instance_source=c.id)\n \tas has_instances,\n \t(select count( * ) from lessons_to_courses cl, lessons l where cl.courses_ID=c.id and l.archive=0 and l.id=cl.lessons_ID)\n \tas num_lessons,\n \t(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and c.archive=0 and u.active!=0 and u.archive=0 and uc.archive=0 and u.login=uc.users_LOGIN and uc.user_type IN ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "'))\n \tas num_students"; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $select .= ",(select count( * ) from module_hcd_course_offers_skill s where courses_ID=c.id)\n \t\tas num_skills"; } #cpp#endif //debug(); $result = eF_getTableData("courses c left outer join (select courses_ID from courses_to_groups where groups_ID=" . $this->group['id'] . ") r on c.id=r.courses_ID left outer join (select courses_ID,name,instance_source from courses c, courses_to_groups cg where c.id=cg.courses_ID and cg.groups_ID={$this->group['id']}) rr on rr.instance_source=c.id", $select, implode(" and ", $where), $orderby, $groupby, $limit); //debug(false); return EfrontCourse::convertDatabaseResultToCourseObjects($result); }
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"> </td> <td colspan = "2"> ' . $coursesTreeString . ' </td> </tr>'; } } return $treeString; }
} $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);
$avatar = new EfrontFile($editedUser->user['avatar']); } catch (Exception $e) { $avatar = new EfrontFile(G_SYSTEMAVATARSPATH . "unknown_small.png"); } $smarty->assign("T_AVATAR", $avatar['url_path']); $smarty->assign("T_EMPLOYEE_SKILLS", $skills_sorted); $smarty->assign("T_EMPLOYEE_SKILL_CATEGORIES", $skill_categories); $smarty->assign('T_EVALUATIONS', $evaluations = $editedEmployee->getEvaluations()); $smarty->assign("T_FORM_PLACEMENTS", $jobs = $editedEmployee->getJobs()); } #cpp#endif if ($editedUser->user['user_type'] != 'administrator') { $directionsTree = new EfrontDirectionsTree(); $directionsArray = $directionsTree->getFlatTree(); $smarty->assign("T_DIRECTIONS_TREE", $directionsPathStrings = $directionsTree->toPathString()); $studentRoles = EfrontLessonUser::getRoles(); foreach ($studentRoles as $key => $value) { if ($value != 'student') { unset($studentRoles[$key]); } } $constraints = array('archive' => false); if ($_COOKIE['setUserFormSelectedSort']) { preg_match("/\\d_(\\w+)--(\\w+)/", $_COOKIE['setUserFormSelectedSort'], $matches); in_array($matches[1], array('name', 'directions_ID', 'active_in_course', 'completed', 'score')) ? $constraints['sort'] = $matches[1] : ($constraints['sort'] = 'name'); $matches[2] == 'desc' ? $constraints['order'] = 'asc' : ($constraints['order'] = 'desc'); } $userCourses = $editedUser->getUserCourses($constraints); foreach ($userCourses as $key => $value) { if (!in_array($value->course['user_type'], array_keys($studentRoles))) { unset($userCourses[$key]);
if (isset($_GET['edit_user_group'])) { $currentGroup = new EfrontGroup($_GET['edit_user_group']); $smarty->assign("T_CURRENT_GROUP", $currentGroup); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY $smarty->assign("T_STATS_LINK", array(array('text' => _STATISTICS, 'image' => "16x16/reports.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=statistics&option=groups&sel_group=" . $_GET['edit_user_group'], 'target' => '_self'))); } #cpp#endif if ($currentGroup->group['key_max_usage'] > 0) { $remainingKeyUsagesLabel = '(' . _REMAINING . ' ' . ($currentGroup->group['key_max_usage'] - $currentGroup->group['key_current_usage']) . '/' . $currentGroup->group['key_max_usage'] . ')'; } } isset($_GET['add_user_group']) ? $postTarget = 'add_user_group=1' : ($postTarget = "edit_user_group=" . $_GET['edit_user_group']); $form = new HTML_QuickForm("add_group_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=user_groups&{$postTarget}", "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $roles = EfrontLessonUser::getStudentRoles(true); //array_unshift($roles, _DONTUSEDEFAULTGROUP); $roles = array(0 => _DONTUSEDEFAULTGROUP) + $roles; $form->addElement('text', 'name', _GROUPNAME, 'class = "inputText"'); $form->addElement('text', 'description', _DESCRIPTION, 'class = "inputText"'); $form->addElement('static', 'sidenote', '<img src = "images/16x16/wizard.png" class = "ajaxHandle" alt = "' . _AUTOMATICALLYGENERATEGROUPKEY . '" title = "' . _AUTOMATICALLYGENERATEGROUPKEY . '" onclick = "$(\'unique_key_id\').value = \'' . md5(time()) . '\';"/>'); // timestamp guarantess uniqueness $form->addElement('text', 'unique_key', _UNIQUEGROUPKEY, 'class = "inputText" id="unique_key_id"'); $form->addElement('static', 'note', _UNIQUEGROUPKEYINFO); $form->addElement('text', 'key_max_usage', _MAXGROUPKEYUSAGE, 'class = "inputText"'); $form->addElement('static', 'note', _MAXGROUPKEYUSAGEINFO . ' ' . $remainingKeyUsagesLabel); $form->addElement('select', 'user_types_ID', _DEFAULTLEARNERTYPE, $roles, 'class = "inputText"'); $form->addElement('static', 'note', _DEFAULTLEARNERTYPEINFO . ' ' . $remainingKeyUsagesLabel); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') {
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; }
public function getRecipients() { $recipients_list = array(); if (isset($this->notification['send_conditions'])) { //echo $this -> notification['send_conditions']; if ($this->notification['send_conditions'] == "N;") { $recipients = eF_getTableData("users", "*", "active=1 and archive=0"); //sending_queue_msgs[$key]['recipients'] = _ALLUSERS; foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } else { // the send_conditions field contains the information which identify the recipients // it is defined in .... //digests.php during the definition of the event notification $this->notification['send_conditions'] = unserialize($this->notification['send_conditions']); if ($this->notification['send_conditions'] == "supervisors") { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $recipients = eF_getTableData("module_hcd_employee_works_at_branch as meb, users as u", "u.*", "meb.users_login=u.login and u.active=1 and u.archive=0 and meb.supervisor=1"); foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } #cpp#endif } elseif (is_array($this->notification['send_conditions'])) { $this->recipients = $this->notification['send_conditions']; // The recipients array definitely exists, due to constructor checks if (isset($this->recipients["lessons_ID"]) && $this->recipients["lessons_ID"]) { $lesson = new EfrontLesson($this->recipients["lessons_ID"]); if (isset($this->recipients["user_type"])) { // return lesson users of specific type $recipients = array(); foreach ($lesson->getUsers($this->recipients["user_type"]) as $value) { if ($value['active']) { $recipients[] = $value; } } } else { if (isset($this->recipients["completed"])) { // return lesson students according to whether they have completed the lesson or not $recipients = array(); foreach ($lesson->getUsersCompleted($this->recipients["completed"]) as $value) { if ($value['active']) { $recipients[] = $value; } } } else { // return all users $recipients = array(); foreach ($lesson->getUsers() as $value) { if ($value['active']) { $recipients[] = $value; } } } } } else { if (isset($this->recipients["courses_ID"])) { $entity_parts = explode("_", $this->notification['id_type_entity']); $notification_type = $entity_parts[1]; if ($this->recipients['user_type'] == "professor") { $completed_condition = " AND uc.user_type = 'professor'"; } else { if ($this->recipients['completed'] == "1") { $completed_condition = " AND completed = '1'"; } else { if ($this->recipients['completed'] == "2" || $notification_type == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) { $completed_condition = " AND completed = '0' and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')"; } else { $completed_condition = ""; } } } if ($this->recipients['supervisor']) { if ($this->recipients['users_login']) { $editedUser = EfrontUserFactory::factory($this->recipients['users_login']); //new EfrontUser(); $editedEmployee = $editedUser->aspects['hcd']; $supervisors = $editedEmployee->getSupervisors(); $recipients = array(); foreach ($supervisors as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } else { $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)"; //get course users' supervisors $result = eF_executeNew($query); $recipients = $result->getAll(); } } elseif ($this->recipients['immediate_supervisor']) { if ($this->recipients['users_login']) { $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and assigned=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')"); $recipients = array(); foreach ($result['users_LOGIN'] as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } $filtered_recipients = array(); if (!empty($recipients)) { $active_recipients = eF_getTableDataFlat("users", "login", "active=1 and archive=0 and login IN ('" . implode("','", array_keys($recipients)) . "')"); foreach ($active_recipients["login"] as $login) { $filtered_recipients[$login] = array("login" => $login); } $recipients = $filtered_recipients; } } else { $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where ewb.assigned=1 and supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and ewb.assigned=1 and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)"; //get course users' supervisors $result = eF_executeNew($query); $recipients = $result->getAll(); } } else { $recipients = eF_getTableData("users_to_courses uc, users u", "u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID, uc.user_type as role", "u.active=1 and u.archive=0 and uc.archive=0 and uc.users_LOGIN = u.login and uc.courses_ID=" . $this->recipients["courses_ID"] . $completed_condition); } } else { if (isset($this->recipients['user_type'])) { $recipients = eF_getTableData("users", "*", "active=1 and archive=0 and user_type = '" . $this->recipients['user_type'] . "'"); } else { if (isset($this->recipients['entity_ID']) && isset($this->recipients['entity_category'])) { if ($this->recipients['entity_category'] == "survey") { $recipients = eF_getTableData("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and surveys_ID = '" . $this->recipients["entity_ID"] . "'"); $notified = eF_getTableDataFlat("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and users_to_surveys.last_post > 1 and surveys_ID = '" . $this->recipients["entity_ID"] . "'"); //$resDone = eF_getTableDataFlat("users_to_done_surveys", "users_LOGIN", "surveys_ID=".$this -> recipients["entity_ID"]); $usersToSent = array(); if (!empty($notified['login'])) { foreach ($recipients as $key => $value) { if (!in_array($value['login'], $notified['login'])) { $usersToSent[] = $value; //eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login']."' and surveys_ID='".$this -> recipients["entity_ID"]."'"); } } $recipients = $usersToSent; } foreach ($recipients as $key => $value) { // in order to include case empty($notified['login'] eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login'] . "' and surveys_ID='" . $this->recipients["entity_ID"] . "'"); } } else { if ($this->recipients['entity_category'] == "projects") { $recipients = eF_getTableData("users_to_projects JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and projects_ID = '" . $this->recipients["entity_ID"] . "'"); } } } else { if (isset($this->recipients["groups_ID"])) { $recipients = eF_getTableData("users_to_groups JOIN users ON users_login = users.login", "users.*", "users.active=1 and users.archive=0 and groups_ID = '" . $this->recipients["groups_ID"] . "'"); } else { if (isset($this->recipients['users_login'])) { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (isset($this->recipients['supervisor'])) { $editedUser = EfrontUserFactory::factory($this->recipients['users_login']); //new EfrontUser(); $editedEmployee = $editedUser->aspects['hcd']; $supervisors = $editedEmployee->getSupervisors(); $recipients = array(); foreach ($supervisors as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } elseif (isset($this->recipients['immediate_supervisor'])) { $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')"); $recipients = array(); foreach ($result['users_LOGIN'] as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } else { $recipients = $this->recipients['users_login']; } } else { #cpp#else $recipients = $this->recipients['users_login']; } #cpp#endif } } } } } } foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } else { if ($this->notification['recipient'] != "") { preg_match("/\\d+_(\\d+)/", $this->notification['id_type_entity'], $matches); if ($matches[1] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) { //In this case, we want an inactive user to receive the email $user = eF_getTableData("users", "*", "archive=0 and login = '******'recipient'] . "'"); } else { $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'"); } if (!empty($user)) { $recipients_list[$this->notification['recipient']] = $user[0]; } } } } } else { if ($this->notification['recipient'] != "") { $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'"); if (!empty($user)) { $recipients_list[$this->notification['recipient']] = $user[0]; } } } return $recipients_list; }
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"; } }
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') {