/**
  * From a moodle course_modinfo object, it creates an intuitel LO
  * @author elever
  * @see \intuitel\LOFactory::createLOFromNative()
  * @param \course_modinfo $rawData : moodle course_modinfo object
  * @return CourseLO $course : intuitelLO course object
  */
 function createLOFromNative($rawData)
 {
     $lmscourse = $rawData->get_course();
     $courseLoid = Intuitel::getIDFactory()->getLoIdfromId('course', $lmscourse->id);
     // course object is created, constructor sets the compulsory attributes: LOId, loName, hasPrecedingSib, hasParent; and the optional: hasFollowingSib
     $course = new CourseLO($courseLoid, $lmscourse->fullname, null, null);
     // optional attributes
     $courseLang = $this->getLang($rawData);
     $course->setLang($courseLang);
     $childrenLoId = $this->getChildren($rawData);
     $course->sethasChildren($childrenLoId);
     return $course;
 }
 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;
 }