-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathusersummaryview.php
87 lines (76 loc) · 3.05 KB
/
usersummaryview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This view provides a summary for the teacher
*
* @package mod_flashcard
* @category mod
* @author Valery Fremaux, Gustav Delius, Tomasz Muras
* @contributors
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
*/
defined('MOODLE_INTERNAL') || die();
echo $out; // Deffered header.
// Small controller here...
if ($action == 'reset') {
$userid = required_param('userid', PARAM_INT);
$DB->delete_records('flashcard_card', array('flashcardid' => $flashcard->id, 'userid' => $userid));
$completion = new completion_info($course);
if (($flashcard->completionallgood || $flashcard->completionallviewed) && $completion->is_enabled($cm)) {
// Unmark completion state.
$completion->update_state($cm, COMPLETION_INCOMPLETE, $userid);
}
}
require_once($CFG->dirroot.'/enrol/locallib.php');
$coursecontext = context_course::instance($COURSE->id);
$course = $DB->get_record('course', array('id' => $COURSE->id), '*', MUST_EXIST);
$groupmode = groups_get_activity_groupmode($cm, $COURSE);
if ($groupmode != NOGROUPS) {
$groupid = groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, $url.'&view=summary&page=byusers');
} else {
$groupid = 0;
}
$courseusers = get_enrolled_users($coursecontext, '', $groupid);
$struser = get_string('username');
$strdeckstates = get_string('deckstates', 'flashcard');
$strcounts = get_string('counters', 'flashcard');
$table = new html_table();
$table->head = array("<b>$struser</b>", "<b>$strdeckstates</b>", "<b>$strcounts</b>");
$table->size = array('30%', '50%', '20%');
$table->width = '100%';
if (!empty($courseusers)) {
foreach ($courseusers as $auser) {
$status = flashcard_get_deck_status($flashcard, $auser->id);
$userbox = $OUTPUT->user_picture($auser);
$userbox .= fullname($auser);
if ($status) {
$flashcard->cm = &$cm;
$deckbox = $renderer->print_deck_status($flashcard, $auser->id, $status, true);
$countbox = $renderer->print_deckcounts($flashcard, $auser->id);
} else {
$deckbox = get_string('notinitialized', 'flashcard');
$countbox = '';
}
$table->data[] = array($userbox, $deckbox, $countbox);
}
echo html_writer::table($table);
} else {
echo '<center>';
echo $OUTPUT->box(get_string('nousers', 'flashcard'));
echo '</center>';
}