Dan Marsden
6 years ago
8 changed files with 246 additions and 26 deletions
@ -0,0 +1,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/>. |
||||
|
|
||||
|
/** |
||||
|
* Contains the mobile output class for the attendance |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2018 Dan Marsden |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
namespace mod_attendance\output; |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
/** |
||||
|
* Mobile output class for the attendance. |
||||
|
* |
||||
|
* @copyright 2018 Dan Marsden |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
class mobile { |
||||
|
/** |
||||
|
* Returns the initial page when viewing the activity for the mobile app. |
||||
|
* |
||||
|
* @param array $args Arguments from tool_mobile_get_content WS |
||||
|
* @return array HTML, javascript and other data |
||||
|
*/ |
||||
|
public static function mobile_view_activity($args) { |
||||
|
global $OUTPUT, $DB, $USER, $PAGE, $CFG; |
||||
|
|
||||
|
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); |
||||
|
|
||||
|
$args = (object) $args; |
||||
|
$cmid = $args->cmid; |
||||
|
$courseid = $args->courseid; |
||||
|
$groupid = empty($args->group) ? 0 : $args->group; // By default, group 0. |
||||
|
|
||||
|
// Capabilities check. |
||||
|
$cm = get_coursemodule_from_id('attendance', $cmid); |
||||
|
|
||||
|
require_login($courseid, false , $cm, true, true); |
||||
|
|
||||
|
$context = \context_module::instance($cm->id); |
||||
|
require_capability('mod/attendance:view', $context); |
||||
|
|
||||
|
$attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); |
||||
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
||||
|
|
||||
|
$pageparams = new \mod_attendance_view_page_params(); |
||||
|
|
||||
|
$pageparams->studentid = $USER->id; |
||||
|
$pageparams->mode = \mod_attendance_view_page_params::MODE_THIS_COURSE; |
||||
|
$pageparams->view = 5; // Show all sessions for this course? |
||||
|
|
||||
|
$att = new \mod_attendance_structure($attendance, $cm, $course, $context, $pageparams); |
||||
|
|
||||
|
$summary = new \mod_attendance_summary($att->id, array($USER->id), $att->pageparams->startdate, |
||||
|
$att->pageparams->enddate); |
||||
|
$data = array('attendance' => $attendance, |
||||
|
'summary' => $summary->get_all_sessions_summary_for($USER->id)); |
||||
|
|
||||
|
return [ |
||||
|
'templates' => [ |
||||
|
[ |
||||
|
'id' => 'main', |
||||
|
'html' => $OUTPUT->render_from_template('mod_attendance/mobile_view_page', $data), |
||||
|
], |
||||
|
], |
||||
|
'javascript' => '', |
||||
|
'otherdata' => '' |
||||
|
]; |
||||
|
} |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
<?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/>. |
||||
|
|
||||
|
/** |
||||
|
* Defines mobile handlers. |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2018 Dan Marsdenb |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
|
||||
|
$addons = [ |
||||
|
'mod_attendance' => [ |
||||
|
'handlers' => [ |
||||
|
'view' => [ |
||||
|
'displaydata' => [ |
||||
|
'icon' => $CFG->wwwroot . '/mod/attendance/pix/icon.png', |
||||
|
'class' => '', |
||||
|
], |
||||
|
'delegate' => 'CoreCourseModuleDelegate', |
||||
|
'method' => 'mobile_view_activity' |
||||
|
] |
||||
|
], |
||||
|
'lang' => [ // Language strings that are used in all the handlers. |
||||
|
['pluginname', 'attendance'], |
||||
|
['sessionscompleted', 'attendance'], |
||||
|
['pointssessionscompleted', 'attendance'], |
||||
|
['percentagesessionscompleted', 'attendance'], |
||||
|
['sessionstotal', 'attendance'], |
||||
|
['pointsallsessions', 'attendance'], |
||||
|
['percentageallsessions', 'attendance'], |
||||
|
['maxpossiblepoints', 'attendance'], |
||||
|
['maxpossiblepercentage', 'attendance'], |
||||
|
] |
||||
|
] |
||||
|
]; |
@ -0,0 +1,74 @@ |
|||||
|
{{=<% %>=}} |
||||
|
<div> |
||||
|
<core-course-module-description description="<% attendance.intro %>" component="mod_attendance" componentId="<% cmid %>"></core-course-module-description> |
||||
|
<ion-item> |
||||
|
<ion-grid> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.sessionscompleted' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.numtakensessions %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.pointssessionscompleted' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.pointssessionscompleted %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.percentagesessionscompleted' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.percentagesessionscompleted %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
|
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.sessionstotal' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.numallsessions %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.pointsallsessions' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.percentagesessionscompleted %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.percentageallsessions' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.allsessionspercentage %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.maxpossiblepoints' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.maxpossiblepoints %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
<ion-row> |
||||
|
<ion-col col-9 class="text-left"> |
||||
|
{{ 'plugin.mod_attendance.maxpossiblepercentage' | translate }} |
||||
|
</ion-col> |
||||
|
<ion-col col-2 class="text-left"> |
||||
|
<% summary.maxpossiblepercentage %> |
||||
|
</ion-col> |
||||
|
</ion-row> |
||||
|
|
||||
|
</ion-grid> |
||||
|
</ion-item> |
||||
|
</div> |
Loading…
Reference in new issue