Skip to content

Commit

Permalink
Merge pull request #12 from ucl-isd/CTP-3690-code-checker-2
Browse files Browse the repository at this point in the history
CTP-3690 automated code checker fixes
  • Loading branch information
aspark21 authored Sep 10, 2024
2 parents 5476e3c + 632b282 commit 45eb6f3
Show file tree
Hide file tree
Showing 190 changed files with 4,650 additions and 4,506 deletions.
24 changes: 12 additions & 12 deletions actions/ajax/datatable/grading.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@
$unallocated = optional_param('unallocated', false, PARAM_BOOL);

// Grading report display options.
$report_options = [];
$reportoptions = [];
if ($unallocated) {
$report_options['unallocated'] = true;
$reportoptions['unallocated'] = true;
}

$report_options['group'] = $group;
$report_options['perpage'] = $perpage;
$report_options['sortby'] = $sortby;
$report_options['sorthow'] = $sorthow;
$report_options['showsubmissiongrade'] = false;
$report_options['showgradinggrade'] = false;
$report_options['courseworkid'] = $courseworkid;
$report_options['mode'] = \mod_coursework\grading_report::$MODE_GET_REMAIN_RECORDS;
$reportoptions['group'] = $group;
$reportoptions['perpage'] = $perpage;
$reportoptions['sortby'] = $sortby;
$reportoptions['sorthow'] = $sorthow;
$reportoptions['showsubmissiongrade'] = false;
$reportoptions['showgradinggrade'] = false;
$reportoptions['courseworkid'] = $courseworkid;
$reportoptions['mode'] = \mod_coursework\grading_report::MODE_GET_REMAIN_RECORDS;

//$controller = new mod_coursework\controllers\grading_controller(['courseworkid' => $report_options, 'allocatableid' => $USER->id, 'allocatabletype' => $USER->id]);
$controller = new mod_coursework\controllers\grading_controller([]);
sleep(10);
$table_html = $controller->get_remain_rows_grading_table($report_options);
$tablehtml = $controller->get_remain_rows_grading_table($reportoptions);
if (ob_get_contents()) {
ob_end_clean();
}

echo $table_html;
echo $tablehtml;
20 changes: 10 additions & 10 deletions actions/ajax/deadline_extension/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
$extra_information_text = optional_param('text', '', PARAM_RAW);
$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$extrainformationtext = optional_param('text', '', PARAM_RAW);
$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
$params = array(
$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);

$params['id'] = $id;
$params['extra_information_text'] = $extra_information_text;
$params['extra_information_format'] = $extra_information_format;
$params['extended_deadline'] = strtotime($extended_deadline);
$params['pre_defined_reason'] = $pre_defined_reason;
$params['extra_information_text'] = $extrainformationtext;
$params['extra_information_format'] = $extrainformationformat;
$params['extended_deadline'] = strtotime($extendeddeadline);
$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;

Expand Down
20 changes: 10 additions & 10 deletions actions/ajax/deadline_extension/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
$extra_information_text = optional_param('text', '', PARAM_RAW);
$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$extrainformationtext = optional_param('text', '', PARAM_RAW);
$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
$params = array(
$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);

$params['id'] = $id;
$params['extra_information_text'] = $extra_information_text;
$params['extra_information_format'] = $extra_information_format;
$params['extended_deadline'] = strtotime($extended_deadline);
$params['pre_defined_reason'] = $pre_defined_reason;
$params['extra_information_text'] = $extrainformationtext;
$params['extra_information_format'] = $extrainformationformat;
$params['extended_deadline'] = strtotime($extendeddeadline);
$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;

Expand Down
20 changes: 10 additions & 10 deletions actions/ajax/deadline_extension/submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);
$requesttype = optional_param('requesttype', 'new', PARAM_ALPHANUMEXT);
$id = optional_param('id', 0, PARAM_INT);
$extra_information_text = optional_param('text', '', PARAM_RAW);
$extra_information_format = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extended_deadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$pre_defined_reason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$extrainformationtext = optional_param('text', '', PARAM_RAW);
$extrainformationformat = optional_param('format', 1, PARAM_ALPHANUMEXT);
$extendeddeadline = optional_param('extended_deadline', 0, PARAM_ALPHANUMEXT);
$predefinedreason = optional_param('pre_defined_reason', null, PARAM_ALPHANUMEXT);
$submissionid = optional_param('submissionid', 0, PARAM_INT);
$name = optional_param('name', 0, PARAM_ALPHANUMEXT);
$params = array(
$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);

$params['id'] = $id;
$params['extra_information_text'] = $extra_information_text;
$params['extra_information_format'] = $extra_information_format;
$params['extended_deadline'] = strtotime($extended_deadline);
$params['pre_defined_reason'] = $pre_defined_reason;
$params['extra_information_text'] = $extrainformationtext;
$params['extra_information_format'] = $extrainformationformat;
$params['extended_deadline'] = strtotime($extendeddeadline);
$params['pre_defined_reason'] = $predefinedreason;
$params['submissionid'] = $submissionid;
$params['name'] = $name;

