/**
 * This method returns average message length for all users who are all posted messages for given resource id.
 * @param rid - Resource ID
 * @return an array. Each item contains an other array where the key will be message_len and screen_name
 */
function voicetools_get_average_length_messages_per_user($rid)
{
    global $CFG;
    $soapclient = new soap_client($CFG->voicetools_servername . VT_API_SERVICES, true);
    $err = $soapclient->getError();
    if ($err) {
        wimba_add_log(WIMBA_ERROR, voiceboard_LOGS, __FUNCTION__ . ' : Error to create the soap element');
        return false;
    }
    $resource = array($CFG->voicetools_adminusername, $CFG->voicetools_adminpassword, $rid);
    $result = $soapclient->call(VT_API_GET_AVERAGE_MESSAGE_LENGTH_PER_USER, $resource);
    if ($soapclient->fault) {
        wimba_add_log(WIMBA_ERROR, voiceboard_LOGS, __FUNCTION__ . ' : Fault with the web service : ' . $soapclient->fault);
        return false;
    } else {
        // Check for errors
        $err = $soapclient->getError();
        if ($err == "operation getAverageMessageLengthPerUser not present.") {
            return "not_implemented";
        } else {
            if ($err) {
                wimba_add_log(WIMBA_ERROR, voiceboard_LOGS, __FUNCTION__ . ' : error with the web service : ' . $err);
                return false;
            }
        }
    }
    return pairsetToArray($result);
}
 function lcapi_getMP4Status($archiveId, $startGenerate, $userid)
 {
     if (empty($archiveId)) {
         wimba_add_log(WIMBA_ERROR, WC, __FUNCTION__ . "archive should not be empty");
         return false;
     }
     $params = "&class_id=" . $this->prefix . $archiveId;
     if (!empty($startGenerate)) {
         $params .= "&start_generate={$startGenerate}";
     }
     if (!empty($userid)) {
         $params .= "&user_id=" . $userid;
     }
     $enc_params = str_replace(" ", "+", $params);
     $response = $this->lcapi_send_query(LCAPI_FUNCTION_GET_MP4_STATUS, $enc_params);
     preg_match("(\\d*)", $response, $matches);
     $lc_respcode = $matches[0];
     if ($lc_respcode != 100) {
         $this->lcapi_error(LCAPI_ECRUD);
         wimba_add_log(WIMBA_ERROR, WC, __FUNCTION__ . ") with {$lc_respcode}");
         return false;
     }
     list(, $body) = explode("\n", $response, 2);
     $records = explode(LCAPI_RECORD_SEPARATOR, $body);
     $lines = explode("\n", $records[0]);
     foreach ($lines as $line) {
         if (!empty($line)) {
             list($key, $value) = explode("=", $line);
             if (!empty($key)) {
                 $audioInfo[$key] = $value;
             }
         }
     }
     if ($userid != null) {
         $authToken = $this->lcapi_get_session($userid, "");
     }
     $audioFile = new LCAudioFileStatus($audioInfo, $authToken);
     return $audioFile;
 }
