Пример #1
0
require_once 'locallib.php';
require_once 'model/exceptions.php';
require_once 'model/intuitelController.php';
global $log;
block_intuitel_disable_moodle_page_exception_handler();
if (!isset($_SESSION['user_validated'])) {
    block_intuitel_check_access();
} else {
    $log->LogDebug("Mapping request authenticated as:" . join(',', $_SESSION['user_ids_validated']));
}
$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;
            }
 /**
  * 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);
 }