-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IOMAD: Training event converted to SQL table to allow for sorting of …
…users
- Loading branch information
Showing
3 changed files
with
240 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Base class for the table used by a {@link quiz_attempts_report}. | ||
* | ||
* @package local_report_user_logins | ||
* @copyright 2012 Derick Turner | ||
* @author Derick Turner | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_trainingevent\tables; | ||
|
||
use \table_sql; | ||
use \iomad; | ||
use \context_system; | ||
use \moodle_url; | ||
use \context_module; | ||
use \single_select; | ||
use html_writer; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->libdir.'/tablelib.php'); | ||
|
||
class attendees_table extends table_sql { | ||
|
||
/** | ||
* Generate the display of the user's| fullname | ||
* @param object $user the table row being output. | ||
* @return string HTML content to go inside the td. | ||
*/ | ||
public function col_fullname($row) { | ||
global $id; | ||
|
||
$name = fullname($row, has_capability('moodle/site:viewfullnames', context_module::instance($id))); | ||
return $name; | ||
} | ||
|
||
/** | ||
* Generate the display of the user's| fullname | ||
* @param object $user the table row being output. | ||
* @return string HTML content to go inside the td. | ||
*/ | ||
public function col_event($row) { | ||
global $params, $id, $waitingoption, $event, $eventselect, $OUTPUT; | ||
|
||
if ($this->is_downloading()) { | ||
return format_text($event->name); | ||
} | ||
|
||
if (has_capability('mod/trainingevent:add', context_module::instance($id))) { | ||
$select = new single_select(new moodle_url('/mod/trainingevent/view.php', | ||
['userid' => $row->id, | ||
'id' => $id, | ||
'view' => 1, | ||
'waiting' => $waitingoption]), | ||
'chosenevent', | ||
$eventselect, | ||
$event->id); | ||
$select->formid = 'chooseevent'.$row->id; | ||
return html_writer::tag('div', | ||
$OUTPUT->render($select), | ||
['id' => 'iomad_event_selector']); | ||
} | ||
} | ||
|
||
/** | ||
* Generate the display of the user's| fullname | ||
* @param object $user the table row being output. | ||
* @return string HTML content to go inside the td. | ||
*/ | ||
public function col_action($row) { | ||
global $params, $id, $waitingoption, $event, $eventselect, $OUTPUT, $numattending, $maxcapacity; | ||
|
||
$actionhtml = ""; | ||
if ($this->is_downloading()) { | ||
return; | ||
} | ||
if (has_capability('mod/trainingevent:add', context_module::instance($id))) { | ||
if ($waitingoption && $numattending < $maxcapacity) { | ||
$actionhtml = $OUTPUT->single_button(new moodle_url('view.php', | ||
array('userid' => $row->id, | ||
'id' => $id, | ||
'action' => 'add', | ||
'view' => 1 )), | ||
get_string("add")); | ||
$actionhtml .= " "; | ||
} | ||
$actionhtml .= $OUTPUT->single_button(new moodle_url('view.php', | ||
['userid' => $row->id, | ||
'id' => $id, | ||
'action' => 'delete', | ||
'view' => 1, | ||
'waiting' => $waitingoption]), | ||
get_string("remove", 'trainingevent')); | ||
|
||
} | ||
return $actionhtml; | ||
} | ||
|
||
/** | ||
* Generate the display of the user's| fullname | ||
* @param object $user the table row being output. | ||
* @return string HTML content to go inside the td. | ||
*/ | ||
public function col_grade($row) { | ||
global $params, $id, $waitingoption, $event, $eventselect, $OUTPUT, $numattending, $maxcapacity; | ||
|
||
$gradehtml = ""; | ||
$usergradeentry = grade_get_grades($event->course, 'mod', 'trainingevent', $event->id, $row->id); | ||
|
||
if ($this->is_downloading()) { | ||
return $usergradeentry->items[0]->grades[$row->id]->str_grade; | ||
} | ||
|
||
if (has_capability('mod/trainingevent:grade', context_module::instance($id)) && $waitingoption == 0) { | ||
$gradehtml = '<form action="view.php" method="get"> | ||
<input type="hidden" name="id" value="' . $id . '" /> | ||
<input type="hidden" name="userid" value="'.$row->id.'" /> | ||
<input type="hidden" name="action" value="grade" /> | ||
<input type="hidden" name="view" value="1" /> | ||
<input type="text" name="usergrade" id="id_usergrade" | ||
value="'.$usergradeentry->items[0]->grades[$row->id]->str_grade.'" /> | ||
<input type="submit" value="' . get_string('grade', 'grades') . '" /> | ||
</form>'; | ||
|
||
} | ||
|
||
return $gradehtml; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
#trainingeventattendancetable { | ||
overflow-x: scroll; | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
} | ||
|
||
input[name=usergrade] { | ||
width: 3em; | ||
} | ||
|
||
table.trainingeventdetails { | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
} |
Oops, something went wrong.