Expand Down
67 changes: 34 additions & 33 deletions actions/allocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

$coursemoduleid = required_param('id', PARAM_INT);
$coursemodule = get_coursemodule_from_id('coursework', $coursemoduleid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
$coursework = $DB->get_record('coursework', array('id' => $coursemodule->instance), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $coursemodule->course], '*', MUST_EXIST);
$coursework = $DB->get_record('coursework', ['id' => $coursemodule->instance], '*', MUST_EXIST);
$coursework = coursework::find($coursework);
$formsavebutton = optional_param('save', 0, PARAM_BOOL);
$samplingformsavebutton = optional_param('save_sampling', 0, PARAM_BOOL);
Expand Down Expand Up @@ -83,7 +83,7 @@
require_capability('mod/coursework:allocate', $PAGE->context, null, true, "Can't allocate here - permission denied.");

$url = '/mod/coursework/actions/allocate.php';
$link = new \moodle_url($url, array('id' => $coursemoduleid));
$link = new \moodle_url($url, ['id' => $coursemoduleid]);
$PAGE->set_url($link);
$title = get_string('allocatefor', 'mod_coursework', $coursework->name);
$PAGE->set_title($title);
Expand All @@ -94,16 +94,17 @@
$PAGE->requires->js('/mod/coursework/loadingoverlay.min.js');

// Will set off the function that adds listeners for onclick/onchange etc.
$jsmodule = array(
$jsmodule = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/module.js',
'requires' => array('base',
'node-base')
'requires' => ['base', 'node-base'],
];
$PAGE->requires->js_init_call(
'M.mod_coursework.init_allocate_page',
['wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid],
false,
$jsmodule
);
$PAGE->requires->js_init_call('M.mod_coursework.init_allocate_page',
array('wwwroot' => $CFG->wwwroot, 'coursemoduleid' => $coursemoduleid),
false,
$jsmodule);

$PAGE->requires->string_for_js('sameassessorerror', 'coursework');

Expand Down Expand Up @@ -138,7 +139,7 @@
reset($deletemodsetrule);
$deleteruleid = key($deletemodsetrule); // Only one button can be clicked.
if (is_numeric($deleteruleid)) {
$DB->delete_records('coursework_mod_set_rules', array('id' => $deleteruleid));
$DB->delete_records('coursework_mod_set_rules', ['id' => $deleteruleid]);
}
}
}
Expand All @@ -162,66 +163,66 @@
/**
* @var mod_coursework_object_renderer $object_renderer
*/
$object_renderer = $PAGE->get_renderer('mod_coursework', 'object');
$objectrenderer = $PAGE->get_renderer('mod_coursework', 'object');
/**
* @var mod_coursework_page_renderer $page_renderer
*/
$page_renderer = $PAGE->get_renderer('mod_coursework', 'page');
$pagerenderer = $PAGE->get_renderer('mod_coursework', 'page');

$warnings = new \mod_coursework\warnings($coursework);

$percentage_allocation_not_complete = $warnings->percentage_allocations_not_complete();
$manual_allocation_not_complete = '';
$students_in_multiple_groups = '';
$percentageallocationnotcomplete = $warnings->percentage_allocations_not_complete();
$manualallocationnotcomplete = '';
$studentsinmultiplegroups = '';
if ($coursework->allocation_enabled()) {
$manual_allocation_not_complete = $warnings->manual_allocation_not_completed();
$manualallocationnotcomplete = $warnings->manual_allocation_not_completed();
if ($coursework->use_groups == 1 || $coursework->assessorallocationstrategy == 'group_assessor') {
$students_in_multiple_groups = $warnings->students_in_mutiple_grouos();
$studentsinmultiplegroups = $warnings->students_in_mutiple_grouos();
}
}

