Source for file flatview_data_generator.class.php
Documentation is available at flatview_data_generator.class.php
* Class to select, sort and transform object data into array data,
* used for the teacher's flat view
// Sorting types constants
const FVDG_SORT_LASTNAME = 1;
const FVDG_SORT_FIRSTNAME = 2;
const FVDG_SORT_DESC = 8;
$this->users = (isset ($users) ? $users : array());
$this->evals = (isset ($evals) ? $evals : array());
$this->links = (isset ($links) ? $links : array());
* Get total number of users (rows)
* Get total number of evaluations/links (columns) (the 2 users columns not included)
* Get array containing column header names (incl user columns)
if (!isset ($items_count))
($count < $items_count ) && ($items_start + $count < count($this->evals_links));
$headers[] = $item->get_name();
* @return array 2-dimensional array - each array contains the elements:
* 3+: evaluation/link scores
public function get_data ($users_sorting = 0,
$users_start = 0, $users_count = null,
$items_start = 0, $items_count = null,
$ignore_score_color = false)
// do some checks on users/items counts, redefine if invalid values
if (!isset ($users_count))
$users_count = count ($this->users) - $users_start;
if (!isset ($items_count))
// copy users to a new array that we will sort
foreach ($this->users as $user)
if ($users_sorting & self :: FVDG_SORT_LASTNAME)
usort($usertable, array ('FlatViewDataGenerator','sort_by_last_name'));
elseif ($users_sorting & self :: FVDG_SORT_FIRSTNAME)
usort($usertable, array ('FlatViewDataGenerator','sort_by_first_name'));
if ($users_sorting & self :: FVDG_SORT_DESC)
// select the requested users
$selected_users = array_slice($usertable, $users_start, $users_count);
// generate actual data array
foreach ($selected_users as $user)
$row[] = $user[0]; // user id
$row[] = $user[1]; // last name
$row[] = $user[2]; // first name
($count < $items_count ) && ($items_start + $count < count($this->evals_links));
$score = $item->calc_score($user[0]);
$row[] = $scoredisplay->display_score($score,$displaytype);
// Sort functions - used internally
|