コード例 #1
0
$PAGE->navbar->add(fullname($plpuser), $userprofileurl, 'title');
//section name
$PAGE->navbar->add(get_string('dashboard', 'block_ilp'), null, 'title');
// setup the page title and heading
$SITE = $dbc->get_course_by_id(SITEID);
$PAGE->set_title($SITE->fullname . " : " . get_string('blockname', 'block_ilp') . " : " . fullname($plpuser));
$PAGE->set_heading($SITE->fullname);
$PAGE->set_pagetype('ilp-dashboard');
$PAGE->set_pagelayout('ilp');
$PAGE->set_url($CFG->wwwroot . "/blocks/ilp/actions/view_main.php", $PARSER->get_params());
//get the enabled template
$temp = $dbc->get_enabled_template();
$classname = $temp->name;
//include the class file for the enabled template
require_once $CFG->dirroot . "/blocks/ilp/classes/dashboard/templates/{$classname}.php";
$template = new $classname();
//check if the student has a user status record if not create one
if (!$dbc->get_user_status($user_id)) {
    //the user can not change there own status so we must set the modifying user to
    //the default user
    $user_modified_id = $user_id != $USER->id ? $USER->id : ILP_DEFAULT_USER_ID;
    $studentstatus = new stdClass();
    $studentstatus->user_id = $user_id;
    $studentstatus->user_modified_id = $user_modified_id;
    $defaultconfiguserstatus = get_config('block_ilp', 'defaultstatusitem');
    $studentstatus->parent_id = !empty($defaultconfiguserstatus) ? $defaultconfiguserstatus : ILP_DEFAULT_USERSTATUS_RECORD;
    //ILP_DEFAULT_USERSTATUS_RECORD;
    $dbc->create_userstatus($studentstatus);
}
//require the view_main.html file
require_once $CFG->dirroot . "/blocks/ilp/views/view_main.html";
コード例 #2
0
//get the selectedtab param if it exists
$tabitem = $PARSER->optional_param('tabitem', NULL, PARAM_RAW);
//get the changed status
$ajax = $PARSER->required_param('ajax', PARAM_RAW);
//get the changed status
$status_id = $PARSER->required_param('select_userstatus', PARAM_RAW);
// instantiate the db
$dbc = new ilp_db();
//retreive the user record from the database
$student = $dbc->get_user_by_id($student_id);
if (empty($student)) {
    //trigger error
}
//
$stausitem = $dbc->get_status_item_by_id($status_id);
$userstatus = $dbc->get_user_status($student_id);
$userstatus->user_modified_id = $USER->id;
$userstatus->parent_id = $status_id;
if ($dbc->update_userstatus($userstatus)) {
    if ($ajax == 'false') {
        $return_url = $CFG->wwwroot . '/blocks/ilp/actions/view_main.php?user_id=' . $student_id . '&course_id=' . $course_id . '&tabitem=' . $tabitem . '&selectedtab=' . $selecttedtab;
        redirect($return_url, get_string("stausupdated", 'block_ilp'), ILP_REDIRECT_DELAY);
    } else {
        $userstatuscolor = get_config('block_ilp', 'passcolour');
        if (!empty($statusitem)) {
            if ($statusitem->passfail == 1) {
                $userstatuscolor = get_config('block_ilp', 'failcolour');
            }
        }
        //echo "['{$stausitem->name}','{$userstatuscolor}']";
        echo $stausitem->name;