backup question images that are stored inside the course and do not look for them...
authorroot <root@pegasus1.weizmann.ac.il>
Sat, 2 Apr 2011 10:48:30 +0000 (13:48 +0300)
committerroot <root@pegasus1.weizmann.ac.il>
Sat, 2 Apr 2011 10:48:30 +0000 (13:48 +0300)
question/backuplib.php

index 80c6396..17bad55 100644 (file)
                                  WHERE backup_code = '$backup_unique_code' AND
                                        table_name = 'question'");
     }
-    
+
     //Function for inserting question and category ids into db that are all called from
-    // quiz_check_backup_mods during execution of backup_check.html 
+    // quiz_check_backup_mods during execution of backup_check.html
 
 
     function question_insert_c_and_q_ids_for_course($coursecontext, $backup_unique_code){
                                        (backup_code, table_name, old_id, info)
                                        SELECT '$backup_unique_code', 'question', q.id, '" . sql_empty() . "'
                                        FROM {$CFG->prefix}question q, {$CFG->prefix}backup_ids bk
-                                       WHERE q.category = bk.old_id AND bk.table_name = 'question_categories' 
+                                       WHERE q.category = bk.old_id AND bk.table_name = 'question_categories'
                                        AND " . sql_compare_text('bk.info') . " = '$info'
                                        AND bk.backup_code = '$backup_unique_code'", false);
         return $status;
     }
-    
+
     function question_insert_c_and_q_ids_for_module($backup_unique_code, $course, $modulename, $instances){
         global $CFG;
         $status = true;
                                     AND c.contextlevel = ".CONTEXT_MODULE." AND cm.course = $course
                                     AND cm.instance IN (".implode(',',array_keys($instances)).")");
         }
-                                    
+
         if ($cmcontexts){
             $status = $status && execute_sql("INSERT INTO {$CFG->prefix}backup_ids
                                        (backup_code, table_name, old_id, info)
                 $inserturl->path = addslashes($url);
                 $status = $status && insert_record('backup_files', $inserturl);
             } else {
-                notify(get_string('linkedfiledoesntexist', 'question', $url));
+                //notify(get_string('linkedfiledoesntexist', 'question', $url)); //nadavkav 2.4.2011
+                if (file_exists($CFG->dataroot.'/'.$course.'/'.$url)){
+                  $inserturl = new object();
+                  $inserturl->backup_code = $backup_unique_code;
+                  $inserturl->file_type = 'course';
+                  $url = clean_param($url, PARAM_PATH);
+                  $inserturl->path = $course.'/'.addslashes($url);
+                  $status = $status && insert_record('backup_files', $inserturl);
+                } else {
+                  notify(get_string('linkedfiledoesntexist', 'question', $url));
+                }
             }
         }
         return $status;