Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#140] properly save and load html instructions #141

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assignstudents.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'invalidqueryparam',
'error',
null,
$a = array('expected' => 'mode to be \'randomassign\'', 'actual' => $mode));
$a = ['expected' => 'mode to be \'randomassign\'', 'actual' => $mode]);
}

require_login($course, true, $cm);
Expand Down
12 changes: 6 additions & 6 deletions backup/moodle2/backup_observation_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ protected function define_structure() {
'observee_ins',
'observee_ins_f',
'students_self_unregister',
'marking_type'
'marking_type',
]);

$notifications = new backup_nested_element('notifications');

$notification = new backup_nested_element('notification', ['id'], [
'timeslot_id',
'time_before'
'time_before',
]);

$points = new backup_nested_element('points');
Expand All @@ -63,7 +63,7 @@ protected function define_structure() {
'ins_f',
'max_grade',
'res_type',
'file_size'
'file_size',
]);

$responses = new backup_nested_element('responses');
Expand All @@ -75,7 +75,7 @@ protected function define_structure() {
'response',
'ex_comment',
'timecreated',
'timemodified'
'timemodified',
]);

$sessions = new backup_nested_element('sessions');
Expand All @@ -87,7 +87,7 @@ protected function define_structure() {
'state',
'start_time',
'finish_time',
'ex_comment'
'ex_comment',
]);

$timeslots = new backup_nested_element('timeslots');
Expand All @@ -99,7 +99,7 @@ protected function define_structure() {
'observer_id',
'observee_id',
'observer_event_id',
'observee_event_id'
'observee_event_id',
]);

// Timeslots tree.
Expand Down
4 changes: 2 additions & 2 deletions classes/calendar_signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function calendar_signup_view(int $observationid, string $title, i

return (object) [
"daynum" => $daynum,
"events" => []
"events" => [],
];
}, $monthdays, array_keys($monthdays));

Expand Down Expand Up @@ -117,7 +117,7 @@ public static function calendar_signup_view(int $observationid, string $title, i
'monthname' => date('F', mktime(0, 0, 0, $month, 10)),
'nextbtn' => $nextmonthbtn,
'prevbtn' => $prevmonthbtn,
'entries' => $weeks
'entries' => $weeks,
];

