-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
941 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Ratings and allocations table. | ||
* | ||
* @package mod_ratingallocate | ||
* @copyright 2016 Janek Lasocki-Biczysko <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
|
@@ -27,18 +29,33 @@ | |
global $CFG; | ||
require_once($CFG->libdir . '/tablelib.php'); | ||
|
||
/** | ||
* @class ratings_and_allocations_table | ||
*/ | ||
class ratings_and_allocations_table extends \table_sql { | ||
|
||
/** | ||
* Choice column. | ||
*/ | ||
const CHOICE_COL = 'choice_'; | ||
/** | ||
* Alloc suffix. | ||
*/ | ||
const EXPORT_CHOICE_ALLOC_SUFFIX = 'alloc'; | ||
/** | ||
* Text suffix. | ||
*/ | ||
const EXPORT_CHOICE_TEXT_SUFFIX = 'text'; | ||
|
||
private $choicenames =[]; | ||
private $choicemax =[]; | ||
private $choicesum =[]; | ||
|
||
/** @var array $choicenames */ | ||
private $choicenames = []; | ||
/** @var array $choicemax */ | ||
private $choicemax = []; | ||
/** @var array $choicesum */ | ||
private $choicesum = []; | ||
/** @var $titles */ | ||
private $titles; | ||
|
||
/** @var true $shownames */ | ||
private $shownames; | ||
|
||
/** | ||
|
@@ -71,6 +88,16 @@ class ratings_and_allocations_table extends \table_sql { | |
*/ | ||
private $renderer; | ||
|
||
/** | ||
* @param \mod_ratingallocate_renderer $renderer | ||
* @param $titles | ||
* @param $ratingallocate | ||
* @param $action | ||
* @param $uniqueid | ||
* @param $downloadable | ||
* @throws \coding_exception | ||
* @throws \dml_exception | ||
*/ | ||
public function __construct(\mod_ratingallocate_renderer $renderer, $titles, $ratingallocate, | ||
$action = ACTION_SHOW_RATINGS_AND_ALLOCATION_TABLE, $uniqueid = 'mod_ratingallocate_table', $downloadable = true) { | ||
parent::__construct($uniqueid); | ||
|
@@ -243,7 +270,7 @@ public function build_table_by_sql($ratings, $allocations, $writeable = false) { | |
$users = $this->rawdata; | ||
|
||
// Group all ratings per user to match table structure. | ||
$ratingsbyuser =[]; | ||
$ratingsbyuser = []; | ||
foreach ($ratings as $rating) { | ||
if (empty($ratingsbyuser[$rating->userid])) { | ||
$ratingsbyuser[$rating->userid] = []; | ||
|
@@ -332,7 +359,7 @@ private function add_user_ratings_row($user, $userratings, $userallocations) { | |
foreach ($userratings as $choiceid => $userrating) { | ||
$row[self::CHOICE_COL . $choiceid] = [ | ||
'rating' => $userrating, | ||
'hasallocation' => false // May be overridden later. | ||
'hasallocation' => false, // May be overridden later. | ||
]; | ||
} | ||
|
||
|
@@ -349,7 +376,7 @@ private function add_user_ratings_row($user, $userratings, $userallocations) { | |
// User has not rated this choice, but it was assigned to him/her. | ||
$row[$rowkey] = [ | ||
'rating' => null, | ||
'hasallocation' => true | ||
'hasallocation' => true, | ||
]; | ||
} else { | ||
// User has rated this choice. | ||
|
@@ -532,7 +559,7 @@ private function setup_filter($hidenorating = null, $showallocnecessary = null, | |
$filter = [ | ||
'hidenorating' => $this->hidenorating, | ||
'showallocnecessary' => $this->showallocnecessary, | ||
'groupselect' => $this->groupselect | ||
'groupselect' => $this->groupselect, | ||
]; | ||
} | ||
if (!is_null($hidenorating)) { | ||
|
@@ -558,7 +585,7 @@ public function get_filter() { | |
$filter = [ | ||
'hidenorating' => $this->hidenorating, | ||
'showallocnecessary' => $this->showallocnecessary, | ||
'groupselect' => $this->groupselect | ||
'groupselect' => $this->groupselect, | ||
]; | ||
return $filter; | ||
} | ||
|
@@ -617,12 +644,17 @@ function($u) { | |
[ | ||
'ratingallocateid' => $this->ratingallocate->ratingallocate->id, | ||
'ratingallocateid2' => $this->ratingallocate->ratingallocate->id, | ||
'groupselect' => $this->groupselect | ||
'groupselect' => $this->groupselect, | ||
] | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @param $choiceids | ||
* @return array | ||
* @throws \dml_exception | ||
*/ | ||
private function filter_choiceids($choiceids) { | ||
global $DB; | ||
if (!$choiceids) { | ||
|
@@ -655,7 +687,7 @@ function($c) { | |
$DB->get_records_sql($sql, | ||
[ | ||
'ratingallocateid' => $this->ratingallocate->ratingallocate->id, | ||
'groupselect' => $this->groupselect | ||
'groupselect' => $this->groupselect, | ||
] | ||
) | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.