3.12-chizma. IntelliBoard plaginning shablon ko’rinishi.
Bilamizki har bir veb dasturning asosiy fayli bu “index” deb nomlanadi, xuddi shunday bizning dasturiy komponentamiz ham asosiy “index.php” fayli hisoblanadi va uning php kod qismi quyida keltirilgan:
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot .'/local/intelliboard/externallib.php');
require_once($CFG->dirroot .'/local/intelliboard/locallib.php');
require_login();
require_capability('local/intelliboard:view', context_system::instance());
admin_externalpage_setup('intelliboardcontrolpanel');
$action = optional_param('action', '', PARAM_RAW);
$url = optional_param('url', '', PARAM_URL);
$time = optional_param('time', 'monthly', PARAM_RAW);
$filter = optional_param('filter', 0, PARAM_INT);
if($url){
redirect("$url&confirm=".get_config('local_intelliboard', 'te1'));
return;
}
$params = array(
'reports'=>get_config('local_intelliboard', 'reports'),
'filter'=>$filter
);
if($action == 'enable_report_time'){
set_config("report_time", 0, "local_intelliboard");
}
if($action == 'disable_report_time'){
set_config("report_time", 1, "local_intelliboard");
}
$report_time = get_config('local_intelliboard', 'report_time');
$sizemode = get_config('local_intelliboard', 'sizemode');
if($action == 'noalert'){
$USER->noalert = true;
}elseif($action == 'signup' or $action == 'setup'){
$webservice = $DB->get_record_sql("SELECT token FROM {external_services} exs, {external_tokens} ext WHERE exs.component='local_intelliboard' AND ext.externalserviceid = exs.id");
$params['token'] = (isset($webservice->token)) ? $webservice->token : 'none';
$params['site'] = format_string($SITE->fullname);
$params['do'] = $action;
$params['agreement'] = true;
}
$intelliboard = intelliboard($params);
$params = (object) array(
'filter_user_deleted'=>get_config('local_intelliboard', 'filter1'),
'filter_user_suspended'=>get_config('local_intelliboard', 'filter2'),
'filter_user_guest'=>get_config('local_intelliboard', 'filter3'),
'filter_course_visible'=>get_config('local_intelliboard', 'filter4'),
'filter_enrolmethod_status'=>get_config('local_intelliboard', 'filter5'),
'filter_enrol_status'=>get_config('local_intelliboard', 'filter6'),
'filter_enrolled_users'=>get_config('local_intelliboard', 'filter8'),
'filter_module_visible'=>get_config('local_intelliboard', 'filter7'),
'filter_columns'=>get_config('local_intelliboard', 'filter9'),
'teacher_roles'=>get_config('local_intelliboard', 'filter10'),
'learner_roles'=>get_config('local_intelliboard', 'filter11'),
'filter_profile'=>0,
'sizemode'=>$sizemode,
'start'=>0,
'userid'=>0,
'length'=>10,
'courseid'=>0,
'filter'=>'',
'custom'=> s($time),
'custom2'=> '',
'custom3'=> '',
'timestart'=>strtotime('-6 month'),
'timefinish'=>time()
);
$plugin = new local_intelliboard_external();
if($action == 'report43'){
if(!$sizemode){
$avg = $plugin->get_dashboard_avg($params);
}else{
$avg = null;
}
$params->timestart = 0;
$params->sizemode = $report_time;
$report43 = $plugin->report43($params);
include("views/report43.php");
exit;
}elseif($action == 'report44'){
$params->timestart = 0;
$report44 = $plugin->report44($params);
include("views/report44.php");
exit;
}
$stat = $plugin->get_dashboard_stats($params);
$LineChart = $plugin->get_dashboard_info($params);
$countries = $plugin->get_dashboard_countries($params);
$enrols = $plugin->get_dashboard_enrols($params);
$params->sizemode = 1;
$totals = $plugin->get_total_info($params);
$json_countries = array();
foreach($countries as $country){
$json_countries[] = "['".format_string(ucfirst($country->country))."', ".s($country->users)."]";
}
$json_enrols = array();
foreach($enrols as $enrol){
$json_enrols[] = "['".format_string(ucfirst($enrol->enrol))."', ".s($enrol->enrols)."]";
}
$json_data = array();
foreach($LineChart[2] as $item){
$d = date("j", $item->timepointval);
$m = date("n", $item->timepointval) - 1;
$y = date("Y", $item->timepointval);
$l = $item->visits;
$v = (isset($LineChart[3][$item->timepointval])) ? $LineChart[3][$item->timepointval]->users : 0;
$t = (isset($LineChart[4][$item->timepointval])) ? $LineChart[4][$item->timepointval]->users : 0;
$json_data[] = "[new Date($y, $m, $d), $l, $t, $v]";
}
$PAGE->requires->jquery();
$PAGE->set_url(new moodle_url("/local/intelliboard/index.php", array()));
$PAGE->set_pagetype('home');
$PAGE->set_pagelayout('report');
$PAGE->set_context(context_system::instance());
$PAGE->set_title(get_string('intelliboardroot', 'local_intelliboard'));
$PAGE->set_heading(get_string('intelliboardroot', 'local_intelliboard'));
$PAGE->requires->css('/local/intelliboard/assets/css/style.css');
echo $OUTPUT->header();
?>
sessions_today);?>
sessions_week);?>
echo get_string('course_completions', 'local_intelliboard');?>
compl_today);?>
compl_week);?>
echo get_string('user_enrolments', 'local_intelliboard');?>
enrolments_today);?>
enrolments_week);?>
users); ?>
courses); ?>
modules); ?>
categories); ?>
wwwroot; ?>/local/intelliboard/index.php?action=" title="">
src="https://www.google.com/jsapi?autoload={
'modules':[{
'name':'visualization',
'version':'1',
'packages':['corechart','geochart']
}]
}">
echo $OUTPUT->footer();
Yuqoridagi php kodimizning natijasi quyida 3.13-chizmada yaqqolroq ko’rsatilgan.
Do'stlaringiz bilan baham: |