return $OUTPUT->render_from_template('mod_observation/calendar_signup', $templatedata);
Expand Down
2 changes: 1 addition & 1 deletion classes/form/notificationeditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function definition() {
$intervalselector = [
$mform->createElement('text', 'interval_amount'),
$mform->createElement('select', 'interval_multiplier', '', $options),
$mform->createElement('submit', 'submit_btn', get_string('create', 'observation'))
$mform->createElement('submit', 'submit_btn', get_string('create', 'observation')),
];

$mform->addGroup($intervalselector, 'select_group', get_string('receivenotification', 'observation'), null, false);
Expand Down
6 changes: 3 additions & 3 deletions classes/form/pointeditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public function definition() {
$mform->addElement('header', 'gradingsettings', get_string('grading', 'observation'));

// Point type selection.
$radioarray = array();
$radioarray = [];
$radioarray[] = $mform->createElement('radio', 'res_type', '', get_string('textinputtype', 'observation'), 0);
$radioarray[] = $mform->createElement('radio', 'res_type', '', get_string('passfailtype', 'observation'), 1);
$radioarray[] = $mform->createElement('radio', 'res_type', '', get_string('evidencetype', 'observation'), 2);

$mform->addGroup($radioarray, 'radioar', get_string('obpointtype', 'observation'), array(' '), false);
$mform->addGroup($radioarray, 'radioar', get_string('obpointtype', 'observation'), [' '], false);
$mform->setDefault('type', 0);

// Evidence file size.
Expand All @@ -70,7 +70,7 @@ public function definition() {

// Grading instructions.
$mform->addElement('editor', 'ins', get_string('gradinginstructions', 'observation'));
$mform->setType('ins', PARAM_TEXT);
$mform->setType('ins', PARAM_RAW); // Editors must be PARAM_RAW.
$mform->addRule('ins', get_string('required', 'observation'), 'required', null, 'client');

// Max / default grade selection.
Expand Down
10 changes: 5 additions & 5 deletions classes/form/pointmarking.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function definition() {

// Observation point information.
$instext = $prefill['ins'];
$insformat = $prefill['ins_f'];
$insformat = (int) $prefill['ins_f'];

$mform->addElement('static', 'instructions', get_string('gradinginstructions', 'observation'),
format_text($instext, $insformat));
Expand All @@ -68,19 +68,19 @@ public function definition() {
break;
// Pass/Fail type.
case \mod_observation\observation_manager::INPUT_PASSFAIL:
$radioarray = array();
$radioarray = [];
$radioarray[] = $mform->createElement('radio', 'response', '', get_string('pass', 'observation'), 'Pass');
$radioarray[] = $mform->createElement('radio', 'response', '', get_string('fail', 'observation'), 'Fail');
$mform->addGroup($radioarray, 'radioar', get_string('passfailtype', 'observation'), array(' '), false);
$mform->addGroup($radioarray, 'radioar', get_string('passfailtype', 'observation'), [' '], false);
$mform->setType('response', PARAM_TEXT);
$mform->addRule('radioar', get_string('required', 'observation'), 'required', null, 'client');
break;
case \mod_observation\observation_manager::INPUT_EVIDENCE:
// Image upload here.
$maxbytes = $prefill['file_size'];
$mform->addElement('filemanager', 'response', get_string('evidenceupload', 'observation'), null,
array('subdirs' => 0, 'maxbytes' => $maxbytes, 'areamaxbytes' => $maxbytes, 'maxfiles' => 1,
'accepted_types' => 'audio,video,image,document'));
['subdirs' => 0, 'maxbytes' => $maxbytes, 'areamaxbytes' => $maxbytes, 'maxfiles' => 1,
'accepted_types' => 'audio,video,image,document']);
$mform->setType('response', PARAM_INT);
$mform->addRule('response', get_string('required', 'observation'), 'required', null, 'client');
break;
Expand Down
4 changes: 2 additions & 2 deletions classes/form/startsession.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function definition() {
$finalusers[$u->id] = fullname($u);
}

$options = array(
$options = [
'multiple' => false,
);
];

$mform->addElement('text', 'observername', get_string('observer', 'observation'));
$mform->setDefault('observername', fullname($USER));
Expand Down
6 changes: 3 additions & 3 deletions classes/form/timesloteditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function definition() {

$intervalselector = [
$mform->createElement('text', 'interval_amount'),
$mform->createElement('select', 'interval_multiplier', '', $options)
$mform->createElement('select', 'interval_multiplier', '', $options),
];
$mform->addGroup($intervalselector, 'interval_select_group', get_string('repeatevery', 'observation'), null, false);
$mform->disabledIf('interval_select_group', 'enable_interval');
Expand All @@ -97,10 +97,10 @@ public function definition() {
foreach ($users as $user) {
$finalusers[$user->id] = fullname($user);
}
$options = array(
$options = [
'multiple' => false,
'noselectionstring' => get_string('allareas', 'search'),
);
];
$mform->addElement('header', 'selecting_observer', get_string('selecting_observer', 'observation'));
$mform->addElement('autocomplete', 'observer_id', get_string('teacher', 'observation'), $finalusers, $options);

Expand Down
2 changes: 1 addition & 1 deletion classes/form/upcomingfilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function definition() {
$intervalselector = [
$mform->createElement('text', 'interval_amount'),
$mform->createElement('select', 'interval_multiplier', '', $options),
$mform->createElement('submit', 'submit_btn', $buttontext)
$mform->createElement('submit', 'submit_btn', $buttontext),
];

// Interval selector block.
Expand Down
2 changes: 1 addition & 1 deletion classes/instructions.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class instructions {
* @return string formatted html to be displays encoded as a string
**/
public static function observation_instructions(?string $heading, ?string $bodytext, ?int $bodyformat, int $headinglevel = 3,
string $defaultmessage = null): string {
?string $defaultmessage = null): string {

global $OUTPUT;
// Can't set function values as default parameters, so do it here.
Expand Down
12 changes: 6 additions & 6 deletions classes/observation_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function delete_observation_point(int $observationid, int $obpoint
"obs_id = :obsid AND list_order > :listorder",
[
'obsid' => $observationid,
'listorder' => $currentpoint->list_order
'listorder' => $currentpoint->list_order,
]
);

Expand All @@ -225,7 +225,7 @@ public static function delete_observation_point(int $observationid, int $obpoint
'observation_points',
[
'id' => $pointabove->id,
'list_order' => $pointabove->list_order - 1
'list_order' => $pointabove->list_order - 1,
]
);
}
Expand Down Expand Up @@ -290,7 +290,7 @@ public static function reorder_observation_point(int $observationid, int $obpoin
$DB->update_record('observation_points',
[
'id' => $targetpoint->id,
'list_order' => $newordering
'list_order' => $newordering,
]);

// Reduce the direction to a unit vector (e.g. 5 -> 1 and -5 -> -1).
Expand All @@ -301,7 +301,7 @@ public static function reorder_observation_point(int $observationid, int $obpoin
$DB->update_record('observation_points',
[
'id' => $e->id,
'list_order' => $e->list_order - $reductionamount
'list_order' => $e->list_order - $reductionamount,
]);
}, $affectedpoints);

Expand Down Expand Up @@ -368,7 +368,7 @@ public static function submit_point_response(int $sessionid, int $pointid, $data
'grade_given' => $data->grade_given,
'response' => $data->response,
'ex_comment' => $data->ex_comment,
'timemodified' => time()
'timemodified' => time(),
];

if ($existingresponse === false) {
Expand Down Expand Up @@ -447,7 +447,7 @@ public static function format_points_and_responses($observationid, $sessionid) {
$item->title,
$item->response,
$item->grade_given,
$item->ex_comment
$item->ex_comment,
];
}, $pointsandresponses);

Expand Down
14 changes: 7 additions & 7 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class provider implements
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {

$collection->add_subsystem_link(
'core_files',
Expand All @@ -75,7 +75,7 @@ public static function get_metadata(collection $collection) : collection {
'response' => 'privacy:metadata:observation_point_responses:response',
'ex_comment' => 'privacy:metadata:observation_point_responses:ex_comment',
'timecreated' => 'privacy:metadata:observation_point_responses:timecreated',
'timemodified' => 'privacy:metadata:observation_point_responses:timemodified'
'timemodified' => 'privacy:metadata:observation_point_responses:timemodified',
],
'privacy:metadata:observation_point_responses'
);
Expand Down Expand Up @@ -113,7 +113,7 @@ public static function get_metadata(collection $collection) : collection {
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
$contextlist = new contextlist();

$params = [
Expand Down Expand Up @@ -208,7 +208,7 @@ public static function export_user_data(approved_contextlist $contextlist) {
// Get all timeslot records where the user is a part of them.
$timeslots = $DB->get_records_select('observation_timeslots', 'observer_id = :userid1 OR observee_id = :userid2', [
'userid1' => $userid,
'userid2' => $userid
'userid2' => $userid,
]);

$data->timeslots = $timeslots;
Expand Down Expand Up @@ -249,7 +249,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
// Delete all timeslot records where the user is a part of them.
$DB->delete_records_select('observation_timeslots', 'observer_id = :userid1 OR observee_id = :userid2', [
'userid1' => $userid,
'userid2' => $userid
'userid2' => $userid,
]);
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ public static function delete_data_for_users(approved_userlist $userlist) {
// Delete all timeslot records where the user is a part of them.
$DB->delete_records_select('observation_timeslots', 'observer_id = :userid1 OR observee_id = :userid2', [
'userid1' => $userid,
'userid2' => $userid
'userid2' => $userid,
]);
}
}
Expand All @@ -301,7 +301,7 @@ public static function delete_data_for_users(approved_userlist $userlist) {
*
* @param context $context The specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context (\context $context) {
public static function delete_data_for_all_users_in_context(\context $context) {
global $DB;

if ($context->contextlevel != CONTEXT_MODULE) {
Expand Down
10 changes: 5 additions & 5 deletions classes/session_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function start_session(int $obsid, int $observerid, int $observeei
'observee_id' => $observeeid,
'observer_id' => $observerid,
'state' => self::SESSION_INPROGRESS,
'start_time' => time()
'start_time' => time(),
];

return $DB->insert_record('observation_sessions', $data, true);
Expand All @@ -116,7 +116,7 @@ public static function get_session_info(int $sessionid) {
'ex_comment' => $sessiondata->ex_comment,
'state' => $sessiondata->state,
'observee' => $sessiondata->observee_id,
'observer' => $sessiondata->observer_id
'observer' => $sessiondata->observer_id,
];
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public static function calculate_grade(int $sessionid) {

return [
'total' => array_sum($givengrades),
'max' => array_sum($maxgrades)
'max' => array_sum($maxgrades),
];
}

Expand Down Expand Up @@ -275,7 +275,7 @@ public static function update_session_grade(int $sessionid, int $gradegiven, int
'gradetype' => 1,
'grademax' => $maxgrade,
'grademin' => $mingrade,
'itemname' => $cm->name . ' - ' . get_string('gradeitemname', 'observation')
'itemname' => $cm->name . ' - ' . get_string('gradeitemname', 'observation'),
];

$grade = [
Expand All @@ -285,7 +285,7 @@ public static function update_session_grade(int $sessionid, int $gradegiven, int
'datesubmitted' => time(),
'dategraded' => time(),
'feedbackformat' => FORMAT_PLAIN,
'feedback' => $sessioninfo['ex_comment']
'feedback' => $sessioninfo['ex_comment'],
];

return \grade_update('mod/observation', $course->id, 'mod', 'observation', $obid, 0, $grade, $params);
Expand Down
2 changes: 1 addition & 1 deletion classes/table/notifications/notifications_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function notifications_table(int $observationid, int $userid, \moo
'fields' => 'obn.id AS id, time_before, start_time',
'from' => '{observation_notifications} obn LEFT JOIN {observation_timeslots} ot ON obn.timeslot_id = ot.id',
'where' => 'ot.observee_id = :userid AND ot.obs_id = :obsid',
'params' => ['userid' => $userid, 'obsid' => $observationid]
'params' => ['userid' => $userid, 'obsid' => $observationid],
];

return $table->out($table->pagesize, true);
Expand Down
4 changes: 2 additions & 2 deletions classes/table/notifications/notifications_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct(string $uniqueid, \moodle_url $callbackurl, int $per
$columns = [
'id',
'time_before',
'actions'
'actions',
];

$headers = [
get_string('id', 'observation'),
get_string('notifyon', 'observation'),
get_string('actions', 'observation')
get_string('actions', 'observation'),
];

$this->define_columns($columns);
Expand Down
2 changes: 1 addition & 1 deletion classes/table/timeslots/timeslots_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class timeslots_display {
'from' => '{observation_timeslots} ot
LEFT JOIN {user} u ON ot.observer_id = u.id
LEFT JOIN {user} o on ot.observee_id = o.id',
'where' => 'obs_id = :obsid'
'where' => 'obs_id = :obsid',
];

/**
Expand Down
Loading
Loading