Ejemplo n.º 1
0
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param object $scormcloud An object from the form in mod_form.php
 * @return boolean Success/Fail
 */
function scormcloud_update_instance($scormcloud, $mform = null)
{
    global $DB;
    $scormcloud = $DB->get_record('scormcloud', array('id' => $scormcloud->instance));
    $scormcloud->timemodified = time();
    if ($mform) {
        $packagefile = $mform->save_temp_file('packagefile');
        if ($packagefile !== false) {
            require_once 'locallib.php';
            $cloud = scormcloud_get_service();
            $course_service = $cloud->getCourseService();
            // PHP lib is somewhat out-of-sync with Cloud API. versionCourse no longer exists,
            // use ImportCourse instead which auto-versions.
            $results = $course_service->ImportCourse($scormcloud->cloudid, $packagefile);
            unlink($packagefile);
            $result = current($results);
            if (!$result->getWasSuccessful()) {
                print_error('importerror', 'scormcloud', $result->getMessage());
            }
            $scormcloud->name = $result->getTitle();
        }
    }
    return $DB->update_record('scormcloud', $scormcloud);
}
Ejemplo n.º 2
0
function scormcloud_course_exists_on_cloud($cloudid)
{
    global $CFG, $log;
    $log->logInfo('URL: ' . $CFG->scormcloud_serviceurl . ', AppID: ' . $CFG->scormcloud_appid . ', Key: ' . $CFG->scormcloud_secretkey);
    $scormservice = scormcloud_get_service();
    $courseservice = $scormservice->getCourseService();
    $allresults = $courseservice->GetCourseList($cloudid);
    $courseexists = false;
    foreach ($allresults as $cloudcourse) {
        if ($cloudcourse->getCourseId() == $cloudid) {
            $courseexists = true;
            break;
        }
    }
    return $courseexists;
}
Ejemplo n.º 3
0
 *   http://scorm.com/moodle/
 *
 *   The SCORM Cloud Module is free software: you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License as published
 *   by the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   The SCORM Cloud Module is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with the SCORM Cloud Module.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "../../config.php";
require_once 'SCORMCloud_PHPLibrary/ScormEngineService.php';
require_once 'SCORMCloud_PHPLibrary/ServiceRequest.php';
require_once 'SCORMCloud_PHPLibrary/CourseData.php';
require_once $CFG->dirroot . '/mod/scormcloud/lib.php';
require_once $CFG->dirroot . '/mod/scormcloud/locallib.php';
$id = required_param('id', PARAM_INT);
$scormcloud = $DB->get_record('scormcloud', array('id' => $id));
require_login($scormcloud->course);
if (!scormcloud_hascapabilitytolaunch($scormcloud->course)) {
    error("You do not have permission to launch this course.");
}
$scormservice = scormcloud_get_service();
$courseservice = $scormservice->getCourseService();
$cssurl = $CFG->wwwroot . '/mod/scormcloud/packageprops.css';
echo '<script language="javascript">window.location.href = "' . $courseservice->GetPropertyEditorUrl($scormcloud->cloudid, $cssurl, null) . '";</script>';
Ejemplo n.º 4
0
require_once 'SCORMCloud_PHPLibrary/ServiceRequest.php';
require_once 'SCORMCloud_PHPLibrary/CourseData.php';
global $CFG;
global $DB;
$id = required_param('courseid', PARAM_INT);
// This is not the Moodle courseid it's the scormcloud->id.
$mode = optional_param('mode', 'launch', PARAM_ALPHA);
$userid = $USER->id;
$regid = '';
$scormcloud = $DB->get_record('scormcloud', array('id' => $id));
require_login($scormcloud->course);
if (!scormcloud_hascapabilitytolaunch($scormcloud->course)) {
    error("You do not have permission to launch this course.");
}
$PAGE->requires->js('/mod/scormcloud/request.js', true);
$ScormService = scormcloud_get_service();
$regService = $ScormService->getRegistrationService();
$log->logDebug('Checking for Moodle registration.');
// Check to see if there is an initial registration
if (!($regs = $DB->get_records_select('scormcloud_registrations', 'userid=' . $userid . ' AND scormcloudid=' . $id))) {
    $log->logInfo("Registration does not exist in Moodle for course {$scormcloud->course} and scormcloudcourse {$id} and user {$userid}; creating.");
    $regid = md5(uniqid());
    $reg = array();
    $reg['scormcloudid'] = $id;
    $reg['userid'] = $userid;
    $reg['regid'] = $regid;
    $reg['lastaccess'] = time();
    $DB->insert_record('scormcloud_registrations', $reg, $returnid = true, $primarykey = 'id');
    $log->logInfo("Moodle registration {$regid} created.");
    $user = scormcloud_get_user_data($userid);
    $learnerId = $user->username;