Skip to content

Commit 17c6cca

Browse files
Merge pull request #116 from catalyst/plugin-dir-update-400
Plugin dir update 400
2 parents 75cd86a + 339bfd1 commit 17c6cca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+852
-110
lines changed

assignstudents.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Functional page, used by the activity coordinators to assign students
1919
*
2020
* @package mod_observation
21-
* @copyright 2021 Endurer Solutions Team
21+
* @copyright Matthew Hilton, Celine Lindeque, Jack Kepper, Jared Hungerford
2222
* @author Matthew Hilton <[email protected]>
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
@@ -30,6 +30,7 @@
3030
$id = required_param('id', PARAM_INT); // Observation instance ID.
3131
$mode = required_param('mode', PARAM_TEXT); // Editor mode - currently only 'randomassign' is supported.
3232
$confirm = optional_param('confirm', null, PARAM_BOOL);
33+
$pageurl = new moodle_url('/mod/observation/assignstudents.php', ['id' => $id, 'mode' => $mode]);
3334

3435
list($observation, $course, $cm) = \mod_observation\observation_manager::get_observation_course_cm_from_obid($id);
3536

@@ -45,7 +46,7 @@
4546
require_login($course, true, $cm);
4647
require_capability('mod/observation:assignstudents', $PAGE->context);
4748

48-
$pageoutput;
49+
$pageoutput = '';
4950

