Example #1
0
$folder_exists = $DB->get_record('wiziq_content', array('id' => $folderid), '*', MUST_EXIST);
require_course_login($course);

$coursecontext = context_course::instance($course->id);
$noerror = get_string('noerror','wiziq');
$paramslog = array(
    'objectid' => $folderid,
    'relateduserid' => $USER->id,
    'courseid' => $id,
    'context' => $coursecontext,
    'other' => array(
        'sesskey' => sesskey(),
        'error' => $noerror
    )
);
$event = \mod_wiziq\event\wiziq_content::create($paramslog);
$event->trigger();

$url = new moodle_url('/mod/wiziq/content.php', array('id'=>$id, 'sesskey' => sesskey()));
$PAGE->set_url($url);
$pagetitle = new stdClass();
$pagetitle->name = get_string('manage_content', 'wiziq');
$PAGE->set_title(format_string($pagetitle->name));
$PAGE->set_heading(format_string(get_string('wiziq_content', 'wiziq')));
$PAGE->set_context($coursecontext);
$PAGE->set_pagelayout('incourse');
#---------------------- table setup here--------------------------
$refresh_txt = get_string('refresh_page', 'wiziq');
$table = new flexible_table('wixiq_content');
$table->define_columns(array('name', 'status', 'delete'));
$statusicon = '<img src="'.$CFG->wwwroot.'/mod/wiziq/pix/refresh.png" alt='.$refresh_txt.'/>';
Example #2
0
/**
 * Get the old_content_id array of content and fetch new content id .
 *
 * @param integer $courseid the course id in which the class is scheduled.
 * @param array $clist_array the old_content_id of old content uploaded by soap api.
 */
function wiziq_get_contentid_update($courseid, $clist_array) {
    global $CFG, $USER, $DB, $wiziq_secretacesskey, $wiziq_access_key, $wiziq_content_webservice;
    require_once("authbase.php");
    $wiziq_access_key= $CFG->wiziq_access_key;
    $wiziq_secretacesskey = $CFG->wiziq_secretacesskey;
    $wiziq_content_webservice = $CFG->wiziq_content_webservice;
    $context = context_course::instance($courseid);
    require_once("authbase.php");
    $wiziq_authbase = new wiziq_authbase($wiziq_secretacesskey, $wiziq_access_key);
    $method = "listContentIds";
    $requestparameters["signature"] = $wiziq_authbase->wiziq_generatesignature($method,
                                                                               $requestparameters);
    $clist_list = implode(',', $clist_array);
    $requestparameters["page_size"] = WIZIQ_DEFAULT_PAGESIZE;
    $requestparameters["multiple_content_id"] = $clist_list;
    $wiziq_httprequest=new wiziq_httprequest();
    try {
        $xmlreturn=$wiziq_httprequest->wiziq_do_post_request(
                                                $wiziq_content_webservice.'?method=listContentIds',
                                                $requestparameters);
        libxml_use_internal_errors(true);
        $xmldata = new SimpleXmlElement($xmlreturn, LIBXML_NOCDATA);
        $attribnode = (string)$xmldata->attributes();
        if ($attribnode=="ok") {
            $get_data = $xmldata->listContentIds->record_list;
            foreach ($get_data->record as $record) {
                $content_id = (string)$record->content_id;
                $wzq_content_id = (string)$record->wzq_content_id;
                $content_ids[$content_id] = $wzq_content_id;
            }
            foreach ($clist_array as $key => $value) {
                /*
                 * we use isset for performance knowing the the
                 * value for particular key will never be null
                 */
                if (isset($content_ids[$value])) {
                    $updates = new stdClass(); //just enough data for updating the submission
                    $updates->id = $key;
                    $updates->contentid = $content_ids[$value];
                    $updates->cid_change_status = '1';
                    $DB->update_record('wiziq_content', $updates);
                }
            }
        } else if ($attribnode=="fail") {
            $att = 'msg';
            $code = 'code';
            $error_code = (string)$xmldata->error->attributes()->$code;
            $error_msg = (string)$xmldata->error->attributes()->$att;
            $paramslog = array(
                    'objectid' => $courseid,
                    'relateduserid' => $USER->id,
                    'courseid' => $courseid,
                    'context' => $context,
                    'other' => array(
                        'sesskey' => sesskey(),
                        'error' => $errormsg
                    )
            );
            $event = \mod_wiziq\event\wiziq_content::create($paramslog);
            $event->trigger();
            $error = $error_code." ".$error_msg;
            print_error('1', '', '', $error);

        }
    } catch (Exception $e) {
        if (property_exists($e, 'errorcode')) {
            notify($e->a);
        } else {
            $errormsg = get_string('errorinservice', 'wiziq');
            notify($e->getMessage().'<br />'.$errormsg);
        }
    }
}