|
By dservos:
CONTRIB-497
* Added flare libbary to repo as it is needed to build the flash front end. Lib is located at /grade/report/visual/flare_visualization/flare/. For more information see http://flare.prefuse.org/
* Added more visualizations.
* Added settings/preferences page for the report.
* Added printable version.
* Added more documentation.
* Added README.txt
* Cleaned up code.
* Fixed a bunch of small bugs.
|
| 1 |
<?php |
<?php |
| 2 |
|
/////////////////////////////////////////////////////////////////////////// |
| 3 |
|
// // |
| 4 |
|
// NOTICE OF COPYRIGHT // |
| 5 |
|
// // |
| 6 |
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment // |
| 7 |
|
// http://moodle.org // |
| 8 |
|
// // |
| 9 |
|
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // |
| 10 |
|
// // |
| 11 |
|
// This program is free software; you can redistribute it and/or modify // |
| 12 |
|
// it under the terms of the GNU General Public License as published by // |
| 13 |
|
// the Free Software Foundation; either version 2 of the License, or // |
| 14 |
|
// (at your option) any later version. // |
| 15 |
|
// // |
| 16 |
|
// This program is distributed in the hope that it will be useful, // |
| 17 |
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
| 18 |
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
| 19 |
|
// GNU General Public License for more details: // |
| 20 |
|
// // |
| 21 |
|
// http://www.gnu.org/copyleft/gpl.html // |
| 22 |
|
// // |
| 23 |
|
/////////////////////////////////////////////////////////////////////////// |
| 24 |
|
|
| 25 |
|
/** |
| 26 |
|
* File witch defines the abstract class visualization witch all visualizations must extend. |
| 27 |
|
* Also defines serveral classes used by the visualization class and classes that extend it. |
| 28 |
|
* @package gradebook |
| 29 |
|
*/ |
| 30 |
|
|
| 31 |
|
/** |
| 32 |
|
* Selector class that represents the selector UI widget in the flash/flex front end. |
| 33 |
|
* @package gradebook |
| 34 |
|
*/ |
| 35 |
class selector { |
class selector { |
| 36 |
public $param; |
public $param; |
| 37 |
public $options; |
public $options; |
| 38 |
public $active; |
public $active; |
| 39 |
|
|
| 40 |
|
/** |
| 41 |
|
* Selector constructer. |
| 42 |
|
* @param string $param the URI value that the selector will add to the URL from witch the data for the visualization is loaded. |
| 43 |
|
* @param array $options an array of options (strings) that the selector will show where the key is the value of $param to be added to the URL. |
| 44 |
|
* @param string $active the key of the active element in $options that will show up as selected by defualt in the UI widget. |
| 45 |
|
*/ |
| 46 |
public function __construct($param, array $options, $active = null) { |
public function __construct($param, array $options, $active = null) { |
| 47 |
$this->param = $param; |
$this->param = $param; |
| 48 |
$this->options = $options; |
$this->options = $options; |
| 50 |
} |
} |
| 51 |
} |
} |
| 52 |
|
|
| 53 |
|
/** |
| 54 |
|
* Edge class that represents a set of edges that will be created based on the data |
| 55 |
|
* recvied by the front end. |
| 56 |
|
* @package gradebook |
| 57 |
|
*/ |
| 58 |
class edge { |
class edge { |
| 59 |
public $sortby; |
public $sortby; |
| 60 |
public $groupby; |
public $groupby; |
| 61 |
|
|
| 62 |
|
/** |
| 63 |
|
* Edge constructer. |
| 64 |
|
* @param array $sortby array of data feilds the nodes should be sorted by whell creating the edges. |
| 65 |
|
* @param array $groupby array of data feilds the nodes will be grouped by when creating the edges. |
| 66 |
|
*/ |
| 67 |
public function __construct($sortby = null, $groupby = null) { |
public function __construct($sortby = null, $groupby = null) { |
| 68 |
$this->sortby = $sortby; |
$this->sortby = $sortby; |
| 69 |
$this->groupby = $groupby; |
$this->groupby = $groupby; |
| 70 |
} |
} |
| 71 |
} |
} |
| 72 |
|
|
| 73 |
|
/** |
| 74 |
|
* Encoder class that represents an encoder that will be applied to the visualization. |
| 75 |
|
* @package gradebook |
| 76 |
|
*/ |
| 77 |
class encoder { |
class encoder { |
| 78 |
const ENCODER_DEFUALT = 1; |
const ENCODER_DEFUALT = 1; |
| 79 |
const ENCODER_COLOR = 1; |
const ENCODER_COLOR = 1; |
| 80 |
const ENCODER_SHAPE = 2; |
const ENCODER_SHAPE = 2; |
| 81 |
const ENCODER_SIZE = 3; |
const ENCODER_SIZE = 3; |
| 82 |
|
|
| 83 |
|
/// Each encoder class needs to have a unique int id so it can be |
| 84 |
|
/// paird with a legend class. $counter holds the last id used in a |
| 85 |
|
/// encoder class + 1, so the next encoder class will have an $id of |
| 86 |
|
/// $counter. |
| 87 |
private static $counter = 0; |
private static $counter = 0; |
| 88 |
|
|
| 89 |
public $id; |
public $id; |
|
|
|
| 90 |
public $type; |
public $type; |
|
|
|
| 91 |
public $settings; |
public $settings; |
|
|
|
| 92 |
public $datafield; |
public $datafield; |
| 93 |
|
|
| 94 |
|
/** |
| 95 |
|
* Encoder constructer. |
| 96 |
|
* @param int $type the encoder type, one of ENCODER_COLOR, ENCODER_SHAPE or ENCODER_SIZE. |
| 97 |
|
* @param string $datafield the datafield of the data the encoder will effect. |
| 98 |
|
* @param array $settings the settings that will be passed to the encoder constructer in flare (in the front end). |
| 99 |
|
*/ |
| 100 |
public function __construct($type, $datafield, array $settings = null) { |
public function __construct($type, $datafield, array $settings = null) { |
| 101 |
$this->type = $type; |
$this->type = $type; |
| 102 |
$this->settings = $settings; |
$this->settings = $settings; |
| 105 |
} |
} |
| 106 |
} |
} |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* Legend class representing a legend in the visualization. |
| 110 |
|
* Each legend is based on an encoder. |
| 111 |
|
* @package gradebook |
| 112 |
|
*/ |
| 113 |
class legend { |
class legend { |
| 114 |
public $encoder; |
public $encoder; |
| 115 |
|
|
| 116 |
public $show; |
public $show; |
| 117 |
|
|
| 118 |
|
/** |
| 119 |
|
* Legend constructer. |
| 120 |
|
* @param object $encoder the encoder this legend is based on. |
| 121 |
|
* @param string $show the value to be selected by defualt in the legend, if null all are selected. |
| 122 |
|
*/ |
| 123 |
public function __construct($encoder, $show = null) { |
public function __construct($encoder, $show = null) { |
| 124 |
$this->encoder = $encoder; |
$this->encoder = $encoder; |
| 125 |
$this->show = $show; |
$this->show = $show; |
| 126 |
} |
} |
| 127 |
} |
} |
| 128 |
|
|
| 129 |
|
/** |
| 130 |
|
* Abstract visualization class that all visualization deftions (classes) must extend. |
| 131 |
|
* @package gradebook |
| 132 |
|
*/ |
| 133 |
abstract class visualization { |
abstract class visualization { |
| 134 |
|
/// Layout types. |
| 135 |
|
/// Currently only LAYOUT_AXIS has been fully implmented and tested, |
| 136 |
|
/// others may have unexpected results or errors in the front end. |
| 137 |
|
/// TODO: Add support for and test all layout types. |
| 138 |
const LAYOUT_DEFAULT = 1; |
const LAYOUT_DEFAULT = 1; |
| 139 |
const LAYOUT_AXIS = 1; |
const LAYOUT_AXIS = 1; |
| 140 |
const LAYOUT_CIRCLE = 2; |
const LAYOUT_CIRCLE = 2; |
| 148 |
const LAYOUT_STACKEDAREA = 10; |
const LAYOUT_STACKEDAREA = 10; |
| 149 |
const LAYOUT_TREEMAP = 11; |
const LAYOUT_TREEMAP = 11; |
| 150 |
|
|
| 151 |
|
/// Shape types for edges and nodes. |
| 152 |
|
/// Currently only SHAPE_HORIZONTAL_BAR, SHAPE_VERTICAL_BAR, |
| 153 |
|
/// and SHAPE_CARDINAL have been fully tested, others may have |
| 154 |
|
/// unexpected results or errors in the front end. |
| 155 |
|
/// SHAPE_HORIZONTAL_BAR will trun into SHAPE_VERTICAL_BAR when |
| 156 |
|
/// inverted and vice versa. |
| 157 |
|
/// TODO: Test and add support for all shapes. |
| 158 |
const SHAPE_BEZIER = 1; |
const SHAPE_BEZIER = 1; |
| 159 |
const SHAPE_BLOCK = -1; |
const SHAPE_BLOCK = -1; |
| 160 |
const SHAPE_CARDINAL = 2; |
const SHAPE_CARDINAL = 2; |
| 165 |
const SHAPE_VERTICAL_BAR = -4; |
const SHAPE_VERTICAL_BAR = -4; |
| 166 |
const SHAPE_WEDGE = -6; |
const SHAPE_WEDGE = -6; |
| 167 |
|
|
| 168 |
|
/** |
| 169 |
|
* Visualization name, name displayed in visualization selector and other places. |
| 170 |
|
* @var string $name |
| 171 |
|
*/ |
| 172 |
public $name; |
public $name; |
| 173 |
|
|
| 174 |
|
/** |
| 175 |
|
* The layout type to be used in the visualization. Must be one of the LAYOUT_* constants. |
| 176 |
|
* @var int $layout |
| 177 |
|
*/ |
| 178 |
public $layout = self::LAYOUT_DEFAULT; |
public $layout = self::LAYOUT_DEFAULT; |
| 179 |
|
|
| 180 |
|
/** |
| 181 |
|
* Array of settings to be past to the layout constructor in the front end. |
| 182 |
|
* Thess will be diffrent for each layout type. |
| 183 |
|
* @var array $layoutsettings |
| 184 |
|
*/ |
| 185 |
public $layoutsettings = null; |
public $layoutsettings = null; |
| 186 |
|
|
| 187 |
|
/** |
| 188 |
|
* If true the data past to the front end will be filiterd by the currently |
| 189 |
|
* selected group in moodle. |
| 190 |
|
* @var bool $usegroups |
| 191 |
|
*/ |
| 192 |
public $usegroups = false; |
public $usegroups = false; |
| 193 |
|
|
| 194 |
|
/** |
| 195 |
|
* Array of edge objects that will be used to create the edges in the |
| 196 |
|
* visualization. |
| 197 |
|
* @var array $edges |
| 198 |
|
*/ |
| 199 |
public $edges = null; |
public $edges = null; |
| 200 |
|
|
| 201 |
|
/** |
| 202 |
|
* The shape to be used for the nodes in the visualization. |
| 203 |
|
* Must be one of the SHAPE_* constants. |
| 204 |
|
* @var int $nodeshape |
| 205 |
|
*/ |
| 206 |
public $nodeshape = null; |
public $nodeshape = null; |
| 207 |
|
|
| 208 |
|
/** |
| 209 |
|
* The edge shape to be used for the edges in the visualization. |
| 210 |
|
* Must be one of the SHAPE_* constants. |
| 211 |
|
* @var int $edgeshape |
| 212 |
|
*/ |
| 213 |
public $edgeshape = null; |
public $edgeshape = null; |
| 214 |
|
|
| 215 |
|
/** |
| 216 |
|
* Array of selector objects that repersent sellector UI widgets |
| 217 |
|
* in the flash front end. |
| 218 |
|
* @var array $selectors |
| 219 |
|
*/ |
| 220 |
public $selectors = null; |
public $selectors = null; |
| 221 |
|
|
| 222 |
|
/** |
| 223 |
|
* Font to be used threw out the visualization. |
| 224 |
|
* @var string $font |
| 225 |
|
*/ |
| 226 |
public $font = 'monospace'; |
public $font = 'monospace'; |
| 227 |
|
|
| 228 |
|
/** |
| 229 |
|
* Size of the font to be used in the visualization. |
| 230 |
|
* @var int $fontsize |
| 231 |
|
*/ |
| 232 |
public $fontsize = 20; |
public $fontsize = 20; |
| 233 |
|
|
| 234 |
|
/** |
| 235 |
|
* Array of legend objects that repersent the legends that will |
| 236 |
|
* be shown in the visualization. |
| 237 |
|
* @var array $legends |
| 238 |
|
*/ |
| 239 |
public $legends = null; |
public $legends = null; |
| 240 |
|
|
| 241 |
|
/** |
| 242 |
|
* Data feild for the xaxis if using axis layout type. |
| 243 |
|
* @var string $xaxis |
| 244 |
|
*/ |
| 245 |
public $xaxis; |
public $xaxis; |
| 246 |
|
|
| 247 |
|
/** |
| 248 |
|
* Data feild for the yaxis if using axis layout type. |
| 249 |
|
* @var string $yaxis |
| 250 |
|
*/ |
| 251 |
public $yaxis; |
public $yaxis; |
| 252 |
|
|
| 253 |
|
/** |
| 254 |
|
* The format to use to encode the xaxis labels. |
| 255 |
|
* @var string $xaxislabelformat |
| 256 |
|
*/ |
| 257 |
public $xaxislabelformat; |
public $xaxislabelformat; |
| 258 |
|
|
| 259 |
|
/** |
| 260 |
|
* The format to use to encode the yaxis labels. |
| 261 |
|
* @var string $yaxislabelformat |
| 262 |
|
*/ |
| 263 |
public $yaxislabelformat; |
public $yaxislabelformat; |
| 264 |
|
|
| 265 |
|
/** |
| 266 |
|
* The minium value of the x axis. |
| 267 |
|
* @var float $xaxismin |
| 268 |
|
*/ |
| 269 |
public $xaxismin; |
public $xaxismin; |
| 270 |
|
|
| 271 |
|
/** |
| 272 |
|
* The maxium value of the x axis. |
| 273 |
|
* @var float $xaxismax |
| 274 |
|
*/ |
| 275 |
public $xaxismax; |
public $xaxismax; |
| 276 |
|
|
| 277 |
|
/** |
| 278 |
|
* The minium value of the y axis. |
| 279 |
|
* @var float $yaxismin |
| 280 |
|
*/ |
| 281 |
public $yaxismin; |
public $yaxismin; |
| 282 |
|
|
| 283 |
|
/** |
| 284 |
|
* The maxium value of the y axis. |
| 285 |
|
* @var float $yaxismax |
| 286 |
|
*/ |
| 287 |
public $yaxismax; |
public $yaxismax; |
| 288 |
|
|
| 289 |
|
/** |
| 290 |
|
* The x axis title. |
| 291 |
|
* @var string $xaxislabel |
| 292 |
|
*/ |
| 293 |
public $xaxislabel; |
public $xaxislabel; |
| 294 |
|
|
| 295 |
|
/** |
| 296 |
|
* The y axis title. |
| 297 |
|
* @var string $yaxislabel |
| 298 |
|
*/ |
| 299 |
public $yaxislabel; |
public $yaxislabel; |
| 300 |
|
|
| 301 |
|
/** |
| 302 |
|
* The offset in pixels the y axis labels will be moved in the y direction |
| 303 |
|
* @var float $yaxisyoffset |
| 304 |
|
*/ |
| 305 |
public $yaxisyoffset; |
public $yaxisyoffset; |
| 306 |
|
|
| 307 |
|
/** |
| 308 |
|
* The offset in pixels the y axis labels will be moved in the x direction |
| 309 |
|
* @var float $yaxisxoffset |
| 310 |
|
*/ |
| 311 |
public $yaxisxoffset; |
public $yaxisxoffset; |
| 312 |
|
|
| 313 |
|
/** |
| 314 |
|
* The offset in pixels the x axis labels will be moved in the y direction |
| 315 |
|
* @var float $xaxisyoffset |
| 316 |
|
*/ |
| 317 |
public $xaxisyoffset; |
public $xaxisyoffset; |
| 318 |
|
|
| 319 |
|
/** |
| 320 |
|
* The offset in pixels the x axis labels will be moved in the x direction |
| 321 |
|
* @var float $xaxisxoffset |
| 322 |
|
*/ |
| 323 |
public $xaxisxoffset; |
public $xaxisxoffset; |
| 324 |
|
|
| 325 |
|
/** |
| 326 |
|
* The title that will be show in the visualization. |
| 327 |
|
* @var string $title |
| 328 |
|
*/ |
| 329 |
public $title; |
public $title; |
| 330 |
|
|
| 331 |
public $capabilities = null; |
/** |
| 332 |
|
* The capability required of the user to view this visualization. |
| 333 |
|
* If null, no capability is needed. |
| 334 |
|
* @var string $capability |
| 335 |
|
*/ |
| 336 |
|
public $capability = null; |
| 337 |
|
|
| 338 |
|
/** |
| 339 |
|
* Array of encoders to apply to the visualization. |
| 340 |
|
* @var array $encoders |
| 341 |
|
*/ |
| 342 |
public $encoders = null; |
public $encoders = null; |
| 343 |
|
|
| 344 |
|
/** |
| 345 |
|
* Background color of the visualization. |
| 346 |
|
* @var string $backgroundcolor |
| 347 |
|
*/ |
| 348 |
public $backgroundcolor = 'ffffff'; |
public $backgroundcolor = 'ffffff'; |
| 349 |
|
|
| 350 |
|
/** |
| 351 |
|
* Width of the embedded flash applet. |
| 352 |
|
* @var int $width |
| 353 |
|
*/ |
| 354 |
public $width = 800; |
public $width = 800; |
| 355 |
|
|
| 356 |
|
/** |
| 357 |
|
* Width of the embedded flash applet. |
| 358 |
|
* @var int $height |
| 359 |
|
*/ |
| 360 |
public $height = 600; |
public $height = 600; |
| 361 |
|
|
| 362 |
|
/** |
| 363 |
|
* Frame rate of the flash applet. |
| 364 |
|
* @var int $framerate |
| 365 |
|
*/ |
| 366 |
public $framerate = 30; |
public $framerate = 30; |
| 367 |
|
|
| 368 |
|
/** |
| 369 |
|
* Default quality setting for the flash applet. |
| 370 |
|
* @var string $quality |
| 371 |
|
*/ |
| 372 |
public $quality = "high"; |
public $quality = "high"; |
| 373 |
|
|
| 374 |
|
/** |
| 375 |
|
* Background color of the pop up widget. |
| 376 |
|
* @var string $popupbgcolor |
| 377 |
|
*/ |
| 378 |
public $popupbgcolor = '7777ff'; |
public $popupbgcolor = '7777ff'; |
| 379 |
|
|
| 380 |
|
/** |
| 381 |
|
* Background alpha value of the pop up widget. |
| 382 |
|
* @var float $popupbgalpha |
| 383 |
|
*/ |
| 384 |
public $popupbgalpha = 0.60; |
public $popupbgalpha = 0.60; |
| 385 |
|
|
| 386 |
|
/** |
| 387 |
|
* Color of the border of the pop up widget. |
| 388 |
|
* @var string $popuplinecolor |
| 389 |
|
*/ |
| 390 |
public $popuplinecolor = '0000ff'; |
public $popuplinecolor = '0000ff'; |
| 391 |
|
|
| 392 |
|
/** |
| 393 |
|
* Alpha value of the border of the pop up widget |
| 394 |
|
* @var float $popuplinealpha |
| 395 |
|
*/ |
| 396 |
public $popuplinealpha = 0.3; |
public $popuplinealpha = 0.3; |
| 397 |
|
|
| 398 |
|
/** |
| 399 |
|
* Line width of the border of the pop up widget |
| 400 |
|
* @var int $popuplinesize |
| 401 |
|
*/ |
| 402 |
public $popuplinesize = 3; |
public $popuplinesize = 3; |
| 403 |
|
|
| 404 |
|
/** |
| 405 |
|
* Font to be used in the pop up widget |
| 406 |
|
* @var string $popupfont |
| 407 |
|
*/ |
| 408 |
public $popupfont = 'monospace'; |
public $popupfont = 'monospace'; |
| 409 |
|
|
| 410 |
|
/** |
| 411 |
|
* Font size used in the pop up widget |
| 412 |
|
* @var int $popupfontsize |
| 413 |
|
*/ |
| 414 |
public $popupfontsize = 12; |
public $popupfontsize = 12; |
| 415 |
|
|
| 416 |
|
/** |
| 417 |
|
* Background color of the button widget |
| 418 |
|
* @var string buttonbgcolor |
| 419 |
|
*/ |
| 420 |
public $buttonbgcolor = '9999FF'; |
public $buttonbgcolor = '9999FF'; |
| 421 |
|
|
| 422 |
|
/** |
| 423 |
|
* Background alpha value of the button widget. |
| 424 |
|
* @var float $buttonbgalpha |
| 425 |
|
*/ |
| 426 |
public $buttonbgalpha = 0.6; |
public $buttonbgalpha = 0.6; |
| 427 |
|
|
| 428 |
|
/** |
| 429 |
|
* Font used on button widgets. |
| 430 |
|
* @var string $buttonfont |
| 431 |
|
*/ |
| 432 |
public $buttonfont = 'monospace'; |
public $buttonfont = 'monospace'; |
| 433 |
|
|
| 434 |
|
/** |
| 435 |
|
* Font size used on button widgets. |
| 436 |
|
* @var int $buttonfontsize |
| 437 |
|
*/ |
| 438 |
public $buttonfontsize = 12; |
public $buttonfontsize = 12; |
| 439 |
|
|
| 440 |
|
/** |
| 441 |
|
* Line width of the border of the button widget. |
| 442 |
|
* @var int $buttonlinesize |
| 443 |
|
*/ |
| 444 |
public $buttonlinesize = 1; |
public $buttonlinesize = 1; |
| 445 |
|
|
| 446 |
|
/** |
| 447 |
|
* Color of the border of the button widget. |
| 448 |
|
*@var string $buttonlinecolor |
| 449 |
|
*/ |
| 450 |
public $buttonlinecolor = '4444FF'; |
public $buttonlinecolor = '4444FF'; |
| 451 |
|
|
| 452 |
|
/** |
| 453 |
|
* Alpha value of the border for the button widget. |
| 454 |
|
* @var flaot $buttonlinealpha |
| 455 |
|
*/ |
| 456 |
public $buttonlinealpha = 0.3; |
public $buttonlinealpha = 0.3; |
| 457 |
|
|
| 458 |
|
/** |
| 459 |
|
* Visualization constructer. |
| 460 |
|
* Sets name of visualization. |
| 461 |
|
* @param string $name The name of the visualization. |
| 462 |
|
*/ |
| 463 |
public function __construct($name) { |
public function __construct($name) { |
| 464 |
$this->name = $name; |
$this->name = $name; |
| 465 |
} |
} |
| 466 |
|
|
| 467 |
|
/** |
| 468 |
|
* Report_data function that will be called to generate the |
| 469 |
|
* data sent to the front end. All visualization deftions must |
| 470 |
|
* implment this function. |
| 471 |
|
* @param object $visualreport The visual report object. |
| 472 |
|
* @returns array Returns an 2d array repersenting a table of data to be sent to the front end. |
| 473 |
|
*/ |
| 474 |
abstract public function report_data($visualreport); |
abstract public function report_data($visualreport); |
| 475 |
} |
} |
|
|
|
| 476 |
?> |
?> |