コード例 #1
0
    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);
        if ($learningObject instanceof CourseLO) {
            $course = $learningObject;
        } else {
            $sectionId = $learningObject->getParent();
            $section = $adaptor->createLO($sectionId);
            $courseId = $section->getParent();
コード例 #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
 /**
  * Parse xml response and generate proper html to be inserted in a DIV in the user interface
  * @throws ProtocolErrorException if userId is not current user
  *
  *
  * @param string $xml
  * @return array(string,SimpleXMLElement)
  */
 public static function ProcessUpdateLearnerRequest($xml, $courseid)
 {
     $intuitel_elements = IntuitelController::getIntuitelXML($xml);
     $learner = IntuitelXMLSerializer::get_required_element($intuitel_elements, 'Learner');
     $user_id = IntuitelXMLSerializer::get_required_attribute($learner, 'uId');
     $adaptor = Intuitel::getAdaptorInstanceForCourse();
     $user = $adaptor->getNativeUserFromUId(new UserId($user_id));
     global $USER;
     if ($USER->id != $user->id) {
         throw new AccessDeniedException("User {$user->id} is not current user");
     }
     // Generate HTML for the TUG and LORE parts
     $html = $adaptor->generateHtmlForTugAndLore($intuitel_elements, $courseid);
     return array($html, $intuitel_elements);
 }