Skip to content

Commit

Permalink
CTP-3690 correct commit 16f5fa2 underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
watson8 committed Sep 3, 2024
1 parent 11da13d commit f72a8df
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 58 deletions.
2 changes: 1 addition & 1 deletion actions/ajax/datatable/grading.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$reportoptions['showsubmissiongrade'] = false;
$reportoptions['showgradinggrade'] = false;
$reportoptions['courseworkid'] = $courseworkid;
$reportoptions['mode'] = \mod_coursework\grading_report::$modegetremainrecords;
$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([]);
Expand Down
16 changes: 8 additions & 8 deletions classes/ability/rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class rule {

/**
* @param string $action
* @param string $class_name
* @param $rule_function
* @param string $classname
* @param $rulefunction
* @param bool $allow
*/
public function __construct($action, $classname, $rulefunction, $allow = true) {
$this->action = $action;
$this->class_name = $classname;
$this->rule_function = $rulefunction;
$this->classname = $classname;
$this->rulefunction = $rulefunction;
$this->allow = $allow;
}

Expand All @@ -81,7 +81,7 @@ public function matches($action, $object) {
* @return bool
*/
public function allows($object) {
$rule = $this->rule_function;
$rule = $this->rulefunction;
return $rule($object) && $this->allow;
}

Expand All @@ -92,7 +92,7 @@ public function allows($object) {
* @return bool
*/
public function prevents($object) {
$rule = $this->rule_function;
$rule = $this->rulefunction;
return $rule($object) && !$this->allow;
}

Expand All @@ -109,10 +109,10 @@ protected function action_matches($action) {
* @return bool
*/
protected function class_matches($object) {
if (get_class($object) == $this->class_name) {
if (get_class($object) == $this->classname) {
return true;
}
if (get_parent_class($object) == $this->class_name) {
if (get_parent_class($object) == $this->classname) {
return true;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions classes/allocation/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public function auto_generate_sample_set() {

for ($stagenumber = 2; $stagenumber <= $this->get_coursework()->get_max_markers(); $stagenumber++) {

$stage = "assessor{$stagenumber}";
$stage = "assessor_{$stagenumber}";

$this->remove_unmarked_automatic_allocatables($stage);

Expand Down Expand Up @@ -353,7 +353,7 @@ public function auto_generate_sample_set() {
$sample->courseworkid = $this->coursework->id;
$sample->allocatableid = $allocatable->id;
$sample->allocatabletype = ($this->coursework->is_configured_to_have_group_submissions()) ? "group" : "user";
$sample->stage_identifier = "assessor{$stagenumber}";
$sample->stage_identifier = "assessor_{$stagenumber}";
$sample->selectiontype = "automatic";

// If this a manually selected allocatable check to see if the allocatable is already in the table
Expand All @@ -369,7 +369,7 @@ public function get_include_in_sample_set($stagenumber) {

global $DB;

$stage = "assessor{$stagenumber}";
$stage = "assessor_{$stagenumber}";

$sql = "SELECT allocatableid,
courseworkid,
Expand Down
6 changes: 3 additions & 3 deletions classes/export/csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class csv {
public function __construct($coursework, $csvcells, $filename) {
$this->coursework = $coursework;
$this->dateformat = '%a, %d %b %Y, %H:%M';
$this->csv_cells = $csvcells;
$this->csvcells = $csvcells;
$this->filename = $filename;
}

Expand All @@ -80,7 +80,7 @@ public function export() {

$csvdata = [];
// headers
$this->add_headers($this->csv_cells);
$this->add_headers($this->csvcells);

/**
* @var submission[] $submissions
Expand Down Expand Up @@ -246,7 +246,7 @@ public function add_csv_data($submission) {
$students = $submission->get_students();

foreach ($students as $student) {
$csvdata[] = $this->add_cells_to_array($submission, $student, $this->csv_cells);
$csvdata[] = $this->add_cells_to_array($submission, $student, $this->csvcells);
}

return $csvdata;
Expand Down
14 changes: 7 additions & 7 deletions classes/grading_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
*/
class grading_report {

//added static vars to determine in what manner the report is loaded
public static $modegetall = 1;
public static $modegetfirstrecords = 2;
public static $modegetremainrecords = 3;
// Added constants to determine in what manner the report is loaded.
const MODE_GET_ALL = 1;
const MODE_GET_FIRST_RECORDS = 2;
const MODE_GET_REMAIN_RECORDS = 3;

/**
* @var array rendering options
Expand Down Expand Up @@ -406,13 +406,13 @@ public function get_table_rows_for_page($rowcount = false) {

$counter = count($rows);
$this->realtotalrows = $counter;
$mode = empty($this->options['mode']) ? self::$modegetall : $this->options['mode'];
$mode = empty($this->options['mode']) ? self::MODE_GET_ALL : $this->options['mode'];
if ($mode != self::$modegetall) {
$perpage = $this->options['perpage'] ?? 10;
if ($counter > $perpage) {
if ($mode == self::$modegetfirstrecords) {
if ($mode == self::MODE_GET_FIRST_RECORDS) {
$rows = array_slice($rows, 0, $perpage);
} else if ($mode == self::$modegetremainrecords) {
} else if ($mode == self::MODE_GET_REMAIN_RECORDS) {
$rows = array_slice($rows, $perpage);
}
}
Expand Down
49 changes: 26 additions & 23 deletions classes/sample_set_rule/range_sample_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function add_form_elements($assessornumber=0) {
{coursework_sample_set_plugin} sp
WHERE sr.sample_set_plugin_id = sp.id
AND sr.courseworkid = {$this->coursework->id}
AND sr.stageidentifier = 'assessor{$assessornumber}'
AND sr.stage_identifier = 'assessor_{$assessornumber}'
AND sp.rulename = 'range_sample_type'";

$rulesfound = false;
Expand All @@ -77,9 +77,9 @@ public function add_form_elements($assessornumber=0) {
$html .= $this->range_elements($assessornumber, 0, false);
}

$html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), ['id' => "assessor{$assessornumber}addgradderule", 'class' => 'addgradderule sample_set_rule']);
$html .= html_writer::link('#', get_string('addgraderule', 'mod_coursework'), ['id' => "assessor_{$assessornumber}_addgradderule", 'class' => 'addgradderule sample_set_rule']);
$html .= " ";
$html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), ['id' => "assessor{$assessornumber}removegradderule", 'class' => 'removegradderule sample_set_rule']);
$html .= html_writer::link('#', get_string('removegraderule', 'mod_coursework'), ['id' => "assessor_{$assessornumber}_removegradderule", 'class' => 'removegradderule sample_set_rule']);

return $html;
}
Expand Down Expand Up @@ -118,10 +118,14 @@ public function range_elements($assessornumber, $sequence, $dbrecord=false) {
$ruleschecked = false;
}

$html = html_writer::start_tag('div', ['class' => "assessor{$assessornumber}graderules", 'id' => "assessor{$assessornumber}graderules{$sequence}"]);
$html = html_writer::start_tag(
'div',
['class' => "assessor_{$assessornumber}_grade_rules", 'id' => "assessor_{$assessornumber}_grade_rules_{$sequence}"]
);

$html .= html_writer::checkbox("assessor{$assessornumber}samplerules[]", 1, $ruleschecked, '',
['id' => "assessor{$assessornumber}samplerules{$sequence}", 'class' => "assessor{$assessornumber} rangegradecheckbox samplesetrule"]);
$html .= html_writer::checkbox(
"assessor_{$assessornumber}_samplerules[]", 1, $ruleschecked, '',
['id' => "assessor_{$assessornumber}_samplerules_{$sequence}", 'class' => "assessor_{$assessornumber} range_grade_checkbox sample_set_rule"]);

$gradescaletext = ($this->coursework->grade < 0) ? get_string('scale', 'mod_coursework') : get_string('grade', 'mod_coursework');
$gradescaleval = ($this->coursework->grade < 0) ? 'scale' : 'grade';
Expand All @@ -130,28 +134,28 @@ public function range_elements($assessornumber, $sequence, $dbrecord=false) {
$gradescaleval => $gradescaletext];

$html .= html_writer::select($options,
"assessor{$assessornumber}sampletype[]",
"assessor_{$assessornumber}_sampletype[]",
"",
$selectedtype,
['id' => "assessor{$assessornumber}sampletype{$sequence}", 'class' => "grade_type sample_set_rule"]);
['id' => "assessor_{$assessornumber}_sampletype_{$sequence}", 'class' => "grade_type sample_set_rule"]);

$html .= html_writer::label(get_string('from', 'mod_coursework'), 'assessortwo_samplefrom[0]');

$ruleoptions = (!empty($selectedtype) && array_key_exists('percentage', $selectedtype)) ? $percentageoptions : $scale; //change this into a ternary statement that

$html .= html_writer::select($ruleoptions,
"assessor{$assessornumber}samplefrom[]",
"assessor_{$assessornumber}_samplefrom[]",
"",
$selectedfrom,
['id' => "assessor{$assessornumber}samplefrom{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from"]);
['id' => "assessor_{$assessornumber}_samplefrom_{$sequence}", 'class' => " sample_set_rule range_drop_down range_samp_from"]);

$html .= html_writer::label(get_string('to', 'mod_coursework'), "assessor{$assessornumber}sampleto[0]");
$html .= html_writer::label(get_string('to', 'mod_coursework'), "assessor_{$assessornumber}_sampleto[0]");

$html .= html_writer::select(array_reverse($ruleoptions, true),
"assessor{$assessornumber}sampleto[]",
"assessor_{$assessornumber}_sampleto[]",
"",
$selectedto,
['id' => "assessor{$assessornumber}sampleto{$sequence}", 'class' => " sample_set_rule range_drop_down"]);
['id' => "assessor_{$assessornumber}_sampleto_{$sequence}", 'class' => " sample_set_rule range_drop_down"]);

$html .= html_writer::end_tag('div', '');

Expand Down Expand Up @@ -330,10 +334,10 @@ public function save_form_data($assessornumber=0, &$order=0) {

global $DB;

$samplerules = optional_param_array("assessor{$assessornumber}samplerules", false, PARAM_RAW);
$sampletype = optional_param_array("assessor{$assessornumber}sampletype", false, PARAM_RAW);
$samplefrom = optional_param_array("assessor{$assessornumber}samplefrom", false, PARAM_RAW);
$sampleto = optional_param_array("assessor{$assessornumber}sampleto", false, PARAM_RAW);
$samplerules = optional_param_array("assessor_{$assessornumber}_samplerules", false, PARAM_RAW);
$sampletype = optional_param_array("assessor_{$assessornumber}_sampletype", false, PARAM_RAW);
$samplefrom = optional_param_array("assessor_{$assessornumber}_samplefrom", false, PARAM_RAW);
$sampleto = optional_param_array("assessor_{$assessornumber}_sampleto", false, PARAM_RAW);

$sampleplugin = $DB->get_record('coursework_sample_set_plugin', ['rulename' => 'range_sample_type']);

Expand All @@ -348,7 +352,7 @@ public function save_form_data($assessornumber=0, &$order=0) {
$dbrecord->sample_set_plugin_id = $sampleplugin->id;
$dbrecord->courseworkid = $this->coursework->id;
$dbrecord->ruleorder = $order;
$dbrecord->stage_identifier = "assessor{$assessornumber}";
$dbrecord->stage_identifier = "assessor_{$assessornumber}";

$DB->insert_record("coursework_sample_set_rules", $dbrecord);
$order++;
Expand All @@ -361,7 +365,7 @@ public function adjust_sample_set($stagenumber, &$allocatables, &$manualsamplese

global $DB;

$stage = "assessor_".$stagenumber;
$stage = "assessor_" . $stagenumber;

$sql = "SELECT r.*,p.rulename
FROM {coursework_sample_set_plugin} p,
Expand Down Expand Up @@ -391,7 +395,6 @@ public function adjust_sample_set($stagenumber, &$allocatables, &$manualsamplese
&& isset($allocatables[$awf->allocatableid])) {
$autosampleset[$awf->allocatableid] = $allocatables[$awf->allocatableid];
}

}
}
}
Expand Down Expand Up @@ -454,9 +457,9 @@ private function get_allocatables_in_range($stage, $limit1, $limit2) {
// Note as things stand limit1 and limit2 can not be params as the type of the grade field (varchar)
//means the values are cast as strings

return $DB->get_records_sql($sql, ['courseworkid' => $this->coursework->id,
'stage' => $stage]);

return $DB->get_records_sql($sql,
['courseworkid' => $this->coursework->id, 'stage' => $stage]
);
}

}
28 changes: 15 additions & 13 deletions classes/sample_set_rule/total_sample_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function get_default_rule_order() {

}

public function add_form_elements($assessornumber=0) {
public function add_form_elements($assessornumber = 0) {

global $DB;

Expand All @@ -58,7 +58,7 @@ public function add_form_elements($assessornumber=0) {
{coursework_sample_set_plugin} sp
WHERE sr.sample_set_plugin_id = sp.id
AND sr.courseworkid = {$this->coursework->id}
AND sr.stageidentifier = 'assessor{$assessornumber}'
AND sr.stage_identifier = 'assessor_{$assessornumber}'
AND sp.rulename = 'total_sample_type'";

$selected = ($record = $DB->get_record_sql($sql)) ? [$record->upperlimit => $record->upperlimit] : false;
Expand All @@ -72,22 +72,24 @@ public function add_form_elements($assessornumber=0) {

$html = html_writer::start_div('sampletotal');

$html .= html_writer::checkbox("assessor{$assessornumber}sampletotalcheckbox", 1, $checked, get_string('topupto', 'mod_coursework'),
['id' => "assessor{$assessornumber}sampletotalcheckbox", 'class' => "assessor{$assessornumber} totalcheckbox samplesetrule"]);
$html .= html_writer::checkbox(
"assessor_{$assessornumber}_sampletotal_checkbox", 1, $checked, get_string('topupto', 'mod_coursework'),
['id' => "assessor_{$assessornumber}_sampletotal_checkbox", 'class' => "assessor{$assessornumber} totalcheckbox samplesetrule"]);

$html .= html_writer::select($percentageoptions,
"assessor{$assessornumber}sampletotal",
$html .= html_writer::select(
$percentageoptions,
"assessor_{$assessornumber}_sampletotal",
"",
$selected,
['id' => "assessor{$assessornumber}sampletotal", 'class' => " sample_set_rule"]);
['id' => "assessor_{$assessornumber}_sampletotal", 'class' => " sample_set_rule"]);
$html .= html_writer::label(get_string('ofallstudents', 'mod_coursework'), 'assessortwo_sampletotal[]');

$html .= html_writer::end_div();

return $html;
}

public function add_form_elements_js($assessornumber=0) {
public function add_form_elements_js($assessornumber = 0) {

$jsscript = "
Expand All @@ -113,11 +115,11 @@ public function add_form_elements_js($assessornumber=0) {

}

function save_form_data($assessornumber=0, &$order=0) {
function save_form_data($assessornumber = 0, &$order = 0) {
global $DB;

$totalcheckbox = optional_param("assessor{$assessornumber}sampletotalcheckbox", false, PARAM_INT);
$sampletotal = optional_param("assessor{$assessornumber}sampletotal", false, PARAM_INT);
$totalcheckbox = optional_param("assessor_{$assessornumber}_sampletotal_checkbox", false, PARAM_INT);
$sampletotal = optional_param("assessor_{$assessornumber}_sampletotal", false, PARAM_INT);

if ($totalcheckbox) {

Expand All @@ -128,7 +130,7 @@ function save_form_data($assessornumber=0, &$order=0) {
$dbrecord->sample_set_plugin_id = 2; // TODO: THIS SHOULD NOT BE HARD CODED - AF
$dbrecord->courseworkid = $this->coursework->id;
$dbrecord->ruleorder = $order;
$dbrecord->stage_identifier = "assessor{$assessornumber}";
$dbrecord->stage_identifier = "assessor_{$assessornumber}";

$DB->insert_record('coursework_sample_set_rules', $dbrecord);
}
Expand All @@ -146,7 +148,7 @@ public function adjust_sample_set($stagenumber, &$allocatables, &$manualsamplese

global $DB;

$stage = "assessor_".$stagenumber;
$stage = "assessor_" . $stagenumber;

$sql = "SELECT r.*,p.rulename
FROM {coursework_sample_set_plugin} p,
Expand Down

0 comments on commit f72a8df

Please sign in to comment.