function xmldb_block_reportdashboard_install() { global $DB; $page = new moodle_page(); $page->blocks->add_blocks(array('side-db-one' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, -1); $page->blocks->add_blocks(array('side-db-two' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, 0); $page->blocks->add_blocks(array('side-db-three' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, 1); $reportblocks =$DB->get_records_sql('select id from {block_instances} where blockname="reportdashboard" order by id desc limit 3'); foreach($reportblocks as $reportblock){ $blockinstance[]=$reportblock->id; } $reportslist = $DB->get_records_sql('select id from {block_cobalt_reports} order by id asc limit 3'); $i=0; foreach($reportslist as $reports){ $reportclass = create_reportclass($reports->id); $components = cr_unserialize($reportclass->config->components); $data = new stdClass; $data->title = $DB->get_field('block_cobalt_reports','name',array('id'=>$reports->id)); $data->reportlist = $reports->id; $data->reportcontenttype = $components['plot']['elements'][$i]['id']; $DB->set_field('block_instances', 'configdata', base64_encode(serialize($data)), array('id' => $blockinstance[$i])); $i++; } }
function get_content() { global $CFG, $DB, $PAGE; require_once($CFG->libdir . '/filelib.php'); require_once($CFG->dirroot . '/blocks/cobalt_reports/report.class.php'); require_once($CFG->dirroot . '/blocks/cobalt_reports/locallib.php'); if ($this->content !== NULL) { return $this->content; } $filteropt = new stdClass; $filteropt->overflowdiv = true; if ($this->content_is_trusted()) { // fancy reportdashboard allowed only on course, category and system blocks. $filteropt->noclean = true; } $this->content = new stdClass; $this->content->footer = ''; $this->content->text = ""; if (isset($this->config->reportlist)) { $reportid = $this->config->reportlist; $reportclass = create_reportclass($reportid); $components = cr_unserialize($reportclass->config->components); $reportcontenttypes = cr_listof_reporttypes($this->config->reportlist); $blockinstanceid = $this->instance->id; $this->content->text .= html_writer::select($reportcontenttypes, 'report', $this->config->reportcontenttype, false, array('id' => 'reporttype_' . $this->instance->id . '', 'onchange' => "generate_report(\"reporttype_\",$reportid,\"reportcontainer\",$blockinstanceid,\"$CFG->wwwroot\")")); $this->content->text .= html_writer::start_tag('div', array('id' => 'reportcontainer' . $this->instance->id . '')); $report = cr_get_reportinstance($this->config->reportlist); if (isset($report) && !$report->global) { $this->content->text .= ''; } elseif (isset($this->config->reportlist)) { $renderer = $this->page->get_renderer('block_reportdashboard'); $this->content->text .= $renderer->generate_dashboardreport($reportclass, $this->config->reportcontenttype, $blockinstanceid); } $this->content->text .=html_writer::end_tag('div'); $link_url = new moodle_url('/blocks/cobalt_reports/viewreport.php', array('id'=>$reportid, 'courseid' => 1)); $link = html_writer::link($link_url, html_writer::span(get_string('viewmore'), '', array('id'=>'reportdashboard_right'))); $this->content->text .=$link; } else { $this->content->text .= ''; } unset($filteropt); // memory footprint return $this->content; }
//if (cr_import_xml($fcontents, $course)) { // redirect("$CFG->wwwroot/blocks/cobalt_reports/managereport.php?courseid={$course->id}", get_string('reportcreated', 'block_cobalt_reports')); //} else { // print_error('errorimporting'); //} //function xmldb_block_reportdashboard_install() { add_customreports_sql(array('activityreport','categoryreport','coursereport')); $page = new moodle_page(); $page->blocks->add_blocks(array('side-db-one' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, -1); $page->blocks->add_blocks(array('side-db-two' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, 0); $page->blocks->add_blocks(array('side-db-three' => array('reportdashboard')), 'blocks-reportdashboard-dashboard', null, null, 1); $reportblocks =$DB->get_records_sql('select id from {block_instances} where blockname="reportdashboard" order by id desc limit 3'); foreach($reportblocks as $reportblock){ $blockinstance[]=$reportblock->id; } $reportslist = $DB->get_records_sql('select id from {block_cobalt_reports} order by id asc limit 3'); $i=0; foreach($reportslist as $reports){ $reportclass = create_reportclass($reports->id); $components = cr_unserialize($reportclass->config->components); $data = new stdClass; $data->title = $DB->get_field('block_cobalt_reports','name',array('id'=>$reports->id)); $data->reportlist = $reports->id; $data->reportcontenttype = $components['plot']['elements'][0]['id']; $DB->set_field('block_instances', 'configdata', base64_encode(serialize($data)), array('id' => $blockinstance[$i])); $i++; } // } //}
function cr_listof_reporttypes($reportid) { global $DB; $reportclass = create_reportclass($reportid); $components = cr_unserialize($reportclass->config->components); foreach ($components['plot']['elements'] as $key => $value) { $reportcontenttypes[$value['pluginname']] = ucfirst($value['formdata']->chartname); } /* * Notice: line charts not available in NVD3 graphs. */ if (get_config('block_cobalt_reports', 'reportchartui') === 'd3') { unset($reportcontenttypes['line']); } /* * Notice: line charts not available in NVD3 graphs. */ if (get_config('block_cobalt_reports', 'reportchartui') === 'default') { unset($reportcontenttypes['bar']); } $reportcontenttypes['table'] = get_string('table', 'block_reportdashboard'); return $reportcontenttypes; }