コード例 #1
0
/**
 * Carries out functions needed after installation
 *
 * @copyright © 2011 University of London Computer Centre
 * @author http://www.ulcc.ac.uk, http://moodle.ulcc.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ILP
 * @version 2.0
 */
function xmldb_block_ilp_install()
{
    global $USER, $CFG, $SESSION, $PARSER;
    // include the ilp db
    require_once $CFG->dirroot . '/blocks/ilp/db/ilp_db.php';
    // instantiate the db
    $dbc = new ilp_db();
    //install the various plugins and templates into the database
    require_once $CFG->dirroot . '/blocks/ilp/classes/form_elements/ilp_element_plugin.php';
    //install new plugins
    ilp_element_plugin::install_new_plugins();
    require_once $CFG->dirroot . '/blocks/ilp/classes/dashboard/ilp_dashboard_template.php';
    //install new templates
    ilp_dashboard_template::install_new_plugins();
    require_once $CFG->dirroot . '/blocks/ilp/classes/dashboard/ilp_dashboard_plugin.php';
    //install new dashboard plugins
    ilp_dashboard_plugin::install_new_plugins();
    require_once $CFG->dirroot . '/blocks/ilp/classes/dashboard/ilp_dashboard_tab.php';
    //install new tabs
    ilp_dashboard_tab::install_new_plugins();
    //create relationships betweendashboard plugins and template regions
    //get the enabled template should be the default temmplate at this stage
    $enabled_template = $dbc->get_enabled_template();
    $regions = $dbc->get_template_regions($enabled_template->id);
    $region_plugins = array();
    //create the association between the plugin and the first region
    $plugin = $dbc->get_dashboard_plugin_by_name('ilp_dashboard_student_info_plugin');
    $rp = new stdClass();
    $rp->plugin_id = $plugin->id;
    $region_plugins[] = $rp;
    $plugin = $dbc->get_dashboard_plugin_by_name('ilp_dashboard_main_plugin');
    $rp = new stdClass();
    $rp->plugin_id = $plugin->id;
    $region_plugins[] = $rp;
    //loop through the regions and assign the region to a plugin
    $i = 0;
    foreach ($regions as $r) {
        $region_plugins[$i]->region_id = $r->id;
        //create the record
        $dbc->create_region_plugin($region_plugins[$i]);
        $i++;
    }
    //create default user status record and subsequent items
    $statusitem = new stdClass();
    $statusitem->selecttype = NULL;
    $id = $dbc->create_plugin_record('block_ilp_plu_sts', $statusitem);
    $statusitems = array('red' => '1', 'orange' => '0', 'green' => '2');
    foreach ($statusitems as $key => $passfail) {
        $si = new stdClass();
        $si->name = $key;
        $si->value = $key;
        $si->passfail = $passfail;
        $si->parent_id = $id;
        $dbc->create_plugin_record('block_ilp_plu_sts_items', $si);
    }
}
コード例 #2
0
    $PAGE->navbar->add(get_string('myilp', 'block_ilp'), $dashboardurl, 'title');
}
// setup the navigation breadcrumbs
//user intials
$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;