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;
}
// 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);
 public static function ProcessTUGResponse($native_user_id, array $params, $courseid)
 {
     $userID = Intuitel::getIDFactory()->getUserId($native_user_id);
     $response = IntuitelXMLSerializer::getIntuitelXMLTemplate();
     $tug_xml = $response->addChild('Tug', null, INTUITEL_LMS_NAMESPACE_URI);
     $tug_xml->addAttribute('uId', $userID->id);
     $tug_xml->addAttribute('mId', $params['mId']);
     if ($params['_intuitel_user_intent'] == 'cancel') {
         // dismiss TUG message	DEPRECATED according final D1.1 cancelled TUGs are not reported
         throw new ProtocolErrorException("Cancelled TUGs shouldn't be reported to INTUITEL.", 400);
         $tug_xml->addAttribute('retVal', "OK");
     } else {
         // process form and send it to INTUITEL
         $msg_datas = '';
         foreach ($params as $name => $value) {
             if ($name != 'mId' && $name != '_intuitel_intent' && $name != '_intuitel_user_intent' && $name != '_intuitel_TUG_cancel' && $name != 'courseid') {
                 if (is_array($value)) {
                     foreach ($value as $val) {
                         $data_xml = $tug_xml->addChild("Data", null, INTUITEL_LMS_NAMESPACE_URI);
                         $data_xml->addAttribute('name', $name);
                         $data_xml->addAttribute('value', $val);
                         $msg_datas .= "{$name} = {$val} ,";
                     }
                 } else {
                     $data_xml = $tug_xml->addChild("Data", null, INTUITEL_LMS_NAMESPACE_URI);
                     $data_xml->addAttribute('name', $name);
                     $data_xml->addAttribute('value', $value);
                     $msg_datas .= "{$name} = {$value} ,";
                 }
             }
         }
         if ($msg_datas != '') {
             $mid = required_param('mId', PARAM_ALPHANUMEXT);
             $info = 'ANSWER to mId=' . $mid . '  Data:' . $msg_datas;
             Intuitel::getAdaptorInstance()->logTugAnswer($courseid, $native_user_id, $mid, $info);
         }
     }
     return IntuitelXMLSerializer::formatXmlString($response->asXML());
 }
Beispiel #4
0
global $CFG;
if (get_config('block_intuitel', 'debug_level') != KLogger::DEBUG) {
    echo "This debug function can only be used when debugging is enabled in Intuitel preferences with level: DEBUG.";
    die;
}
if ($fromtime_str) {
    $fromtime = strtotime($fromtime_str);
} else {
    $fromtime = time() - $time;
}
if ($totime_str) {
    $totime = strtotime($totime_str);
} else {
    $totime = time();
}
$adaptor = Intuitel::getAdaptorInstance();
$courseLo = $adaptor->createLO(Intuitel::getIDFactory()->getLoIdfromId('course', $courseid));
$userID = Intuitel::getIDFactory()->getUserId($userid);
$events_user = $adaptor->getLearnerUpdateData(array($userid), $courseLo, $fromtime, $totime, false);
$interactionEvents = $adaptor->getINTUITELInteractions(array($userid), $courseLo, $fromtime, $totime, false);
$events = array();
if (array_key_exists((string) $userID, $events_user)) {
    $events = $events_user[(string) $userID];
}
// merge and sort arrays
if ($include_INTUITEL) {
    $events = $events + $interactionEvents;
    ksort($events);
    // key is the sequential id of the event table in Moodle
}
// limit events to process
 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());
 }