/** * For an activity LO, retrieves the moodle id of the following activity/resource (course_module) in the section of the activity * or null if this is the last activity in that section * @param \cm_info $rawData Moodle internal info for a course module * @return string|NULL id of the following activity/resource (Course_module) */ private function getFollowingSib($rawData) { $course_info = $rawData->get_modinfo(); //get the course_modinfo object with all data of the course $section = $course_info->get_section_info($rawData->sectionnum); $cmsId = explode(',', $section->sequence); //array with the ids of the cms in that section $position = array_keys($cmsId, $rawData->id); //position of the cm in the sequence $pos = $position[0]; $num_mods = count($cmsId); while (true) { // if($position[0]==(count($cmsId)-1)){ //it is the last in the section, not previous cm if ($pos == $num_mods - 1) { //it is the last in the section, not previous cm $FollowingSib = null; break; } else { // get the previous cm in the sequence $FollowingSib = $cmsId[$pos + 1]; // check if type is ignored $factory = Intuitel::getAdaptorInstance()->getGuessedFactory($course_info->get_cm($FollowingSib)); if (!$factory->toBeIgnored()) { break; } } $pos++; } // end of while return $FollowingSib; }
function getINTUITELInteractionsPre2_7(array $native_user_ids = null, CourseLO $course = null, $from = null, $to = null, $filter_offline_users = true) { global $DB; $native_courseids = array(); $native_userids = array(); $interactionEvents = array(); if ($native_user_ids != null) { $native_userids = $native_user_ids; } $adaptor = Intuitel::getAdaptorInstance(); if ($course == null) { // retrieve all intuitel enabled courses $courses = $adaptor->getIntuitelEnabledCourses(); } else { $courses = array($course); } // Collect course ids and user ids. foreach ($courses as $course) { $native_courseids[] = Intuitel::getIDFactory()->getIdfromLoId($course->getloId()); if ($native_user_ids == null) { //get all users enrolled in the different intuitel enabled courses $native_userids = array_merge($native_userids, $adaptor->getUsersEnrolled($course)); } } if ($filter_offline_users) { //filter out those users who are not currently online $native_activeuserids = block_intuitel_get_online_users($native_userids); } else { $native_activeuserids = $native_userids; } if ($from === null) { $fromsql = 0; } else { $fromsql = $from; } // Retrieve from database the events using $fromsql. if (!empty($native_activeuserids)) { list($insql, $inparams) = $DB->get_in_or_equal($native_activeuserids); list($insqlCourses, $inparamsCourse) = $DB->get_in_or_equal($native_courseids); if ($to == null) { //not upper limit of time $params = array_merge($inparamsCourse, array('from' => $fromsql), $inparams); $sql = "SELECT * FROM {log} WHERE course {$insqlCourses} AND time >= ? AND userid {$insql} AND module = 'INTUITEL' ORDER BY time ASC"; } else { $params = array_merge($inparamsCourse, array('from' => $fromsql, 'to' => $to), $inparams); $sql = "SELECT * FROM {log} WHERE course {$insqlCourses} AND time >= ? and time <= ? AND userid {$insql} AND module = 'INTUITEL' ORDER BY time ASC"; } $events = $DB->get_records_sql($sql, $params); foreach ($events as $event) { $userId = intuitel::getIDFactory()->getUserId($event->userid); $interactionEvents[$event->id] = new InteractionEvent($userId, $event->id, $event->action . ':' . $event->info, $event->time); } } return $interactionEvents; }
public function getIDRegExpr() { $lmsid = Intuitel::getAdaptorInstance()->getLMSId(); return "/{$lmsid}-([a-zA-z]+)([0-9]+)/"; }