]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15103 towards assignment dml conversion
authorskodak <skodak>
Thu, 5 Jun 2008 10:31:37 +0000 (10:31 +0000)
committerskodak <skodak>
Thu, 5 Jun 2008 10:31:37 +0000 (10:31 +0000)
mod/assignment/backuplib.php
mod/assignment/delete.php
mod/assignment/grade.php
mod/assignment/submissions.php
mod/assignment/upload.php
mod/assignment/view.php

index 747df2bb94a39efe9f76445e1fb6d272fcd31166..ce963d6e467f72bb76835ccdf727dd5e88f502f9 100644 (file)
 
     //This function executes all the backup procedure about this mod
     function assignment_backup_mods($bf,$preferences) {
-
-        global $CFG;
+        global $CFG, $DB;
 
         $status = true;
 
         //Iterate over assignment table
-        $assignments = get_records ("assignment","course",$preferences->backup_course,"id");
+        $assignments = $DB->get_records ("assignment", array("course"=>$preferences->backup_course),"id");
         if ($assignments) {
             foreach ($assignments as $assignment) {
                 if (backup_mod_selected($preferences,'assignment',$assignment->id)) {
     }
 
     function assignment_backup_one_mod($bf,$preferences,$assignment) {
-        
-        global $CFG;
+        global $CFG, $DB;
     
         if (is_numeric($assignment)) {
-            $assignment = get_record('assignment','id',$assignment);
+            $assignment = $DB->get_record('assignment', array('id'=>$assignment));
         }
     
         $status = true;
 
     //Backup assignment_submissions contents (executed from assignment_backup_mods)
     function backup_assignment_submissions ($bf,$preferences,$assignment) {
-
-        global $CFG;
+        global $CFG, $DB;
 
         $status = true;
 
-        $assignment_submissions = get_records("assignment_submissions","assignment",$assignment,"id");
+        $assignment_submissions = $DB->get_records("assignment_submissions", array("assignment"=>$assignment),"id");
         //If there is submissions
         if ($assignment_submissions) {
             //Write start tag
     //Backup assignment files because we've selected to backup user info
     //and files are user info's level
     function backup_assignment_files($bf,$preferences) {
-
-        global $CFG;
+        global $CFG, $DB;
        
         $status = true;
 
     } 
 
     function backup_assignment_files_instance($bf,$preferences,$instanceid) {
-
-        global $CFG;
+        global $CFG, $DB;
        
         $status = true;
 
     //Return a content encoded to support interactivities linking. Every module
     //should have its own. They are called automatically from the backup procedure.
     function assignment_encode_content_links ($content,$preferences) {
-
         global $CFG;
 
         $base = preg_quote($CFG->wwwroot,"/");
 
     //Returns an array of assignments id 
     function assignment_ids ($course) {
+        global $CFG, $DB;
 
-        global $CFG;
-
-        return get_records_sql ("SELECT a.id, a.course
-                                 FROM {$CFG->prefix}assignment a
-                                 WHERE a.course = '$course'");
+        return $DB->get_records_sql ("SELECT a.id, a.course
+                                        FROM {assignment} a
+                                       WHERE a.course = ?", array($course));
     }
     
     //Returns an array of assignment_submissions id
     function assignment_submission_ids_by_course ($course) {
+        global $CFG, $DB;
 
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.assignment
-                                 FROM {$CFG->prefix}assignment_submissions s,
-                                      {$CFG->prefix}assignment a
-                                 WHERE a.course = '$course' AND
-                                       s.assignment = a.id");
+        return $DB->get_records_sql ("SELECT s.id , s.assignment
+                                        FROM {assignment_submissions} s,
+                                             {assignment} a
+                                       WHERE a.course = ? AND
+                                             s.assignment = a.id", array($course));
     }
 
     //Returns an array of assignment_submissions id
     function assignment_submission_ids_by_instance ($instanceid) {
+        global $CFG, $DB;
 
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.assignment
-                                 FROM {$CFG->prefix}assignment_submissions s
-                                 WHERE s.assignment = $instanceid");
+        return $DB->get_records_sql ("SELECT s.id , s.assignment
+                                        FROM {assignment_submissions} s
+                                       WHERE s.assignment = ?", array($instanceid));
     }
 ?>
index c00668a097fea0e387ea0f296f861dd5662c4744..25b2cf090f5558d84950f67f678dfefae1bfe4dc 100644 (file)
             print_error('invalidcoursemodule');
         }
 
-        if (! $assignment = get_record('assignment', 'id', $cm->instance)) {
+        if (! $assignment = $DB->get_record('assignment', array('id'=>$cm->instance))) {
             print_error('invalidid', 'assignment');
         }
 
-        if (! $course = get_record('course', 'id', $assignment->course)) {
+        if (! $course = $DB->get_record('course', array('id'=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
     } else {
-        if (!$assignment = get_record('assignment', 'id', $a)) {
+        if (!$assignment = $DB->get_record('assignment', array('id'=>$a))) {
             print_error('invalidcoursemodule');
         }
-        if (! $course = get_record('course', 'id', $assignment->course)) {
+        if (! $course = $DB->get_record('course', array('id'=>$assignment->course))) {
             print_error('coursemisconf', 'assignement');
         }
         if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id, $course->id)) {
index dc8a6a42ceeb6aa1f35dd9bc8f0b13691becda79..4bb2cb313b26ecdefa94728c59f9532420e48f5d 100644 (file)
@@ -8,11 +8,11 @@
         print_error('invalidcoursemodule');
     }
 
-    if (! $assignment = get_record("assignment", "id", $cm->instance)) {
+    if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) {
         print_error('invalidid', 'assignment');
     }
 
-    if (! $course = get_record("course", "id", $assignment->course)) {
+    if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
         print_error('coursemisconf', 'assignment');
     }
 
index abf87994cb2bfc50fab285bdb4407773a0b8acde..953c3b448dde2e814e8ad130181571943fc37120 100644 (file)
             print_error('invalidcoursemodule');
         }
 
-        if (! $assignment = get_record("assignment", "id", $cm->instance)) {
+        if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) {
             print_error('invalidid', 'assignment');
         }
 
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
     } else {
-        if (!$assignment = get_record("assignment", "id", $a)) {
+        if (!$assignment = $DB->get_record("assignment", array("id"=>$a))) {
             print_error('invalidcoursemodule');
         }
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
index 0a0509fe529607f128e292d0383c3ccdaea3b9f6..2b4059c73cc8f9b2a6ea7a9d64623041c4daac00 100644 (file)
             print_error('invalidcoursemodule');
         }
 
-        if (! $assignment = get_record("assignment", "id", $cm->instance)) {
+        if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) {
             print_error('invalidid', 'assignment');
         }
 
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
     } else {
-        if (!$assignment = get_record("assignment", "id", $a)) {
+        if (!$assignment = $DB->get_record("assignment", array("id"=>$a))) {
             print_error('invalidcoursemodule');
         }
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('invalidid', 'assignment');
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
index 2499c98bae9568c52e55b2dec1467db0a42354bb..f12de92d52720a4a4315864c6f85ed38be15168d 100644 (file)
             print_error('invalidcoursemodule');
         }
 
-        if (! $assignment = get_record("assignment", "id", $cm->instance)) {
+        if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) {
             print_error('invalidid', 'assignment');
         }
 
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
     } else {
-        if (!$assignment = get_record("assignment", "id", $a)) {
+        if (!$assignment = $DB->get_record("assignment", array("id"=>$a))) {
             print_error('invalidid', 'assignment');
         }
-        if (! $course = get_record("course", "id", $assignment->course)) {
+        if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
             print_error('coursemisconf', 'assignment');
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {