Parent Directory
|
Revision Log
Revision 1.3 - (view) (download)
| 1 : | dservos | 1.1 | <?php |
| 2 : | dservos | 1.3 | /////////////////////////////////////////////////////////////////////////// |
| 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 : | dservos | 1.2 | class selector { |
| 36 : | public $param; | ||
| 37 : | public $options; | ||
| 38 : | public $active; | ||
| 39 : | |||
| 40 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.2 | public function __construct($param, array $options, $active = null) { |
| 47 : | $this->param = $param; | ||
| 48 : | $this->options = $options; | ||
| 49 : | $this->active = $active; | ||
| 50 : | } | ||
| 51 : | } | ||
| 52 : | dservos | 1.1 | |
| 53 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | class edge { |
| 59 : | public $sortby; | ||
| 60 : | public $groupby; | ||
| 61 : | |||
| 62 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public function __construct($sortby = null, $groupby = null) { |
| 68 : | $this->sortby = $sortby; | ||
| 69 : | $this->groupby = $groupby; | ||
| 70 : | } | ||
| 71 : | } | ||
| 72 : | |||
| 73 : | dservos | 1.3 | /** |
| 74 : | * Encoder class that represents an encoder that will be applied to the visualization. | ||
| 75 : | * @package gradebook | ||
| 76 : | */ | ||
| 77 : | dservos | 1.1 | class encoder { |
| 78 : | const ENCODER_DEFUALT = 1; | ||
| 79 : | const ENCODER_COLOR = 1; | ||
| 80 : | const ENCODER_SHAPE = 2; | ||
| 81 : | const ENCODER_SIZE = 3; | ||
| 82 : | |||
| 83 : | dservos | 1.3 | /// 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 : | dservos | 1.1 | private static $counter = 0; |
| 88 : | |||
| 89 : | public $id; | ||
| 90 : | public $type; | ||
| 91 : | public $settings; | ||
| 92 : | public $datafield; | ||
| 93 : | |||
| 94 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public function __construct($type, $datafield, array $settings = null) { |
| 101 : | $this->type = $type; | ||
| 102 : | $this->settings = $settings; | ||
| 103 : | $this->datafield = $datafield; | ||
| 104 : | $this->id = self::$counter++; | ||
| 105 : | } | ||
| 106 : | } | ||
| 107 : | |||
| 108 : | dservos | 1.3 | /** |
| 109 : | * Legend class representing a legend in the visualization. | ||
| 110 : | * Each legend is based on an encoder. | ||
| 111 : | * @package gradebook | ||
| 112 : | */ | ||
| 113 : | dservos | 1.1 | class legend { |
| 114 : | public $encoder; | ||
| 115 : | |||
| 116 : | dservos | 1.2 | public $show; |
| 117 : | |||
| 118 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.2 | public function __construct($encoder, $show = null) { |
| 124 : | dservos | 1.1 | $this->encoder = $encoder; |
| 125 : | dservos | 1.2 | $this->show = $show; |
| 126 : | dservos | 1.1 | } |
| 127 : | } | ||
| 128 : | |||
| 129 : | dservos | 1.3 | /** |
| 130 : | * Abstract visualization class that all visualization deftions (classes) must extend. | ||
| 131 : | * @package gradebook | ||
| 132 : | */ | ||
| 133 : | dservos | 1.1 | abstract class visualization { |
| 134 : | dservos | 1.3 | /// 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 : | dservos | 1.1 | const LAYOUT_DEFAULT = 1; |
| 139 : | const LAYOUT_AXIS = 1; | ||
| 140 : | const LAYOUT_CIRCLE = 2; | ||
| 141 : | const LAYOUT_DENDROGRAM = 3; | ||
| 142 : | const LAYOUT_FORCEDIRECTED = 4; | ||
| 143 : | const LAYOUT_INDENTEDTREE = 5; | ||
| 144 : | const LAYOUT_NODELINKTREE = 6; | ||
| 145 : | const LAYOUT_PIE = 7; | ||
| 146 : | const LAYOUT_RADIALTREE = 8; | ||
| 147 : | const LAYOUT_RANDOM = 9; | ||
| 148 : | const LAYOUT_STACKEDAREA = 10; | ||
| 149 : | const LAYOUT_TREEMAP = 11; | ||
| 150 : | |||
| 151 : | dservos | 1.3 | /// 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 : | dservos | 1.1 | const SHAPE_BEZIER = 1; |
| 159 : | const SHAPE_BLOCK = -1; | ||
| 160 : | const SHAPE_CARDINAL = 2; | ||
| 161 : | const SHAPE_HORIZONTAL_BAR = -5; | ||
| 162 : | const SHAPE_LINE = 0; | ||
| 163 : | const SHAPE_POLYBLOB = -3; | ||
| 164 : | const SHAPE_POLYGON = -2; | ||
| 165 : | const SHAPE_VERTICAL_BAR = -4; | ||
| 166 : | const SHAPE_WEDGE = -6; | ||
| 167 : | |||
| 168 : | dservos | 1.3 | /** |
| 169 : | * Visualization name, name displayed in visualization selector and other places. | ||
| 170 : | * @var string $name | ||
| 171 : | */ | ||
| 172 : | dservos | 1.1 | public $name; |
| 173 : | |||
| 174 : | dservos | 1.3 | /** |
| 175 : | * The layout type to be used in the visualization. Must be one of the LAYOUT_* constants. | ||
| 176 : | * @var int $layout | ||
| 177 : | */ | ||
| 178 : | dservos | 1.1 | public $layout = self::LAYOUT_DEFAULT; |
| 179 : | |||
| 180 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public $layoutsettings = null; |
| 186 : | |||
| 187 : | dservos | 1.3 | /** |
| 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; | ||
| 193 : | dservos | 1.2 | |
| 194 : | dservos | 1.3 | /** |
| 195 : | * Array of edge objects that will be used to create the edges in the | ||
| 196 : | * visualization. | ||
| 197 : | * @var array $edges | ||
| 198 : | */ | ||
| 199 : | dservos | 1.1 | public $edges = null; |
| 200 : | |||
| 201 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public $nodeshape = null; |
| 207 : | |||
| 208 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public $edgeshape = null; |
| 214 : | |||
| 215 : | dservos | 1.3 | /** |
| 216 : | * Array of selector objects that repersent sellector UI widgets | ||
| 217 : | * in the flash front end. | ||
| 218 : | * @var array $selectors | ||
| 219 : | */ | ||
| 220 : | dservos | 1.2 | public $selectors = null; |
| 221 : | |||
| 222 : | dservos | 1.3 | /** |
| 223 : | * Font to be used threw out the visualization. | ||
| 224 : | * @var string $font | ||
| 225 : | */ | ||
| 226 : | dservos | 1.1 | public $font = 'monospace'; |
| 227 : | |||
| 228 : | dservos | 1.3 | /** |
| 229 : | * Size of the font to be used in the visualization. | ||
| 230 : | * @var int $fontsize | ||
| 231 : | */ | ||
| 232 : | dservos | 1.1 | public $fontsize = 20; |
| 233 : | |||
| 234 : | dservos | 1.3 | /** |
| 235 : | * Array of legend objects that repersent the legends that will | ||
| 236 : | * be shown in the visualization. | ||
| 237 : | * @var array $legends | ||
| 238 : | */ | ||
| 239 : | dservos | 1.1 | public $legends = null; |
| 240 : | |||
| 241 : | dservos | 1.3 | /** |
| 242 : | * Data feild for the xaxis if using axis layout type. | ||
| 243 : | * @var string $xaxis | ||
| 244 : | */ | ||
| 245 : | dservos | 1.1 | public $xaxis; |
| 246 : | |||
| 247 : | dservos | 1.3 | /** |
| 248 : | * Data feild for the yaxis if using axis layout type. | ||
| 249 : | * @var string $yaxis | ||
| 250 : | */ | ||
| 251 : | dservos | 1.1 | public $yaxis; |
| 252 : | |||
| 253 : | dservos | 1.3 | /** |
| 254 : | * The format to use to encode the xaxis labels. | ||
| 255 : | * @var string $xaxislabelformat | ||
| 256 : | */ | ||
| 257 : | dservos | 1.1 | public $xaxislabelformat; |
| 258 : | |||
| 259 : | dservos | 1.3 | /** |
| 260 : | * The format to use to encode the yaxis labels. | ||
| 261 : | * @var string $yaxislabelformat | ||
| 262 : | */ | ||
| 263 : | dservos | 1.1 | public $yaxislabelformat; |
| 264 : | |||
| 265 : | dservos | 1.3 | /** |
| 266 : | * The minium value of the x axis. | ||
| 267 : | * @var float $xaxismin | ||
| 268 : | */ | ||
| 269 : | dservos | 1.1 | public $xaxismin; |
| 270 : | |||
| 271 : | dservos | 1.3 | /** |
| 272 : | * The maxium value of the x axis. | ||
| 273 : | * @var float $xaxismax | ||
| 274 : | */ | ||
| 275 : | dservos | 1.1 | public $xaxismax; |
| 276 : | |||
| 277 : | dservos | 1.3 | /** |
| 278 : | * The minium value of the y axis. | ||
| 279 : | * @var float $yaxismin | ||
| 280 : | */ | ||
| 281 : | dservos | 1.1 | public $yaxismin; |
| 282 : | |||
| 283 : | dservos | 1.3 | /** |
| 284 : | * The maxium value of the y axis. | ||
| 285 : | * @var float $yaxismax | ||
| 286 : | */ | ||
| 287 : | dservos | 1.1 | public $yaxismax; |
| 288 : | |||
| 289 : | dservos | 1.3 | /** |
| 290 : | * The x axis title. | ||
| 291 : | * @var string $xaxislabel | ||
| 292 : | */ | ||
| 293 : | dservos | 1.1 | public $xaxislabel; |
| 294 : | |||
| 295 : | dservos | 1.3 | /** |
| 296 : | * The y axis title. | ||
| 297 : | * @var string $yaxislabel | ||
| 298 : | */ | ||
| 299 : | dservos | 1.1 | public $yaxislabel; |
| 300 : | |||
| 301 : | dservos | 1.3 | /** |
| 302 : | * The offset in pixels the y axis labels will be moved in the y direction | ||
| 303 : | * @var float $yaxisyoffset | ||
| 304 : | */ | ||
| 305 : | dservos | 1.1 | public $yaxisyoffset; |
| 306 : | |||
| 307 : | dservos | 1.3 | /** |
| 308 : | * The offset in pixels the y axis labels will be moved in the x direction | ||
| 309 : | * @var float $yaxisxoffset | ||
| 310 : | */ | ||
| 311 : | dservos | 1.1 | public $yaxisxoffset; |
| 312 : | |||
| 313 : | dservos | 1.3 | /** |
| 314 : | * The offset in pixels the x axis labels will be moved in the y direction | ||
| 315 : | * @var float $xaxisyoffset | ||
| 316 : | */ | ||
| 317 : | dservos | 1.1 | public $xaxisyoffset; |
| 318 : | |||
| 319 : | dservos | 1.3 | /** |
| 320 : | * The offset in pixels the x axis labels will be moved in the x direction | ||
| 321 : | * @var float $xaxisxoffset | ||
| 322 : | */ | ||
| 323 : | dservos | 1.1 | public $xaxisxoffset; |
| 324 : | |||
| 325 : | dservos | 1.3 | /** |
| 326 : | * The title that will be show in the visualization. | ||
| 327 : | * @var string $title | ||
| 328 : | */ | ||
| 329 : | dservos | 1.1 | public $title; |
| 330 : | |||
| 331 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | public $encoders = null; |
| 343 : | |||
| 344 : | dservos | 1.3 | /** |
| 345 : | * Background color of the visualization. | ||
| 346 : | * @var string $backgroundcolor | ||
| 347 : | */ | ||
| 348 : | dservos | 1.1 | public $backgroundcolor = 'ffffff'; |
| 349 : | |||
| 350 : | dservos | 1.3 | /** |
| 351 : | * Width of the embedded flash applet. | ||
| 352 : | * @var int $width | ||
| 353 : | */ | ||
| 354 : | dservos | 1.1 | public $width = 800; |
| 355 : | |||
| 356 : | dservos | 1.3 | /** |
| 357 : | * Width of the embedded flash applet. | ||
| 358 : | * @var int $height | ||
| 359 : | */ | ||
| 360 : | dservos | 1.1 | public $height = 600; |
| 361 : | |||
| 362 : | dservos | 1.3 | /** |
| 363 : | * Frame rate of the flash applet. | ||
| 364 : | * @var int $framerate | ||
| 365 : | */ | ||
| 366 : | dservos | 1.1 | public $framerate = 30; |
| 367 : | |||
| 368 : | dservos | 1.3 | /** |
| 369 : | * Default quality setting for the flash applet. | ||
| 370 : | * @var string $quality | ||
| 371 : | */ | ||
| 372 : | dservos | 1.1 | public $quality = "high"; |
| 373 : | |||
| 374 : | dservos | 1.3 | /** |
| 375 : | * Background color of the pop up widget. | ||
| 376 : | * @var string $popupbgcolor | ||
| 377 : | */ | ||
| 378 : | dservos | 1.1 | public $popupbgcolor = '7777ff'; |
| 379 : | |||
| 380 : | dservos | 1.3 | /** |
| 381 : | * Background alpha value of the pop up widget. | ||
| 382 : | * @var float $popupbgalpha | ||
| 383 : | */ | ||
| 384 : | dservos | 1.1 | public $popupbgalpha = 0.60; |
| 385 : | |||
| 386 : | dservos | 1.3 | /** |
| 387 : | * Color of the border of the pop up widget. | ||
| 388 : | * @var string $popuplinecolor | ||
| 389 : | */ | ||
| 390 : | dservos | 1.1 | public $popuplinecolor = '0000ff'; |
| 391 : | |||
| 392 : | dservos | 1.3 | /** |
| 393 : | * Alpha value of the border of the pop up widget | ||
| 394 : | * @var float $popuplinealpha | ||
| 395 : | */ | ||
| 396 : | dservos | 1.1 | public $popuplinealpha = 0.3; |
| 397 : | |||
| 398 : | dservos | 1.3 | /** |
| 399 : | * Line width of the border of the pop up widget | ||
| 400 : | * @var int $popuplinesize | ||
| 401 : | */ | ||
| 402 : | dservos | 1.1 | public $popuplinesize = 3; |
| 403 : | |||
| 404 : | dservos | 1.3 | /** |
| 405 : | * Font to be used in the pop up widget | ||
| 406 : | * @var string $popupfont | ||
| 407 : | */ | ||
| 408 : | dservos | 1.1 | public $popupfont = 'monospace'; |
| 409 : | |||
| 410 : | dservos | 1.3 | /** |
| 411 : | * Font size used in the pop up widget | ||
| 412 : | * @var int $popupfontsize | ||
| 413 : | */ | ||
| 414 : | dservos | 1.1 | public $popupfontsize = 12; |
| 415 : | |||
| 416 : | dservos | 1.3 | /** |
| 417 : | * Background color of the button widget | ||
| 418 : | * @var string buttonbgcolor | ||
| 419 : | */ | ||
| 420 : | dservos | 1.1 | public $buttonbgcolor = '9999FF'; |
| 421 : | |||
| 422 : | dservos | 1.3 | /** |
| 423 : | * Background alpha value of the button widget. | ||
| 424 : | * @var float $buttonbgalpha | ||
| 425 : | */ | ||
| 426 : | dservos | 1.1 | public $buttonbgalpha = 0.6; |
| 427 : | |||
| 428 : | dservos | 1.3 | /** |
| 429 : | * Font used on button widgets. | ||
| 430 : | * @var string $buttonfont | ||
| 431 : | */ | ||
| 432 : | dservos | 1.1 | public $buttonfont = 'monospace'; |
| 433 : | |||
| 434 : | dservos | 1.3 | /** |
| 435 : | * Font size used on button widgets. | ||
| 436 : | * @var int $buttonfontsize | ||
| 437 : | */ | ||
| 438 : | dservos | 1.1 | public $buttonfontsize = 12; |
| 439 : | |||
| 440 : | dservos | 1.3 | /** |
| 441 : | * Line width of the border of the button widget. | ||
| 442 : | * @var int $buttonlinesize | ||
| 443 : | */ | ||
| 444 : | dservos | 1.1 | public $buttonlinesize = 1; |
| 445 : | |||
| 446 : | dservos | 1.3 | /** |
| 447 : | * Color of the border of the button widget. | ||
| 448 : | *@var string $buttonlinecolor | ||
| 449 : | */ | ||
| 450 : | dservos | 1.1 | public $buttonlinecolor = '4444FF'; |
| 451 : | |||
| 452 : | dservos | 1.3 | /** |
| 453 : | * Alpha value of the border for the button widget. | ||
| 454 : | * @var flaot $buttonlinealpha | ||
| 455 : | */ | ||
| 456 : | dservos | 1.1 | public $buttonlinealpha = 0.3; |
| 457 : | |||
| 458 : | dservos | 1.3 | /** |
| 459 : | * Visualization constructer. | ||
| 460 : | * Sets name of visualization. | ||
| 461 : | * @param string $name The name of the visualization. | ||
| 462 : | */ | ||
| 463 : | dservos | 1.1 | public function __construct($name) { |
| 464 : | $this->name = $name; | ||
| 465 : | } | ||
| 466 : | |||
| 467 : | dservos | 1.3 | /** |
| 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 : | dservos | 1.1 | abstract public function report_data($visualreport); |
| 475 : | } | ||
| 476 : | ?> |
| Moodle CVS Admin | ViewVC Help |
| Powered by ViewVC 1.0.7 |