require_once "../../config.php";
require_once 'lib/php/common/WimbaLib.php';
require_once 'lib/php/vt/WimbaVoicetoolsAPI.php';
$user = optional_param("user", PARAM_ALPHANUM);
$pass = optional_param("pass", PARAM_ALPHANUM);
$server = optional_param("server", PARAM_TEXT);
$result = voicetools_api_check_documentbase($server, $user, $pass, $CFG->wwwroot);
if ($result != "ok") {
    if (get_string($result, 'voicetools') == "[[" . $result . "]]") {
        //the error description is not in the bundle
        wimba_add_log(WIMBA_ERROR, "wimbaConfiguration", $result);
        echo get_string("generic_error", 'voicetools');
    } else {
        wimba_add_log(WIMBA_ERROR, "wimbaConfiguration", get_String($result, 'voicetools'));
        echo get_string($result, 'voicetools');
    }
} else {
    $php_extension = get_loaded_extensions();
    for ($i = 0; $i < count($php_extension); $i++) {
        if ($php_extension[$i] == "libxml" || $php_extension[$i] == "domxml") {
            wimba_add_log(WIMBA_INFO, 'wimbaConfiguration', "The module is well configured");
            echo $result;
            exit;
        }
    }
    wimba_add_log(WIMBA_INFO, 'wimbaConfiguration', "domxml is not installed");
    echo get_string("domxml", 'voicetools');
}
//add important informations to the log
wimba_add_log(WIMBA_INFO, 'wimbaConfiguration', "php info :\n" . print_r(get_loaded_extensions(), true));
$sentence1 = get_string('vtpopupshouldappear.1', 'voiceemail');
$sentence2 = "<a href='javascript:startVoiceTools()';>" . get_string('vtpopupshouldappear.2', 'voiceemail') . "</a>";
$sentence3 = get_string('vtpopupshouldappear.3', 'voiceemail');
$strLaunchComment = $sentence1 . $sentence2 . $sentence3;
//get the informations related to the Vt resource
$vtAction = new vtAction($USER->email);
$dbResource = get_record("voiceemail_resources", "id", $voicetool->rid);
$resource = $vtAction->getResource($dbResource->rid);
//check the availability of the resource
$roleSwitch = isSwitch();
//the user have switched his role?
//determinate the role for the wimba tools
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$role = voiceemail_getRole($context);
if ($resource->error == true) {
    wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "view.php : problem to get the resource(rid : " . $voicetool->rid . ") linked to this activity");
    error(get_string("problem_vt", "voiceemail"), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
}
$currentUser = $vtAction->createUser($USER->firstname . "_" . $USER->lastname, $USER->email);
$currentUserRights = $vtAction->createUserRights($resource->getType(), $role);
$resource->setEmailFrom($USER->email);
//get the vt session
$vtSession = $vtAction->getVtSession($resource, $currentUser, $currentUserRights);
if (function_exists("build_navigation")) {
    $cm->modname = "voiceemail";
    $cm->name = $voicetool->name;
    $navigation = build_navigation('', $cm);
    print_header("{$course->shortname}: {$voicetool->name}", $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $strvoicetool . " " . get_string('activity', 'voiceemail')), navmenu($course));
} else {
    $navigation = array();
    if ($course->id != SITEID) {
/**
* List all the resource for the course given
* @param $courseId - the current course id
* @return the  of the boards rid 
*/
function voicepresentation_get_voicetool_informations($rid)
{
    $tool = get_record('voicepresentation_resources', 'rid', $rid);
    if (empty($tool)) {
        wimba_add_log(WIMBA_INFO, voicepresentation_LOGS, "No resources have been created yet");
        return null;
    } else {
        if ($tool === false) {
            wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "Problem to get the list of resources");
            error("Response get_board_list : query to database failed");
            return "error_moodleDatabase";
        }
    }
    wimba_add_log(WIMBA_DEBUG, voicepresentation_LOGS, "list of resource :\n" . print_r($tool, true));
    return $tool;
}
foreach (getKeysOfGeneralParameters() as $param) {
    $value = optional_param($param["value"], $param["default_value"], $param["type"]);
    if ($value != null) {
        $params[$param["value"]] = $value;
    }
}
require_login($params["enc_course_id"]);
$uiManager = new WimbaUI($params);
wimba_add_log(WIMBA_DEBUG, voicepresentation_LOGS, "getXmlListPanel : parameters  \n" . print_r($params, true));
if (isset($params["error"])) {
    wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "getXmlListPanel : " . get_string($params["error"], 'voicepresentation'));
    $uiManager->setError(get_string($params["error"], 'voicepresentation'));
} else {
    //Session Management
    if ($uiManager->getSessionError() === false) {
        $message = "";
        if (!empty($messageProduct) && !empty($messageAction)) {
            $message = get_string("message_" . $messageProduct . "_start", "voicepresentation") . "  " . get_string("message_" . $messageAction . "_end", "voicepresentation");
        }
        $uiManager->getVTPrincipalView($message, "presentation");
    } else {
        //bad session
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "getXmlListPanel : " . get_string('error_session', 'voicepresentation'));
        $uiManager->setError(get_string('error_session', 'voicepresentation'));
    }
}
wimba_add_log(WIMBA_DEBUG, voicepresentation_LOGS, "getXmlListPanel : xml generated \n" . $uiManager->getXmlString());
if (isset($error_wimba)) {
    $uiManager->setError(get_string('error_display', 'voicepresentation'));
}
echo $uiManager->getXmlString();
function manage_error($errno, $error, $file, $line, $context)
{
    global $error_wimba;
    if ($errno == E_USER_ERROR or $errno == E_ERROR) {
        wimba_add_log(WIMBA_ERROR, "general", $error . " in " . $file . " line " . $line);
        $error_wimba = true;
    } else {
        if ($errno < E_USER_NOTICE) {
            wimba_add_log(WIMBA_DEBUG, "general", $error . " in " . $file . " line " . $line);
        }
    }
}
function voiceauthoring_get_block_informations($blockId)
{
    $recorder = get_record('voiceauthoring_block', 'bid', $blockId);
    if ($recorder === false) {
        $recorder->bid = $blockId;
        $recorder->comment = "Configure this block to add a description";
        $recorder->title = "Voice Authoring";
        $id = insert_record("voiceauthoring_block", $recorder);
    }
    wimba_add_log(WIMBA_DEBUG, voiceauthoring_LOGS, "Recorder informations : \n" . print_r($recorder, true));
    return $recorder;
}
 /**
  * 
  * 
  */
 function getListVoiceTools()
 {
     $resources = array();
     $list = voiceemail_get_voicetools_list($this->session->hparams["course_id"]);
     if ($list != false) {
         $vtResources = voicetools_api_get_resources($list["rid"]);
         if ($vtResources === false) {
             wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to get the list of resources from the voiceemail_LOGS server");
             return false;
         } else {
             $ressources = $vtResources->getResources();
         }
     } else {
         wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to get the list of resources from the databse");
         return false;
     }
     for ($i = 0; $i < count($ressources); $i++) {
         $resource = $vtResources->getResource($i);
         $grade = -1;
         $rid = $resource->getRid();
         if ($list["info"][$rid]->gradeid != -1) {
             $grade = $list["info"][$rid]->gradeid;
         }
         if ($list["info"][$rid]->availability == "0") {
             $preview = false;
         } elseif ($list["info"][$rid]->start_date == -1 && $list["info"][$rid]->end_date == -1) {
             $preview = true;
         } elseif ($list["info"][$rid]->start_date == -1 && time() <= $list["info"][$rid]->end_date) {
             $preview = true;
         } elseif ($list["info"][$rid]->start_date < time() && $list["info"][$rid]->end_date == -1) {
             $preview = true;
         } elseif ($list["info"][$rid]->start_date < time() && time() < $list["info"][$rid]->end_date) {
             $preview = true;
         } else {
             $preview = false;
         }
         $xmlResource = new XmlResource($rid, $resource->getTitle(), $preview, "manageAction.php", $this->session->url_params . "&time=" . time() . "&action=launch", $grade);
         $xmlResource->setTooltipAvailability(get_string("tooltipVT_" . $preview . "_student", 'voiceemail'));
         if ($this->session->isInstructor() || !$this->session->isInstructor() && $preview) {
             $xmlResource->setType($resource->getType());
             $resources[$resource->getTitle() . $resource->getRid()] = $xmlResource;
         }
     }
     return $resources;
 }
         $messageProduct = "presentation";
     } elseif ($params['type'] == "pc") {
         $result = $vtAction->modifyPodcaster($params["resource_id"]);
         $messageAction = "updated";
         $messageProduct = "pc";
     }
     if ($result != NULL) {
         //create the object to store in the db
         $resource_id = updateResource($result->getRid(), $session->getCourseId(), $params);
         if (empty($resource_id)) {
             error_log(__FUNCTION__ . " : Problem to update the resource on the database", TRUE);
             redirection($redirectionUrl . '&error=problem_bd');
         }
         $messageType = $params['type'] . 'Updated';
     } else {
         wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "manageAction : Problem to add the resource into the database");
         redirection($redirectionUrl . '&error=problem_vt');
     }
 } elseif ($params['action'] == 'delete') {
     /* Bug 28439 - We need to check if the resource has a grade book associated with it
        before we try and delete it */
     $resourceDb = get_record("voicepresentation_resources", "rid", $params["resource_id"]);
     if ($resourceDb->gradeid != -1) {
         voicepresentation_delete_grade_column($params["resource_id"], $params["enc_course_id"]);
     }
     $result = $vtAction->deleteResource($params["resource_id"]);
     if ($result != NULL) {
         //if no error during the creation
         if (!voicepresentation_delete_all_instance_of_resource($params["resource_id"])) {
             notify("Could not delete the activities for the voicetools:" . $params["resource_id"]);
         }
Exemple #11
0
function liveclassroom_delete_all_instance_of_room($roomid)
{
    global $CFG;
    // / Given an ID of an instance of this module,
    // / this function will permanently delete the instance
    // / and any data that depends on it.
    $api = new LCApi($CFG->liveclassroom_servername, $CFG->liveclassroom_adminusername, $CFG->liveclassroom_adminpassword);
    $result = true;
    if ($liveclassrooms = get_records("liveclassroom", "type", $roomid)) {
        $roomname = $api->lcapi_get_room_name($liveclassroom->type);
        // Delete any dependent records here #
        foreach ($liveclassrooms as $liveclassroom) {
            // get the course_module instance linked to the liveclassroom instance
            if (!($cm = get_coursemodule_from_instance("liveclassroom", $liveclassroom->id, $liveclassroom->course))) {
                error("Course Module ID was incorrect");
            }
            if (!delete_course_module($cm->id)) {
                wimba_add_log(WIMBA_ERROR, WC, "Problem to delete the course module : " . $cm->id);
                $result = false;
                // Delete a course module and any associated data at the course level (events)
                // notify("Could not delete the $cm->id (coursemodule)");
            }
            if (!delete_records("liveclassroom", "id", "{$liveclassroom->id}")) {
                wimba_add_log(WIMBA_ERROR, WC, "Problem to delete all the activities associated to the voice tools");
                $result = false;
            }
            // delete in the course section too
            if (!delete_mod_from_section($cm->id, "{$cm->section}")) {
                wimba_add_log(WIMBA_ERROR, WC, "Could not delete the " . $cm->id . " from that section : " . $cm->section);
                $result = false;
                // notify("Could not delete the $mod->modulename from that section");
            }
        }
    }
    return $result;
}
       GET URL INFORMATIONS
       ********************/
    $action = optional_param('action', "");
    // Course Module ID, or
    $typeProduct = $params['type'];
    if ($action == 'update') {
        //get the information of the resource
        $currentBoard = voicetools_api_get_resource($params["resource_id"]);
        if (!isset($currentBoard) || $currentBoard->error == true) {
            wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "getXmlNewPanel : " . get_string('problem_vt', 'voicepresentation'));
            $uiManager->setError(get_string('problem_vt', 'voicepresentation'));
        } else {
            $currentBoardInformations = voicepresentation_get_wimbaVoice_Informations($params["resource_id"]);
            $uiManager->setCurrentProduct($typeProduct, $currentBoard, $currentBoardInformations);
        }
    } else {
        $uiManager->setCurrentProduct($typeProduct);
    }
    $display = $uiManager->getVTSettingsView($action, $createWorkflow);
} else {
    wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "getXmlNewPanel : " . get_string('error_session', 'voicepresentation'));
    $uiManager->setError(get_string('error_session', 'voicepresentation'));
}
wimba_add_log(WIMBA_DEBUG, voicepresentation_LOGS, "getXmlListPanel : parameters  \n" . $uiManager->getXmlString());
if (isset($error_wimba)) {
    $uiManager->setError(get_string('error_display', 'voicepresentation'));
}
echo $uiManager->getXmlString();
?>

