Skip to content

Commit

Permalink
codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe committed Mar 6, 2024
1 parent 3814171 commit 645f156
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
20 changes: 11 additions & 9 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,21 @@ function xmldb_ratingallocate_upgrade($oldversion) {

// Define fields teamvote and teamvotegroupingid to be added to ratingallocate.
$table = new xmldb_table('ratingallocate');
$field_teamvote = new xmldb_field('teamvote', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
$field_teamvotegroupingid = new xmldb_field('teamvotegroupingid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$field_preventvotenotingroup = new xmldb_field('preventvotenotingroup', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
$fieldteamvote = new xmldb_field('teamvote', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
$fieldteamvotegroupingid = new xmldb_field('teamvotegroupingid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$fieldpreventvotenotingroup = new xmldb_field(
'preventvotenotingroup', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'
);

// Conditionally launch add fields to ratingallocate table.
if (!$dbman->field_exists($table, $field_teamvote)) {
$dbman->add_field($table, $field_teamvote);
if (!$dbman->field_exists($table, $fieldteamvote)) {
$dbman->add_field($table, $fieldteamvote);
}
if (!$dbman->field_exists($table, $field_teamvotegroupingid)) {
$dbman->add_field($table, $field_teamvotegroupingid);
if (!$dbman->field_exists($table, $fieldteamvotegroupingid)) {
$dbman->add_field($table, $fieldteamvotegroupingid);
}
if (!$dbman->field_exists($table, $field_preventvotenotingroup)) {
$dbman->add_field($table, $field_preventvotenotingroup);
if (!$dbman->field_exists($table, $fieldpreventvotenotingroup)) {
$dbman->add_field($table, $fieldpreventvotenotingroup);
}

// Define field groupid to be added to ratingallocate_ratings.
Expand Down
2 changes: 1 addition & 1 deletion lang/en/ratingallocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
$string['teamvote'] = 'Students rate in groups';
$string['teamvote_help'] = 'If enabled, students will be divided into groups based on the default set of groups or a custom grouping. A group rating will count for all group members.';
$string['teamvotegroupingid'] = 'Grouping for student groups';
$string['teamvotegroupingid_help'] = 'This is the grouping that the assignment will use to find groups for student groups. If not set, the default set of groups will be used.';
$string['teamvotegroupingid_help'] = 'This is the grouping that the activity will use to find groups for student groups. If not set, the default set of groups will be used.';
$string['teamvote_altered_after_preferences'] = 'Group Voting settings cannot be changed after preferences were submitted';
$string['preventvotenotingroup'] = 'Require group to vote';
$string['preventvotenotingroup_help'] = 'If enabled, users who are not members of a group will be unable to give a rating.';
Expand Down
7 changes: 3 additions & 4 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ public function get_teamvote_goups() {
$usersnogroup = array_diff($this->get_raters_in_course(), groups_get_grouping_members($groupingid));

$groupdata = new stdClass();
$groupdata->courseid =$this->course->id;
$groupdata->courseid = $this->course->id;
$groupdata->idnumber = $this->ratingallocateid;
$groupdata->name = 'delete after algorithm run';

Expand All @@ -1319,7 +1319,6 @@ public function get_teamvote_goups() {
WHERE g.groupingid = :groupingid
GROUP BY groupid';


// Return array should have the form groupid => membercount.
$groups = array_map(function ($record) {
return $record->members;
Expand Down Expand Up @@ -1771,7 +1770,7 @@ public function delete_ratings_of_user($userid) {
$choices = $this->get_choices();

$teamvote = ($DB->get_field('ratingallocate', 'teamvote', ['id' => $this->ratingallocateid]) == 1);
if ($teamvote && $votegroup=$this->get_vote_group($userid)) {
if ($teamvote && $votegroup = $this->get_vote_group($userid)) {

// If teamvote is enabled, delete ratings for this group.
foreach ($choices as $id => $choice) {
Expand Down Expand Up @@ -1822,7 +1821,7 @@ public function save_ratings_to_db($userid, array $data) {
try {

$teamvote = ($DB->get_field('ratingallocate', 'teamvote', ['id' => $this->ratingallocateid]) == 1);
if ($teamvote && $votegroup=$this->get_vote_group($userid)) {
if ($teamvote && $votegroup = $this->get_vote_group($userid)) {
$votegroupid = $votegroup->id;
$ratingexists = array(
'groupid' => $votegroupid
Expand Down
6 changes: 3 additions & 3 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function definition() {
$mform->addElement('static', self::STRATEGY_OPTIONS_PLACEHOLDER . '[' . $strategy . ']', '', '');
}

// Add settings for voting in groups
// Add settings for voting in groups.
$mform->addElement('header', 'groupvotesettings', get_string('groupvotesettings', RATINGALLOCATE_MOD_NAME));

$name = get_string('teamvote', RATINGALLOCATE_MOD_NAME);
Expand Down Expand Up @@ -169,7 +169,7 @@ public function definition() {
$mform->addHelpButton('teamvotegroupingid', 'teamvotegroupingid', RATINGALLOCATE_MOD_NAME);
$mform->hideIf('teamvotegroupingid', 'teamvote', 'eq', 0);
if ($disablestrategy) {
$mform->freeze('teamsubmissiongroupingid');
$mform->freeze('teamvotegroupingid');
}

// Add standard elements, common to all modules.
Expand Down Expand Up @@ -314,7 +314,7 @@ public function validation($data, $files) {
if ($ratingallocate->ratingallocate->dbrecord->strategy !== $data['strategy']) {
$errors['strategy'] = get_string('strategy_altered_after_preferences', self::MOD_NAME);
}
if($ratingallocate->ratingallocate->dbrecord->teamvote !== $data['teamvote']) {
if ($ratingallocate->ratingallocate->dbrecord->teamvote !== $data['teamvote']) {
$errors['teamvote'] = get_string('teamvote_altered_after_preferences', self::MOD_NAME);
}
}
Expand Down
2 changes: 0 additions & 2 deletions solver/ford-fulkerson-koegel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class solver_ford_fulkerson extends distributor {
*/
public function compute_distribution($choicerecords, $ratings, $usercount, $teamvote) {



$groupdata = array();
foreach ($choicerecords as $record) {
$groupdata[$record->id] = $record;
Expand Down
4 changes: 2 additions & 2 deletions solver/solver-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function distribute_users(\ratingallocate $ratingallocate) {
$userdistributions[$choiceid] = array_merge($userids);
}

// We have to delete the provisionally groups containing only one user
// We have to delete the provisionally groups containing only one user.
$ratingallocate->delete_groups_for_usersnogroup($teamvote);

}
Expand Down Expand Up @@ -360,7 +360,7 @@ protected function augment_flow($path, $teamvote=false, $toteamid=null) {
$space = 1;
} else {
// If teamvote is enabled, reduce its space by amount of groupmembers.
$space = $teamvote[$toteamid[$path[$i+1]]];
$space = $teamvote[$toteamid[$path[$i + 1]]];
}

if ($i == 1 && $edge->space > $space) {
Expand Down

0 comments on commit 645f156

Please sign in to comment.