[system] / trunk / wwmoodle / wwassignment4 / moodle / mod / wwassignment / backuplib.php Repository:
ViewVC logotype

Diff of /trunk/wwmoodle/wwassignment4/moodle/mod/wwassignment/backuplib.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5882 Revision 5883
1<?php //$Id: backuplib.php,v 1.2 2008-08-24 01:27:56 gage Exp $ 1<?php //$Id: backuplib.php,v 1.3 2008-08-24 03:03:32 gage Exp $
2 //This php script contains all the stuff to backup 2 //This php script contains all the stuff to backup
3 //wwassignment mods 3 //wwassignment mods
4 4
5 //This is the "graphical" structure of the assignment mod: 5 //This is the "graphical" structure of the assignment mod:
6 // 6 //
23 23
24 //This function executes all the backup procedure about this mod 24 //This function executes all the backup procedure about this mod
25 25
26 26
27 function wwassignment_backup_mods($bf,$preferences) { 27 function wwassignment_backup_mods($bf,$preferences) {
28 error_log("wwassignment_backup_mods"); 28 //error_log("wwassignment_backup_mods");
29 //error_log("preferences ".print_r($preferences,true)); 29 ////error_log("preferences ".print_r($preferences,true));
30 global $CFG; 30 global $CFG;
31 31
32 $status = true; 32 $status = true;
33 33
34 //Iterate over assignment table 34 //Iterate over assignment table
35 $wwassignments = get_records ("wwassignment","course",$preferences->backup_course); 35 $wwassignments = get_records ("wwassignment","course",$preferences->backup_course);
36 if ($wwassignments) { 36 if ($wwassignments) {
37 foreach ($wwassignments as $wwassignment) { 37 foreach ($wwassignments as $wwassignment) {
38 //error_log("backing up wwassignment ".$wwassignment->id); 38 ////error_log("backing up wwassignment ".$wwassignment->id);
39 if (backup_mod_selected($preferences,'wwassignment',$wwassignment->id)) { 39 if (backup_mod_selected($preferences,'wwassignment',$wwassignment->id)) {
40 $status = wwassignment_backup_one_mod($bf,$preferences,$wwassignment); 40 $status = wwassignment_backup_one_mod($bf,$preferences,$wwassignment);
41 // backup files happens in backup_one_mod now too. 41 // backup files happens in backup_one_mod now too.
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 46
47 47
48 error_log("end wwassignment_backup_mods"); 48 //error_log("end wwassignment_backup_mods");
49 return $status; 49 return $status;
50 } 50 }
51 51
52 function wwassignment_backup_one_mod($bf,$preferences,$wwassignment) { 52 function wwassignment_backup_one_mod($bf,$preferences,$wwassignment) {
53 error_log("wwassignment_backup_one_mod"); 53 //error_log("wwassignment_backup_one_mod");
54 //error_log("preferences ".print_r($preferences,true)); 54 ////error_log("preferences ".print_r($preferences,true));
55 global $CFG; 55 global $CFG;
56 global $BaCkUpWWassignment_bridge ; // hack to back up wwassignment_bridge table just once
57 56
58 if (is_numeric($wwassignment)) { 57 if (is_numeric($wwassignment)) {
59 $wwassignment = get_record('wwassignment','id',$wwassignment); 58 $wwassignment = get_record('wwassignment','id',$wwassignment);
60 } 59 }
61 60
75 74
76 //End mod 75 //End mod
77 $status =fwrite ($bf,end_tag("MOD",3,true)); 76 $status =fwrite ($bf,end_tag("MOD",3,true));
78 77
79 78
80 error_log("end wwassignment_one_backup_mod"); 79 //error_log("end wwassignment_one_backup_mod");
81 error_log("preferences ".print_r($preferences,true)); 80 //error_log("preferences ".print_r($preferences,true));
82 if ($status and !$BaCkUpWWassignment_bridge) { 81
83 $BaCkUpWWassignment_bridge = 1 ; // don't back it up again
84 $wwassignment_bridge =get_record("wwassignment_bridge","course",$preferences->backup_course);
85 error_log("writing wwassignment_bridge");
86 fwrite ($bf,start_tag("MOD",3,true));
87 //Print wwassignment_bridge data
88 fwrite ($bf,full_tag("ID",4,false,"66666"));
89 fwrite ($bf,full_tag("MODTYPE",4,false,"wwassignment"));
90 fwrite ($bf,full_tag("WEBWORK_COURSE",4,false,$wwassignment_bridge->webwork_course));
91 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$wwassignment_bridge->timemodified));
92 $status =fwrite ($bf,end_tag("MOD",3,true));
93 error_log("wwassignment_bridge backed up");
94 }
95 82
96 83
97 return $status; 84 return $status;
98 } 85 }
99 86
100 87
101 //Return an array of info (name,value) 88 //Return an array of info (name,value)
102 function wwassignment_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) { 89 function wwassignment_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
103 //error_log("wwassignment_check_backup_mods "); 90 ////error_log("wwassignment_check_backup_mods ");
104 //error_log("user_data ".print_r($user_data,true) ); 91 ////error_log("user_data ".print_r($user_data,true) );
105 //error_log("backup code ".print_r($backup_unique_code,true)); 92 ////error_log("backup code ".print_r($backup_unique_code,true));
106 //error_log("instance ".print_r($instance,true)); 93 ////error_log("instance ".print_r($instance,true));
107 $info=array(); 94 $info=array();
108 if (!empty($instances) && is_array($instances) && count($instances)) { 95 if (!empty($instances) && is_array($instances) && count($instances)) {
109 foreach ($instances as $id => $instance) { 96 foreach ($instances as $id => $instance) {
110 $info += wwassignment_check_backup_mods_instances($instance,$backup_unique_code); 97 $info += wwassignment_check_backup_mods_instances($instance,$backup_unique_code);
111 } 98 }
117 $info[0][1] = count($ids); 104 $info[0][1] = count($ids);
118 } else { 105 } else {
119 $info[0][1] = 0; 106 $info[0][1] = 0;
120 } 107 }
121 108
122 //error_log("end wwassignment_check_backup_mods"); 109 ////error_log("end wwassignment_check_backup_mods");
123 110
124 return $info; 111 return $info;
125 } 112 }
126 113
127 //Return an array of info (name,value) 114 //Return an array of info (name,value)
128 function wwassignment_check_backup_mods_instances($instance,$backup_unique_code) { 115 function wwassignment_check_backup_mods_instances($instance,$backup_unique_code) {
129 //error_log("wwassignment_check_backup_mods_instances "); 116 ////error_log("wwassignment_check_backup_mods_instances ");
130 //error_log("content ".print_r($content,true)); 117 ////error_log("content ".print_r($content,true));
131 //error_log("preferences ".print_r($preferences,true)); 118 ////error_log("preferences ".print_r($preferences,true));
132 119
133 $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>'; 120 $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
134 $info[$instance->id.'0'][1] = ''; 121 $info[$instance->id.'0'][1] = '';
135// if (!empty($instance->userdata)) { 122// if (!empty($instance->userdata)) {
136// $info[$instance->id.'1'][0] = get_string("submissions","assignment"); 123// $info[$instance->id.'1'][0] = get_string("submissions","assignment");
138// $info[$instance->id.'1'][1] = count($ids); 125// $info[$instance->id.'1'][1] = count($ids);
139// } else { 126// } else {
140// $info[$instance->id.'1'][1] = 0; 127// $info[$instance->id.'1'][1] = 0;
141// } 128// }
142// } 129// }
143 //error_log("end wwassignment_check_backup_mods_instances"); 130 ////error_log("end wwassignment_check_backup_mods_instances");
144 131
145 return $info; 132 return $info;
146 } 133 }
147// 134//
148// //Return a content encoded to support interactivities linking. Every module 135// //Return a content encoded to support interactivities linking. Every module
166 153
167 // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE 154 // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
168 155
169 //Returns an array of assignments id 156 //Returns an array of assignments id
170 function wwassignment_ids ($course) { 157 function wwassignment_ids ($course) {
171 //error_log("wwassignment_ids "); 158 ////error_log("wwassignment_ids ");
172 //error_log("course ".print_r($course,true)); 159 ////error_log("course ".print_r($course,true));
173 160
174 global $CFG; 161 global $CFG;
175 162
176 163
177 //error_log("end wwassignment_ids"); 164 ////error_log("end wwassignment_ids");
178 165
179 return get_records_sql ("SELECT a.id, a.course 166 return get_records_sql ("SELECT a.id, a.course
180 FROM {$CFG->prefix}wwassignment a 167 FROM {$CFG->prefix}wwassignment a
181 WHERE a.course = '$course'"); 168 WHERE a.course = '$course'");
182 } 169 }

Legend:
Removed from v.5882  
changed lines
  Added in v.5883

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9