Exemple #13
0
function voiceemail_deleteCalendarEvent($instanceNumber)
{
    /// Basic event record for the database.
    global $CFG;
    if (!($event = get_record('event', 'instance', $instanceNumber, 'modulename', 'voiceemail'))) {
        wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to delete calendar event : " . $instanceNumber);
        return false;
    }
    $result = delete_records("event", "id", $event->id);
}
foreach (getKeysOfGeneralParameters() as $param) {
    $value = optional_param($param["value"], $param["default_value"], $param["type"]);
    if ($value != null) {
        $params[$param["value"]] = $value;
    }
}
require_login($params["enc_course_id"]);
$uiManager = new WimbaUI($params);
wimba_add_log(WIMBA_DEBUG, voicepodcaster_LOGS, "getXmlListPanel : parameters  \n" . print_r($params, true));
if (isset($params["error"])) {
    wimba_add_log(WIMBA_ERROR, voicepodcaster_LOGS, "getXmlListPanel : " . get_string($params["error"], 'voicepodcaster'));
    $uiManager->setError(get_string($params["error"], 'voicepodcaster'));
} else {
    //Session Management
    if ($uiManager->getSessionError() === false) {
        $message = "";
        if (!empty($messageProduct) && !empty($messageAction)) {
            $message = get_string("message_" . $messageProduct . "_start", "voicepodcaster") . "  " . get_string("message_" . $messageAction . "_end", "voicepodcaster");
        }
        $uiManager->getVTPrincipalView($message, "pc");
    } else {
        //bad session
        wimba_add_log(WIMBA_ERROR, voicepodcaster_LOGS, "getXmlListPanel : " . get_string('error_session', 'voicepodcaster'));
        $uiManager->setError(get_string('error_session', 'voicepodcaster'));
    }
}
wimba_add_log(WIMBA_DEBUG, voicepodcaster_LOGS, "getXmlListPanel : xml generated \n" . $uiManager->getXmlString());
if (isset($error_wimba)) {
    $uiManager->setError(get_string('error_display', 'voicepodcaster'));
}
echo $uiManager->getXmlString();