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

Remove mysqlisms and hardcoded table prefixes #37

Open
wants to merge 1 commit into
base: Moodle_36
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions backup/moodle2/backup_coursework_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ class backup_coursework_activity_structure_step extends backup_activity_structur
protected function define_structure()
{
global $DB;

foreach(array('coursework_submissions',
'coursework_allocation_pairs',
'coursework_mod_set_members',
'coursework_sample_set_mbrs',
'coursework_extensions',
'coursework_person_deadlines') as $tablename)
{
$DB->execute("update {{$tablename}} set `allocatableuser`=0, `allocatablegroup`=0");
$DB->execute("update {{$tablename}} set `allocatableuser`=`allocatableid` where allocatabletype='user'");
$DB->execute("update {{$tablename}} set `allocatablegroup`=`allocatableid` where allocatabletype='group'");
$DB->execute("update {{$tablename}} set allocatableuser=0, allocatablegroup=0");
$DB->execute("update {{$tablename}} set allocatableuser=allocatableid where allocatabletype='user'");
$DB->execute("update {{$tablename}} set allocatablegroup=allocatableid where allocatabletype='group'");
}

$userinfo = $this->get_setting_value('userinfo');

$coursework=new backup_nested_element('coursework',array('id'),
array('formid',
'course',
Expand Down Expand Up @@ -316,7 +316,7 @@ protected function define_structure()
$coursework->add_child($allocation_configs);
//And sample members
$coursework->add_child($sample_members);

//And submissions are made up from individual submission instances
$submissions->add_child($submission);
//Submissions have multiple feedback items
Expand Down Expand Up @@ -377,30 +377,30 @@ protected function define_structure()

$allocation_config->set_source_table('coursework_allocation_config',
array('courseworkid'=>backup::VAR_PARENTID));

//Mark important foreign keys
$feedback->annotate_ids('user','assessorid');
$feedback->annotate_ids('user','lasteditedbyuser');
$feedback->annotate_ids('user','markernumber');

$submission->annotate_ids('user','userid');
$submission->annotate_ids('user','createdby');
$submission->annotate_ids('user','lastupdatedby');
$submission->annotate_ids('user','allocatableuser');
$submission->annotate_ids('user','allocatableuser');
$submission->annotate_ids('group','allocatablegroup');

$reminder->annotate_ids('user','userid');

$pair->annotate_ids('user','assessorid');
$pair->annotate_ids('user','allocatableuser');
$pair->annotate_ids('user','allocatableuser');
$pair->annotate_ids('group','allocatablegroup');

$allocation_config->annotate_ids('user','assessorid');

$modsetmember->annotate_ids('user','allocatableuser');
$modsetmember->annotate_ids('user','allocatableuser');
$modsetmember->annotate_ids('group','allocatablegroup');

$extension->annotate_ids('user','allocatableuser');
$extension->annotate_ids('user','allocatableuser');
$extension->annotate_ids('group','allocatablegroup');

$personal_deadline->annotate_ids('user','allocatableuser');
Expand All @@ -423,8 +423,8 @@ protected function define_structure()
$coursework->annotate_ids('grouping','grouping_id');

$coursework->set_source_table('coursework',array('id'=>backup::VAR_ACTIVITYID));
return $this->prepare_activity_structure($coursework);

return $this->prepare_activity_structure($coursework);

}
}
6 changes: 3 additions & 3 deletions classes/models/outstanding_marking.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ private function get_to_grade_agreed_grade_sampled_submissions($courseworkid) {
COUNT(a.id) AS ssmID FROM(
SELECT f.id AS fid, cs.id AS csid, cs.allocatableid ,ssm.id, COUNT(f.id) AS count_feedback,
cs.courseworkid
FROM mdl_coursework_submissions cs LEFT JOIN
mdl_coursework_feedbacks f ON f.submissionid= cs.id
LEFT JOIN `mdl_coursework_sample_set_mbrs` ssm
FROM {coursework_submissions} cs LEFT JOIN
{coursework_feedbacks} f ON f.submissionid= cs.id
LEFT JOIN {coursework_sample_set_mbrs} ssm
ON cs.courseworkid = ssm.courseworkid AND cs.allocatableid =ssm.allocatableid
WHERE cs.courseworkid = :courseworkid
GROUP BY cs.allocatableid, ssm.stage_identifier
Expand Down
4 changes: 2 additions & 2 deletions classes/warnings.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public function students_in_mutiple_grouos() {
} else {

$sql = "SELECT groups.id,groups.name
FROM mdl_groups groups
INNER JOIN mdl_groups_members gm
FROM {groups} groups
INNER JOIN {groups_members} gm
ON gm.groupid = groups.id
WHERE groups.courseid = :courseid
AND gm.userid = :userid";
Expand Down