[moodle] / contrib / plugins / grade / report / visual / visualizations / visual_grades_vs_students.php Repository:

View of /contrib/plugins/grade/report/visual/visualizations/visual_grades_vs_students.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Thu Jul 24 15:31:45 2008 WST (16 months ago) by dservos
Branch: MAIN
CONTRIB-497
*Added new visualization, Grade Distribution
*Fixed some minor bugs
*Made abstract visualization class for creating visualizations by making classes witch extend it.
*Made visual_settings.php witch takes a visualization class and truns it in to XML witch flex can read in.
*Made flex visualization application read in XML formated settings as well as tab formated data from moodle and combind them to make a custom visualization.
*Made flex visualization application read and use langue strings from moodle.
*Added printer firendly tab

TODO:
*Add more visualizations
*Refactor some of the flex/actionscript code
*More douctenation
*More UI functions for the flex application
<?php
require_once $CFG->dirroot . '/grade/report/visual/visualizations/visualization.php';

class grades_vs_students extends visualization {

    public $colorencoder;
    
    public $shapeencoder;
    
    public $grouplegend;
    
    public $itemlegend;
    

    public function __construct() {
        parent::__construct(get_string('gradesvsstudents', 'gradereport_visual'));
        
        $this->layout = visualization::LAYOUT_AXIS;
        $this->layoutsettings = null;
        
        $this->xaxis = 'student';
        $this->yaxis = 'grade';
        
        $this->xaxislabel = get_string('student', 'gradereport_visual');
        $this->yaxislabel = get_string('grade', 'gradereport_visual');
        $this->title = get_string('gradesvsstudents:title', 'gradereport_visual');
        
        $this->capabilities = null;
        
        $this->colorencoder = new encoder(encoder::ENCODER_COLOR, 'item');
        $this->shapeencoder = new encoder(encoder::ENCODER_SHAPE, 'group');
        $this->encoders = array($this->colorencoder, $this->shapeencoder);
    
        $this->grouplegend = new legend($this->shapeencoder);
        $this->itemlegend = new legend($this->colorencoder);
        $this->legends = array($this->itemlegend, $this->grouplegend);
    }
    
    
    public function report_data($visualreport) {
        $data = array();
        $data['header'] = array();
        $data['header']['student'] = 'student';
        $data['header']['grade'] = 'grade';
        $data['header']['item'] = 'item';
        $data['header']['group'] = 'group';
        
        foreach($visualreport->grades as $itemkey=>$itemgrades) {
            foreach($itemgrades as $studentkey=>$studentdata) {
                if($studentdata != null && $studentdata->finalgrade != null) {
                    foreach(groups_get_user_groups($visualreport->courseid, $studentkey) as $grouping) {
                        if(count($grouping) > 0) {
                            foreach($grouping as $group) {
                                $data[$studentkey . '-' . $itemkey . '-' . $group]['student'] = $visualreport->users[$studentkey]->firstname . ' ' . $visualreport->users[$studentkey]->lastname;
                                $data[$studentkey . '-' . $itemkey . '-' . $group]['grade'] = $studentdata->standardise_score($studentdata->finalgrade, $visualreport->gtree->items[$itemkey]->grademin, $visualreport->gtree->items[$itemkey]->grademax, 0, 100); 
                                $data[$studentkey . '-' . $itemkey . '-' . $group]['item'] = $visualreport->gtree->items[$itemkey]->get_name();
                                $data[$studentkey . '-' . $itemkey . '-' . $group]['group'] = groups_get_group_name($group);
                            }
                        } else {
                            $data[$studentkey . '-' . $itemkey . '-ng' ]['student'] = $visualreport->users[$studentkey]->firstname . ' ' . $visualreport->users[$studentkey]->lastname;
                            $data[$studentkey . '-' . $itemkey . '-ng' ]['grade'] = $studentdata->standardise_score($studentdata->finalgrade, $visualreport->gtree->items[$itemkey]->grademin, $visualreport->gtree->items[$itemkey]->grademax, 0, 100); 
                            $data[$studentkey . '-' . $itemkey . '-ng' ]['item'] = $visualreport->gtree->items[$itemkey]->get_name();
                            $data[$studentkey . '-' . $itemkey . '-ng' ]['group'] = get_string('nogroup', 'gradereport_visual');
                        }
                    }
                }
            }
        }
        
        return $data;
    }
}

?>

Moodle CVS Admin
ViewVC Help
Powered by ViewVC 1.0.7