if ($formsavebutton && $percentage_allocation_not_complete == '' && $manual_allocation_not_complete == '') {
if ($formsavebutton && $percentageallocationnotcomplete == '' && $manualallocationnotcomplete == '') {
redirect($CFG->wwwroot.'/mod/coursework/view.php?id='.$coursemoduleid, get_string('changessaved', 'mod_coursework'));
} else if ($formsavebutton) {
redirect($PAGE->url);
}

echo $OUTPUT->header();
echo $percentage_allocation_not_complete;
echo $percentageallocationnotcomplete;
if ($coursework->allocation_enabled()) {
echo $manual_allocation_not_complete;
echo $students_in_multiple_groups;
echo $manualallocationnotcomplete;
echo $studentsinmultiplegroups;
}

// Add coursework id etc.
echo \html_writer::input_hidden_params($PAGE->url);

if ($coursework->sampling_enabled()) { // Do not delete yet - refactoring...
echo \html_writer::start_tag('form', array('id' => 'sampling_form',
'method' => 'post'));
echo \html_writer::start_tag('form', ['id' => 'sampling_form',
'method' => 'post']);
$samplesetwidget = $allocationsmanager->get_sampling_set_widget();
echo $object_renderer->render($samplesetwidget);
echo $objectrenderer->render($samplesetwidget);
echo html_writer::end_tag('form');
}

// Start form. The page has now been broken into two forms sampling section and allocation section
// Open form tag.
echo \html_writer::start_tag('form', array('id' => 'allocation_form',
'method' => 'post'));
echo \html_writer::start_tag('form', ['id' => 'allocation_form',
'method' => 'post']);

if ($coursework->allocation_enabled()) {
echo $object_renderer->render($allocationwidget);
echo $objectrenderer->render($allocationwidget);
}

// Spacer so that we can float the headers next to each other.
$attributes = array(
'class' => 'coursework_spacer'
);
$attributes = [
'class' => 'coursework_spacer',
];
echo html_writer::start_tag('div', $attributes);
echo html_writer::end_tag('div');

echo html_writer::tag('h3', get_string('assessormoderatorgrades', 'mod_coursework'));
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), array('class' => 'pininfo'));
echo html_writer::tag('div', get_string('pininfo', 'mod_coursework'), ['class' => 'pininfo']);

// Start the form with save button.
/*
Expand All @@ -232,7 +233,7 @@
echo html_writer::empty_tag('input', $attributes);
echo $OUTPUT->help_icon('savemanualallocations', 'mod_coursework');
*/
echo $object_renderer->render($allocationtable);
echo $objectrenderer->render($allocationtable);

echo html_writer::end_tag('form');

Expand Down
4 changes: 2 additions & 2 deletions actions/deadline_extensions/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT);
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);

$params = array(
$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
);
];
$url = '/mod/coursework/actions/deadline_extensions/create.php';
$link = new \moodle_url($url, $params);
$PAGE->set_url($link);
Expand Down
4 changes: 2 additions & 2 deletions actions/deadline_extensions/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

$id = required_param('id', PARAM_INT);

$params = array(
$params = [
'id' => $id,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->edit_deadline_extension();
4 changes: 2 additions & 2 deletions actions/deadline_extensions/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
$allocatableid = optional_param('allocatableid', $USER->id, PARAM_INT);
$allocatabletype = optional_param('allocatabletype', $USER->id, PARAM_ALPHANUMEXT);

$params = array(
$params = [
'courseworkid' => $courseworkid,
'allocatableid' => $allocatableid,
'allocatabletype' => $allocatabletype,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->new_deadline_extension();
4 changes: 2 additions & 2 deletions actions/deadline_extensions/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

$id = required_param('id', PARAM_INT);

$params = array(
$params = [
'id' => $id,
);
];
$controller = new mod_coursework\controllers\deadline_extensions_controller($params);
$controller->show_deadline_extension();
4 changes: 2 additions & 2 deletions actions/deadline_extensions/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

$id = required_param('id', PARAM_INT);

$params = array(
$params = [
'id' => $id,
);
];
$url = '/mod/coursework/actions/deadline_extensions/create.php';
$link = new \moodle_url($url, $params);
$PAGE->set_url($link);
Expand Down
8 changes: 4 additions & 4 deletions actions/feedbacks/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
$submissionid = required_param('submissionid', PARAM_INT);
$isfinalgrade = optional_param('isfinalgrade', 0, PARAM_INT);
$assessorid = optional_param('assessorid', $USER->id, PARAM_INT);
$stage_identifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
$stageidentifier = optional_param('stage_identifier', '', PARAM_ALPHANUMEXT);
$finalised = !!optional_param('submitbutton', 0, PARAM_TEXT);
$ajax = optional_param('ajax', 0, PARAM_INT);

$params = array(
$params = [
'submissionid' => $submissionid,
'isfinalgrade' => $isfinalgrade,
'assessorid' => $assessorid,
'stage_identifier' => $stage_identifier,
'stage_identifier' => $stageidentifier,
'finalised' => $finalised,
'ajax' => $ajax,
);
];

if ($ajax) {
$params['cell_type'] = required_param('cell_type', PARAM_TEXT);
Expand Down
6 changes: 3 additions & 3 deletions actions/feedbacks/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
$feedbackid = optional_param('feedbackid', 0, PARAM_INT);
$ajax = optional_param('ajax', 0, PARAM_INT);

$params = array(
$params = [
'feedbackid' => $feedbackid,
'ajax' => $ajax
);
'ajax' => $ajax,
];
$controller = new mod_coursework\controllers\feedback_controller($params);
$controller->edit_feedback();
Loading

0 comments on commit 45eb6f3

Please sign in to comment.