this is the code
and jpgraph lines are highlighted ,
others are my code lines so just check those lines
[B][I][U]//This is the important line and this file is in examples pf jpgraph
include “pie_csimex1.php”;
//My moodle output should between echo $OUTPUT->header(); and echo $OUTPUT->footer();[/U][/I][/B]
<?php
global $DB, $PAGE, $OUTPUT ,$COURSE,$USER;
require_once("../../config.php");
// Input params
$courseid = optional_param('id',1, PARAM_INT);
// Require course login
$course = $DB->get_record("course", array("id" => $courseid), '*', MUST_EXIST);
require_login();
require_once('dedication_lib.php');
// Optional params from request or default values
$download = optional_param('download', false, PARAM_BOOL);
//getting course from the system
//$sql="select c.fullname from {course} c";
//$courses=$DB->get_recordset_sql($sql);
$courses = $DB->get_fieldset_select('course', 'fullname', 'id != 1');
//converting it to array
$page_url = new moodle_url('/report/formcheck/index.php');
$page_url->params(array(
'courseid' => $course->id,
'action' => $action,
));
// Page format
$PAGE->set_pagelayout('report');
$PAGE->set_pagetype('course-view-' . $course->format);
//$PAGE->navbar->add(get_string('pluginname', 'report_dedication'), new moodle_url('/report/formcheck/index.php', array('courseid' => $courseid)));
$PAGE->set_url($page_url);
$PAGE->set_title(get_string('pagetitle', 'report_dedication', $course->shortname));
$PAGE->set_heading($course->fullname);
// Load libraries
require_once('dedication_form.php');
$data=array('courses'=>$courses);
// Load calculate params from form, request or set default values
$mform = new dedication_block_selection_form(null, $data);
// $mform->disable_form_change_checker();
if ($mform->is_submitted()) {
// Params from form post
$formdata = $mform->get_data();
$mintime = $formdata->mintime;
$maxtime = $formdata->maxtime;
$limit = $formdata->limit;
$wcourse=$formdata->courses;
// Url with params for links inside tables
//getting course object for submitted course
$course=$courses[$wcourse];
$course = $DB->get_record("course", array("fullname" => $course), '*', MUST_EXIST);
$page_url= new moodle_url("/report/dedication/user.php");
$page_url->params(array(
'mintime' => $mintime,
'maxtime' => $maxtime,
'limit' => $limit,
'courseid'=> $course->id
));
// Object to store view data
$view = new stdClass();
$view->header = array();
$table_styles = report_dedication_manager::get_table_styles();
$view->table = new html_table();
$view->table->attributes = array('class' => $table_styles['table_class'] . " table-$action");
switch ($action) {
case 'user':
$userid = required_param('id', PARAM_INT);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
if (!is_enrolled(context_course::instance($course->id), $user)) {
print_error('usernotincourse');
}
$dm = new report_dedication_manager($course, $mintime, $maxtime, $limit);
$rows = $dm->get_user_dedication($user);
if ($download) {
$dm->download_user_dedication($user, $rows);
}
// Table formatting & total count
$total_dedication = 0;
foreach ($rows as $index => $row) {
$total_dedication += $row->dedicationtime;
$rows[$index] = array(
userdate($row->start_date),
report_dedication_manager::format_dedication($row->dedicationtime),
report_dedication_manager::format_ips($row->ips),
);
}
$view->header[] = get_string('userdedication', 'report_dedication', $OUTPUT->user_picture($user, array('courseid' => $course->id)) . fullname($user));
$view->header[] = get_string('period', 'report_dedication', (object) array('mintime' => userdate($mintime), 'maxtime' => userdate($maxtime)));
$view->header[] = get_string('perioddiff', 'report_dedication', format_time($maxtime - $mintime));
$view->header[] = get_string('totaldedication', 'report_dedication', report_dedication_manager::format_dedication($total_dedication));
$view->header[] = get_string('meandedication', 'report_dedication', report_dedication_manager::format_dedication($total_dedication / count($rows)));
$view->table->head = array(get_string('sessionstart', 'report_dedication'), get_string('sessionduration', 'report_dedication'), 'IP');
$view->table->data = $rows;
break;
case 'group':
case 'all':
default:
// Get all students in this course or ordered by group
if ($course->groupmode == NOGROUPS) {
$students = get_enrolled_users(context_course::instance($course->id));
} else {
$students = array();
foreach ($groups as $group) {
$members = groups_get_members($group->id);
$students = array_merge($students, $members);
}
}
if (!$students) {
print_error('noparticipants');
}
$dm = new report_dedication_manager($course, $mintime, $maxtime, $limit);
$rows = $dm->get_students_dedication($students);
if ($download) {
$dm->download_students_dedication($rows);
}
// Table formatting & total count
$total_dedication = 0;
$myrow=array();
foreach ($rows as $index => $row) {
if($row->dedicationtime == 0)continue;
$total_dedication += $row->dedicationtime;
$user_url = new moodle_url($page_url, array('action' => 'user', 'id' => $row->user->id));
$group_url = new moodle_url($page_url, array('action' => 'group', 'id' => $row->groupid));
$myrow[$index] = array(
$OUTPUT->user_picture($row->user, array('courseid' => $course->id)),
html_writer::link($user_url, $row->user->firstname),
html_writer::link($user_url, $row->user->lastname),
html_writer::link($group_url, isset($groups[$row->groupid]) ? $groups[$row->groupid]->name : ''),
report_dedication_manager::format_dedication($row->dedicationtime),
$row->connectionratio
);
}
if ($action == 'group') {
$view->header[] = get_string('dedicationgroup', 'report_dedication', $groups[$groupid]->name);
} else {
$view->header[] = get_string('dedicationall', 'report_dedication');
}
$view->header[] = get_string('period', 'report_dedication', (object) array('mintime' => userdate($mintime), 'maxtime' => userdate($maxtime)));
$view->header[] = get_string('perioddiff', 'report_dedication', format_time($maxtime - $mintime));
$view->header[] = get_string('totaldedication', 'report_dedication', report_dedication_manager::format_dedication($total_dedication));
$view->header[] = get_string('meandedication', 'report_dedication', report_dedication_manager::format_dedication($total_dedication / count($rows)));
$view->table->head = array('', get_string('firstname'), get_string('lastname'), get_string('group'), get_string('dedicationrow', 'report_dedication'), get_string('connectionratiorow', 'report_dedication'));
$view->table->data = $myrow;
break;
}
// START PAGE: layout, headers, title, boxes...
echo $OUTPUT->header();
// Form
$mform->display();
// $mform->addElement('select', 'courses', get_string('courses'));
echo $OUTPUT->box_start();
foreach ($view->header as $header) {
echo $OUTPUT->heading($header, 4);
}
// Format table headers if they exists
echo html_writer::tag('hr', null);
/*
if (!empty($view->table->head)) {
$headers = array();
foreach ($view->table->head as $header) {
$cell = new html_table_cell($header);
$cell->style = $table_styles['header_style'];
$headers[] = $cell;
}
$view->table->head = $headers;
}
*/
echo html_writer::table($view->table);
echo $OUTPUT->box_end();
/*
$table = new flexible_table('admin-blocks-compatible');
$table->define_columns(array('name', 'instances' ));
$table->define_headers(array($strname, $strcourses ));
// $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
// $table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
$table->setup();
$tablerows = array();
$t->finish_output();
$t->print_html();
*/
[B][I][U]//This is the important line and this file is in examples pf jpgraph
include "pie_csimex1.php";
//My moodle output should between echo $OUTPUT->header(); and echo $OUTPUT->footer();[/U][/I][/B]
echo $OUTPUT->footer();
}
else{
echo $OUTPUT->header();
// Form
$mform->display();
echo $OUTPUT->footer();
}