Example #1
0
function voiceauthoring_get_url_params($courseid)
{
    global $USER;
    global $CFG;
    $context = get_context_instance(CONTEXT_COURSE, $courseid);
    $role = voiceauthoring_getRole($context);
    $signature = md5($courseid . $USER->email . $USER->firstname . $USER->lastname . $role);
    $url_params = "enc_course_id=" . rawurlencode($courseid) . "&enc_email=" . rawurlencode($USER->email) . "&enc_firstname=" . rawurlencode($USER->firstname) . "&enc_lastname=" . rawurlencode($USER->lastname) . "&enc_role=" . rawurlencode($role) . "&signature=" . rawurlencode($signature);
    return $url_params;
}
require_once 'lib/php/vt/VtAction.php';
require_once 'lib/php/vt/WimbaVoicetools.php';
require_once 'lib/php/vt/WimbaVoicetoolsAPI.php';
global $CFG, $USER;
$vtAction = new vtAction($USER->email);
$course_id = optional_param('course_id', 0, PARAM_INT);
$block_id = optional_param('block_id', 0, PARAM_INT);
require_login($course_id);
if (!isset($CFG->voicetools_servername)) {
    echo "<script language='javascript'>window.location.replace('error.php?error=problem_vt')</script>";
    exit;
}
$vtUser = new VtUser(NULL);
$vtUserRigths = new VtRights(NULL);
$context = get_context_instance(CONTEXT_COURSE, $course_id);
if (voiceauthoring_getRole($context) == "Instructor") {
    $vtUserRigths->setProfile('moodle.recorder.instructor');
    $type = "record";
} else {
    $vtUserRigths->setProfile('moodle.recorder.student');
    $type = "play";
}
$rid = voiceauthoring_get_resource_rid($course_id);
if ($rid === false) {
    $result = $vtAction->createRecorder("Voice Authoring associated to the course " . $course_id);
    //create the resource on the vt
    if ($result != NULL && $result->error != "error") {
        if (!storeResource($result->getRid(), $course_id, "recorder", $course_id . "_recorder")) {
            $rid = $result->getRid();
            //problem to insert the record in db
        }