-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdoubts.php
113 lines (106 loc) · 4.33 KB
/
doubts.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?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/>.
/**
* List doubts.
*
* @package mod_icontent
* @copyright 2016-2015 Leo Santos {@link http://github.com/leorenis}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(__FILE__).'/../../config.php');
require_once(dirname(__FILE__).'/locallib.php');
use mod_icontent\notes\icontent_note_options;
$id = required_param('id', PARAM_INT); // Course Module ID.
$action = optional_param('action', 0, PARAM_ALPHA); // Action.
$private = optional_param('private', 0, PARAM_INT); // Private.
$featured = optional_param('featured', 0, PARAM_INT); // Featured.
$likes = optional_param('likes', 0, PARAM_INT); // Likes.
$doubttutor = optional_param('doubttutor', 0, PARAM_INT); // Doubttutor.
$tab = optional_param('tab', 0, PARAM_ALPHA); // Alldoubts.
$sort = optional_param('sort', '', PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', ICONTENT_PER_PAGE, PARAM_INT);
$cm = get_coursemodule_from_id('icontent', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
$icontent = $DB->get_record('icontent', ['id' => $cm->instance], '*', MUST_EXIST);
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/icontent:viewnotes', $context);
$urlparams = ['id' => $cm->id, 'action' => $action];
// Page setting.
switch ($action){
case 'doubttutor':
$urlparams += ['doubttutor' => $doubttutor, 'tab' => $tab];
$strheading = get_string('doubttutor', 'mod_icontent');
break;
case 'alldoubts':
$urlparams += ['tab' => $tab];
$strheading = get_string('alldoubts', 'mod_icontent');
break;
}
$PAGE->set_url('/mod/icontent/doubts.php', $urlparams);
// Header and strings.
$PAGE->set_title($icontent->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($icontent->name);
echo $OUTPUT->heading(get_string('listdoubts', 'mod_icontent'), 3);
$url = new moodle_url('/mod/icontent/doubts.php', $urlparams + ['page' => $page, 'perpage' => $perpage]);
// Get sort value.
$sort = icontent_check_value_sort($sort);
// Get users attempts.
$notesusers = icontent_note_options::icontent_get_notes_users_instance($cm->id,
$sort,
$page,
$perpage,
$private,
$featured,
$doubttutor,
$likes,
$tab);
$tnotesusers = icontent_note_options::icontent_count_notes_users_instance($cm->id,
$private,
$featured,
$doubttutor,
$likes,
$tab);
// Make table questions.
$table = new html_table();
$table->id = "idtablenotesusers";
$table->colclasses = ['pictures', 'comments'];
$table->attributes = ['class' => 'table table-hover tableattemptsusers'];
$table->head = [get_string('fullname'), $strheading];
if ($notesusers) {
foreach ($notesusers as $notesuser) {
$user = clone $notesuser;
$user->id = $notesuser->userid;
$picture = $OUTPUT->user_picture($user, ['size' => 35, 'class' => 'img-thumbnail pull-left']);
$linkfirstname = html_writer::link(new moodle_url('/user/view.php', ['id' => $notesuser->userid, 'course' => $course->id]),
$notesuser->firstname.' '.$notesuser->lastname, ['title' => $notesuser->firstname, 'class' => 'lkfullname']);
// Set data.
$table->data[] = [$picture.$linkfirstname, $notesuser->comment];
}
} else {
echo html_writer::div(get_string('norecordsfound', 'mod_icontent'), 'alert alert-warning');
echo $OUTPUT->footer();
exit;
}
// Show table.
echo html_writer::start_div('idtablenotes');
echo html_writer::table($table);
echo $OUTPUT->paging_bar($tnotesusers, $page, $perpage, $url);
echo html_writer::end_div();
echo $OUTPUT->footer();