5051
if ($mode === 'randomassign') {
5152
// If no confirmation yet, display confirmation dialog.
@@ -56,6 +57,8 @@
5657

5758
// Accepted confirmation.
5859
if ($confirm === 1) {
60+
require_sesskey();
61+
5962
$remainingusers = timeslot_manager::randomly_assign_students($id);
6063

6164
$message = get_string('randomassignsuccess', 'observation');
@@ -79,7 +82,6 @@
7982
}
8083

8184
// Output page if no redirects.
82-
$pageurl = new moodle_url('/mod/observation/assignstudents.php', array('id' => $id, 'mode' => $mode));
8385
$PAGE->set_url($pageurl);
8486
$PAGE->set_title($course->shortname.': '.$observation->name);
8587
$PAGE->set_heading($course->fullname);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* This file contains the backup structure code for mod_observation
19+
*
20+
* @package mod_observation
21+
* @copyright Catalyst IT Australia
22+
* @author Matthew Hilton
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
defined('MOODLE_INTERNAL') || die;
27+
28+
require_once($CFG->dirroot . '/mod/observation/backup/moodle2/backup_observation_stepslib.php');
29+
30+
/**
31+
* Task to backup observation activity
32+
*/
33+
class backup_observation_activity_task extends backup_activity_task {
34+
/**
35+
* Backup settings
36+
*/
37+
protected function define_my_settings() {
38+
}
39+
40+
/**
41+
* Define steps for backing up observation activity
42+
*/
43+
protected function define_my_steps() {
44+
$this->add_step(new backup_observation_activity_structure_step('observation_structure', 'observation.xml'));
45+
}
46+
47+
/**
48+
* Content link encoding
49+
* @param string $content content to encode
50+
*/
51+
public static function encode_content_links($content) {
52+
return $content;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* This file contains the backup structure code for mod_observation
19+
*
20+
* @package mod_observation
21+
* @copyright Catalyst IT Australia
22+
* @author Matthew Hilton
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
/**
27+
* Structure step to backup one observation activity
28+
*/
29+
class backup_observation_activity_structure_step extends backup_activity_structure_step {
30+
31+
/**
32+
* Define structure of backup
33+
*/
34+
protected function define_structure() {
35+
$userinfo = $this->get_setting_value('userinfo');
36+
37+
$observation = new backup_nested_element('observation', ['id'], [
38+
'name',
39+
'intro',
40+
'timemodified',
41+
'observer_ins',
42+
'observer_ins_f',
43+
'observee_ins',
44+
'observee_ins_f',
45+
'students_self_unregister',
46+
'marking_type'
47+
]);
48+
49+
$notifications = new backup_nested_element('notifications');
50+
51+
$notification = new backup_nested_element('notification', ['id'], [
52+
'timeslot_id',
53+
'time_before'
54+
]);
55+
56+
$points = new backup_nested_element('points');
57+
58+
$point = new backup_nested_element('point', ['id'], [
59+
'obs_id',
60+
'title',
61+
'list_order',
62+
'ins',
63+
'ins_f',
64+
'max_grade',
65+
'res_type',
66+
'file_size'
67+
]);
68+
69+
$responses = new backup_nested_element('responses');
70+
71+
$response = new backup_nested_element('response', ['id'], [
72+
'obs_pt_id',
73+
'obs_ses_id',
74+
'grade_given',
75+
'response',
76+
'ex_comment',
77+
'timecreated',
78+
'timemodified'
79+
]);
80+
81+
$sessions = new backup_nested_element('sessions');
82+
83+
$session = new backup_nested_element('session', ['id'], [
84+
'obs_id',
85+
'observee_id',
86+
'observer_id',
87+
'state',
88+
'start_time',
89+
'finish_time',
90+
'ex_comment'
91+
]);
92+
93+
$timeslots = new backup_nested_element('timeslots');
94+
95+
$timeslot = new backup_nested_element('timeslot', ['id'], [
96+
'obs_id',
97+
'start_time',
98+
'duration',
99+
'observer_id',
100+
'observee_id',
101+
'observer_event_id',
102+
'observee_event_id'
103+
]);
104+
105+
// Timeslots tree.
106+
$observation->add_child($timeslots);
107+
$timeslots->add_child($timeslot);
108+
$timeslot->add_child($notifications);
109+
$notifications->add_child($notification);
110+
111+
// Points tree.
112+
$observation->add_child($points);
113+
$points->add_child($point);
114+
115+
// Sessions tree.
116+
$observation->add_child($sessions);
117+
$sessions->add_child($session);
118+
119+
// Responses tree.
120+
$session->add_child($responses);
121+
$responses->add_child($response);
122+
123+
// Set table sources.
124+
$observation->set_source_table('observation', ['id' => backup::VAR_ACTIVITYID]);
125+
$point->set_source_table('observation_points', ['obs_id' => backup::VAR_PARENTID]);
126+
127+
// These are only possible if user info is included.
128+
if ($userinfo || PHPUNIT_TEST) {
129+
$response->set_source_table('observation_point_responses', ['obs_ses_id' => backup::VAR_PARENTID]);
130+
$timeslot->set_source_table('observation_timeslots', ['obs_id' => backup::VAR_PARENTID]);
131+
$notification->set_source_table('observation_notifications', ['timeslot_id' => backup::VAR_PARENTID]);
132+
$session->set_source_table('observation_sessions', ['obs_id' => backup::VAR_PARENTID]);
133+
}
134+
135+
// User ID annotations.
136+
$timeslot->annotate_ids('user', 'observee_id');
137+
$timeslot->annotate_ids('user', 'observer_id');
138+
139+
$session->annotate_ids('user', 'observee_id');
140+
$session->annotate_ids('user', 'observer_id');
141+
142+
// Annotate files.
143+
$response->annotate_files('mod_observation', 'response', 'id');
144+
145+
return $this->prepare_activity_structure($observation);
146+
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* This file contains the restore structure code for mod_observation
19+
*
20+
* @package mod_observation
21+
* @copyright Catalyst IT Australia
22+
* @author Matthew Hilton
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
defined('MOODLE_INTERNAL') || die();
27+
28+
require_once($CFG->dirroot . '/mod/observation/backup/moodle2/restore_observation_stepslib.php');
29+
30+
/**
31+
* Task to restore observation activity
32+
*/
33+
class restore_observation_activity_task extends restore_activity_task {
34+
35+
/**
36+
* Define (add) particular settings this activity can have
37+
*/
38+
protected function define_my_settings() {
39+
// No particular settings for this activity.
40+
}
41+
42+
/**
43+
* Define steps for restoring activity.
44+
*/
45+
protected function define_my_steps() {
46+
$this->add_step(new restore_observation_activity_structure_step('observation_structure', 'observation.xml'));
47+
}
48+
49+
/**
50+
* No content decoding.
51+
*/
52+
public static function define_decode_contents() {
53+
return [];
54+
}
55+
56+
/**
57+
* No decode rules.
58+
*/
59+
public static function define_decode_rules() {
60+
return [];
61+
}
62+
63+
/**
64+
* No restore log rules.
65+
*/
66+
public static function define_restore_log_rules() {
67+
return [];
68+
}
69+
70+
/**
71+
* No restore log rules for course.
72+
*/
73+
public static function define_restore_log_rules_for_course() {
74+
return [];
75+
}
76+
}

0 commit comments

Comments
 (0)