function block_intuitel_add_loId_decorations($tug_mdata) { global $CFG; $tug_mdata = trim($tug_mdata); if (strpos($tug_mdata, '<![CDATA[') === 0) { $tug_mdata = substr($tug_mdata, 9, strlen($tug_mdata) - 9 - 3); } $regExpr = Intuitel::getIDFactory()->getIDRegExpr(); preg_match_all($regExpr, $tug_mdata, $results); foreach ($results[0] as $result) { $cmid = Intuitel::getIDFactory()->getIdfromLoId(new LOId($result)); $lo = Intuitel::getAdaptorInstance()->createLO(new LOId($result)); $type = Intuitel::getIDFactory()->getType(new LOId($result)); if ($type != 'section' && $type != 'course') { $module_link = block_intuitel_generateHtmlModuleLink($cmid); } else { $module_link = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $cmid . '">' . $lo->loName . '</a>'; } $tug_mdata = str_replace($result, $module_link, $tug_mdata); } return $tug_mdata; }
// http://localhost/moodle2/blocks/intuitel/tests/mockrest/intuitel.php?debugresponse=true&userid=3&xml=%3CINTUITEL%3E%3CLearner%20uId=%22pepe%22%20loId=%22wqHKFQmiYXEq4tE6y4BztVFIdzsIe2d7localhost-CO2%22%20debugcourse=%222%22/%3E%3C/INTUITEL%3E // accept: debugcourse with native courseid to simulare Lore Loids // debugresponse to enable HTML page formating // userid to use native userid in the request. $debugresponse = optional_param('debugresponse', false, PARAM_ALPHANUM); if ($debugresponse == false) { block_intuitel_disable_moodle_page_exception_handler(); } $native_userid = optional_param('userid', null, PARAM_INTEGER); $query = block_intuitel_get_input_message(); $intuitelMsg = IntuitelController::getIntuitelXML($query); //sleep(4); if ($intuitelMsg->Learner) { if ($native_userid) { // Debugging backdoor $learnerid = Intuitel::getIDFactory()->getUserId($native_userid); } else { $learnerid = (string) $intuitelMsg->Learner['uId']; } $loId = new LOId((string) $intuitelMsg->Learner['loId']); $nativeCourseId = (string) $intuitelMsg->Learner['debugcourse']; $adaptor = Intuitel::getAdaptorInstanceForCourse(); $idFactory = Intuitel::getIdFactory(); if ($nativeCourseId) { global $PAGE; $context = context_course::instance($nativeCourseId); $PAGE->set_context($context); $courseLoId = $idFactory->getLoIdfromId('course', $nativeCourseId); $course = $adaptor->createLO($courseLoId); } else { $learningObject = $adaptor->createLO($loId);
} /* * Graph title */ $graph_title = "fontsize=20;\nlabelloc=\"t\";\nlabel = \"Graph of user {$userid} activity from {$fromtime_label} to {$totime_label}\";"; /* * transitions */ $previousEvent = null; $durations = array_reverse($durations); $num = 1; foreach ($durations as $event) { $isInter = $event instanceof intuitel\InteractionEvent; $class = get_class($event); if ($class == 'intuitel\\VisitEvent') { $eventType = Intuitel::getIDFactory()->getType($event->loId); } else { $eventType = 'Interaction'; } if ($supress_course && $eventType == 'course') { continue; } if ($previousEvent == null) { $first_node = $event; $previousEvent = $event; $graph_start_node = "\t start_node [shape=doublecircle, fillcolor=black label=\"\"]\n"; $graph_start_node .= "\t" . loId_escape($event->loId) . "\n"; //."[shape=box3d, style=filled, fillcolor=plum];\n"; $graph_start_node .= "\tstart_node -> "; $graph_start_node .= "\t" . loId_escape($event->loId) . "[ {$constraint} ];\n"; } else {
/** * Calculate an array with differential information and without contiguous visit events to Course Modules. * A chain of events regarding to the same loId is filtered out. * @param array:VisitEvent $eventsArray ordered by time ASC * @param int timestamp of the end of the time window if null time() is assumed * @return array:VisitEvent with duration field computed. ordered by time. Newer first. Course and sections are excluded */ public static function compute_durations($eventsArray, $totime = null) { $delays = array(); $lastseen = null; $current = null; if ($totime == null) { $totime = time(); } $eventsArray = array_reverse($eventsArray); // older last while (($current = array_pop($eventsArray)) != null) { if ($lastseen == null || $lastseen->loId != $current->loId) { try { if ($current instanceof intuitel\VisitEvent) { $type = Intuitel::getIDFactory()->getType($current->loId); } else { $type = 'Interaction'; } if ($type != 'section') { $delays[] = $current; } } catch (UnknownLOException $e) { // ignore this event (probably a deleted content) } if ($lastseen != null) { $lastseen->duration = min($current->time - $lastseen->time, 15 * 60); } // limit 15 min // TODO detect and exclude logoffs and absentions $lastseen = $current; } } if ($lastseen) { $lastseen->duration = $totime - $lastseen->time; } return array_reverse($delays); }