コード例 #1
0
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;
}
コード例 #2
0
}
$params = array();
$serializer = new IntuitelXMLSerializer();
$xml = block_intuitel_get_input_message();
$log->LogDebug("loMapping Request: {$xml}");
$intuitel_elements = IntuitelController::getIntuitelXML($xml);
$loMappings = IntuitelXMLSerializer::get_required_element($intuitel_elements, 'LoMapping');
$loMappingResults = array();
foreach ($loMappings as $loMapping) {
    $mid = IntuitelXMLSerializer::get_required_attribute($loMapping, 'mId');
    if (isset($loMappingResults[$mid])) {
        throw new ProtocolErrorException("Duplicated message id: {$mid}");
    }
    $params = $serializer->parse_mapping_request($loMapping);
    // support sending KVP for testing
    foreach ($_GET as $name => $value) {
        if ($name != 'xml' && $name != 'XDEBUG_SESSION_START') {
            $val = optional_param($name, null, PARAM_TEXT);
            if (isset($val)) {
                // CHECK if NULL is valid parameter
                $params[$name] = $val;
            }
        }
    }
    $result = Intuitel::getAdaptorInstanceForCourse(null)->findLObyAttributes($params);
    $loMappingResults[$mid] = $result;
}
$response = $serializer->serializeLoMapping($loMappingResults);
$log->LogDebug("Mapping response: {$response}");
header('Content-type: text/xml');
echo $response;
コード例 #3
0
// along with INTUITEL for Moodle Adaptor.  If not, see <http://www.gnu.org/licenses/>.
/**
 * REST interface.
 *
 * @package    block_intuitel
 * @author Juan Pablo de Castro, Elena Verdú.
 * @copyright  2015 Intuitel Consortium
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
use intuitel\IntuitelXMLSerializer;
use intuitel\Intuitel;
use intuitel\ProtocolErrorException;
use intuitel\IntuitelController;
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once 'locallib.php';
require_once 'model/exceptions.php';
require_once 'model/intuitelController.php';
block_intuitel_disable_moodle_page_exception_handler();
block_intuitel_check_access();
global $CFG;
$xml = block_intuitel_get_input_message();
$intuitel_msg = IntuitelController::getIntuitelXML($xml);
$lmsProfile = $intuitel_msg->LmsProfile;
$mid = IntuitelXMLSerializer::get_required_attribute($lmsProfile, 'mId');
if (!isset($mid)) {
    throw new ProtocolErrorException("Bad LmsProfile request.");
}
$serializer = new IntuitelXMLSerializer();
$properties = Intuitel::getAdaptorInstance()->getLMSProfile();
header('Content-type: text/xml');
echo $serializer->serializeLMSProfile($mid, $properties);
コード例 #4
0
}
/*
 * 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 {
コード例 #5
0
}
$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);
        if ($learningObject instanceof CourseLO) {
            $course = $learningObject;
        } else {
            $sectionId = $learningObject->getParent();
            $section = $adaptor->createLO($sectionId);
            $courseId = $section->getParent();
            $course = $adaptor->createLO($courseId);
コード例 #6
0
            // The browser use Javascript.
            if ($tugcancelledfield === 'true') {
                $_REQUEST['_intuitel_user_intent'] = 'cancel';
            } else {
                $_REQUEST['_intuitel_user_intent'] = 'submit';
            }
        }
        // JPC: end of workaround for YUI bug with forms.
        if ($_REQUEST['_intuitel_user_intent'] === 'submit') {
            // Ignore cancellation of the TUG messages.
            // TODO: Avoid sending this form in the User Interface but find a way to work without javascript too.
            $message = IntuitelController::ProcessTUGResponse($USER->id, $_REQUEST, $courseid);
            $log->LogDebug("LMS sends TUG answer: {$message}");
            block_intuitel_submit_to_intuitel($message);
        } else {
            $mid = required_param('mId', PARAM_ALPHANUMEXT);
            Intuitel::getAdaptorInstance()->logTugDismiss($courseid, $USER->id, $mid, 'DISMISS mId=' . $mid);
        }
    } else {
        if ($action == 'GEOLOCATION') {
            require_login();
            session_write_close();
            // Release the session to avoid block requests while waiting intuitel response.
            $adaptor = Intuitel::getAdaptorInstance();
            // Location.
            $lat = required_param('lat', PARAM_FLOAT);
            $lon = required_param('lon', PARAM_FLOAT);
            $adaptor->registerEnvironment('dLocation', "EPSG:4326;POINT({$lat} {$lon})", $USER, time());
        }
    }
}
コード例 #7
0
 /**
  * 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);
 }
コード例 #8
0
 public function register_environment_values()
 {
     global $USER;
     $adaptor = Intuitel::getAdaptorInstance();
     // User agent.
     // The function get_user_device_type() was deprecated in Moodle 2.6.
     $device = class_exists('core_useragent') ? core_useragent::get_user_device_type() : get_user_device_type();
     $adaptor->registerEnvironment('dType', $device, $USER, time());
 }