Skip to content

Commit

Permalink
Add department in Report
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed Sep 20, 2024
1 parent 579a08d commit 4ea3a3b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions field/teammemberselect/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function render_display_mode(stdClass $entry, array $options): string {
$selected = json_decode($entry->{"c{$fieldid}_content"}, true);
$selected = $selected ? $selected : [];

$str = $this->get_user_list($selected);
$str = $this->get_user_list($selected, $options);

switch ($field->listformat) {
case datalynxfield_teammemberselect::TEAMMEMBERSELECT_FORMAT_NEWLINE:
Expand Down Expand Up @@ -107,9 +107,9 @@ public function render_display_mode(stdClass $entry, array $options): string {
return $str;
}

private static $userlist = [];
private static array $userlist = [];

private function get_user_list($userids) {
private function get_user_list(array $userids, array $options = []): array {
global $DB, $COURSE;

$list = [];
Expand All @@ -135,6 +135,11 @@ private function get_user_list($userids) {
$baseurl->param('id', $user->id);
$fullname = fullname($user);
$item = "<a href=\"$baseurl\">$fullname</a>";
foreach ((array) $user as $property => $value) {
if (isset($options[$property]) && !empty($value)) {
$item .= "<br> " . get_string($property) . ": $value";
}
}
self::$userlist[$user->id] = $item;
$list[] = $item;
}
Expand Down Expand Up @@ -208,6 +213,7 @@ protected function patterns() {
$patterns = parent::patterns();
$patterns["[[$fieldname]]"] = array(true);
$patterns["[[$fieldname:subscribe]]"] = array(true);
$patterns["[[$fieldname:department]]"] = array(false);

return $patterns;
}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_datalynx';
$plugin->version = 2024091800;
$plugin->release = 'v4.7-DataTreasure'; // Data words like data science, data mining.
$plugin->version = 2024092000;
$plugin->release = 'v4.8-DataTreasure'; // Data words like data science, data mining.
$plugin->requires = 2022112800;
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = array(
Expand Down
4 changes: 2 additions & 2 deletions view/report/view_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public function display_entries(?array $options = null): string {
$overallnotyeteditedsum = 0;

foreach ($report as $userid => $data) {
$user = $DB->get_record('user', ['id' => $userid], 'id, firstname, lastname, email');
$userinfo = "{$user->firstname} {$user->lastname} ({$user->id})<br>{$user->email}";
$user = $DB->get_record('user', ['id' => $userid], 'id, firstname, lastname, email, department');
$userinfo = "{$user->firstname} {$user->lastname} ({$user->id})<br>{$user->email} <br> {$user->department}";

foreach ($data['monthly'] as $month => $monthlydata) {
if (!isset($monthlydatabymonth[$month])) {
Expand Down

0 comments on commit 4ea3a3b

Please sign in to comment.