当前位置: 首页>>代码示例>>PHP>>正文


PHP EfrontLesson::getConditions方法代码示例

本文整理汇总了PHP中EfrontLesson::getConditions方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontLesson::getConditions方法的具体用法?PHP EfrontLesson::getConditions怎么用?PHP EfrontLesson::getConditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EfrontLesson的用法示例。


在下文中一共展示了EfrontLesson::getConditions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUserLessonStatus

 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 ='" . $user['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;
//.........这里部分代码省略.........
开发者ID:bqq1986,项目名称:efront,代码行数:101,代码来源:statistics.class.php


注:本文中的EfrontLesson::getConditions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。