MDL-14889 - just removed the field count. I isn't more needed.

additionaly fixed some notice messages on restore.lib
This commit is contained in:
agrabs
2008-05-18 10:37:48 +00:00
parent b75953148d
commit 239ba4ee76
6 changed files with 162 additions and 151 deletions
-1
View File
@@ -162,7 +162,6 @@
fwrite ($bf,full_tag("USERID",6,false,$feedbacktracking->userid));
fwrite ($bf,full_tag("FEEDBACK",6,false,$feedbacktracking->feedback));
fwrite ($bf,full_tag("COMPLETED",6,false,$feedbacktracking->completed));
fwrite ($bf,full_tag("COUNT",6,false,$feedbacktracking->count));
//End completed
$status =fwrite ($bf,end_tag("TRACKING",5,true));
+5 -6
View File
@@ -194,12 +194,11 @@
feedback_send_email_anonym($cm, $feedback, $course, $userid);
}
//tracking the submit
$multiple_count = null;
$multiple_count->userid = $USER->id;
$multiple_count->feedback = $feedback->id;
$multiple_count->completed = $new_completed_id;
$multiple_count->count = 1;
insert_record('feedback_tracking', $multiple_count);
$tracking = null;
$tracking->userid = $USER->id;
$tracking->feedback = $feedback->id;
$tracking->completed = $new_completed_id;
insert_record('feedback_tracking', $tracking);
unset($SESSION->feedback->is_started);
}else {
+1 -2
View File
@@ -132,8 +132,7 @@
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="feedback"/>
<FIELD NAME="feedback" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="completed"/>
<FIELD NAME="completed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="feedback" NEXT="tmp_completed"/>
<FIELD NAME="tmp_completed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="completed" NEXT="count"/>
<FIELD NAME="count" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="tmp_completed"/>
<FIELD NAME="tmp_completed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="completed"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for feedback_tracking" NEXT="feedback"/>
+7
View File
@@ -219,6 +219,13 @@ function xmldb_feedback_upgrade($oldversion=0) {
/// Launch add field2
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2008050105) {
//field count is not more needed
$table = new XMLDBTable('feedback_tracking');
$field = new XMLDBField('count');
$result = $result && $dbman->drop_field($table, $field);
}
return $result;
}
+148 -141
View File
@@ -112,162 +112,169 @@
if ($newid) {
//Now, build the feedback_item record structure
$items = $info['MOD']['#']['ITEMS']['0']['#']['ITEM'];
for($i = 0; $i < sizeof($items); $i++) {
$item_info = $items[$i];
$item->feedback = $newid;
$item->template = 0;
$item->name = backup_todb($item_info['#']['NAME']['0']['#']);
$item->presentation = backup_todb($item_info['#']['PRESENTATION']['0']['#']);
$item->presentation = str_replace("\n", '', $item->presentation);
if($version >= 1) {
$item->typ = backup_todb($item_info['#']['TYP']['0']['#']);
$item->hasvalue = backup_todb($item_info['#']['HASVALUE']['0']['#']);
switch($item->typ) {
case 'radio':
$item->typ = 'multichoice';
$item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'check':
$item->typ = 'multichoice';
$item->presentation = 'c'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'dropdown':
$item->typ = 'multichoice';
$item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'radiorated':
$item->typ = 'multichoicerated';
$item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'dropdownrated':
$item->typ = 'multichoicerated';
$item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
if(isset($info['MOD']['#']['ITEMS']['0']['#']['ITEM'])) {
$items = $info['MOD']['#']['ITEMS']['0']['#']['ITEM'];
for($i = 0; $i < sizeof($items); $i++) {
$item_info = $items[$i];
$item->feedback = $newid;
$item->template = 0;
$item->name = backup_todb($item_info['#']['NAME']['0']['#']);
$item->presentation = backup_todb($item_info['#']['PRESENTATION']['0']['#']);
$item->presentation = str_replace("\n", '', $item->presentation);
if($version >= 1) {
$item->typ = backup_todb($item_info['#']['TYP']['0']['#']);
$item->hasvalue = backup_todb($item_info['#']['HASVALUE']['0']['#']);
switch($item->typ) {
case 'radio':
$item->typ = 'multichoice';
$item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'check':
$item->typ = 'multichoice';
$item->presentation = 'c'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'dropdown':
$item->typ = 'multichoice';
$item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'radiorated':
$item->typ = 'multichoicerated';
$item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
case 'dropdownrated':
$item->typ = 'multichoicerated';
$item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
break;
}
} else {
$oldtyp = intval(backup_todb($item_info['#']['TYP']['0']['#']));
switch($oldtyp) {
case 0:
$item->typ = 'label';
$item->hasvalue = 0;
break;
case 1:
$item->typ = 'textfield';
$item->hasvalue = 1;
break;
case 2:
$item->typ = 'textarea';
$item->hasvalue = 1;
break;
case 3:
$item->typ = 'radio';
$item->hasvalue = 1;
break;
case 4:
$item->typ = 'check';
$item->hasvalue = 1;
break;
case 5:
$item->typ = 'dropdown';
$item->hasvalue = 1;
break;
}
}
} else {
$oldtyp = intval(backup_todb($item_info['#']['TYP']['0']['#']));
switch($oldtyp) {
case 0:
$item->typ = 'label';
$item->hasvalue = 0;
break;
case 1:
$item->typ = 'textfield';
$item->hasvalue = 1;
break;
case 2:
$item->typ = 'textarea';
$item->hasvalue = 1;
break;
case 3:
$item->typ = 'radio';
$item->hasvalue = 1;
break;
case 4:
$item->typ = 'check';
$item->hasvalue = 1;
break;
case 5:
$item->typ = 'dropdown';
$item->hasvalue = 1;
break;
}
}
$item->position = backup_todb($item_info['#']['POSITION']['0']['#']);
$item->required = backup_todb($item_info['#']['REQUIRED']['0']['#']);
//put this new item into the database
$newitemid = insert_record('feedback_item', $item);
$item->position = backup_todb($item_info['#']['POSITION']['0']['#']);
$item->required = backup_todb($item_info['#']['REQUIRED']['0']['#']);
//put this new item into the database
$newitemid = insert_record('feedback_item', $item);
//Now check if want to restore user data and do it.
if ($restore_userdata) {
$values = $item_info['#']['FBVALUES']['0']['#']['FBVALUE'];
for($ii = 0; $ii < sizeof($values); $ii++) {
$value_info = $values[$ii];
$value = new object();
$value->id = '';
$value->item = $newitemid;
$value->completed = 0;
$value->tmp_completed = backup_todb($value_info['#']['COMPLETED']['0']['#']);
$value->value = backup_todb($value_info['#']['VAL']['0']['#']);
$value->value = addslashes($value->value);
$value->course_id = backup_todb($value_info['#']['COURSE_ID']['0']['#']);
//put this new value into the database
$newvalueid = insert_record('feedback_value', $value);
$value->id = $newvalueid;
// $allValues[] = $value;
//Now check if want to restore user data and do it.
if ($restore_userdata) {
if(isset($item_info['#']['FBVALUES']['0']['#']['FBVALUE'])) {
$values = $item_info['#']['FBVALUES']['0']['#']['FBVALUE'];
for($ii = 0; $ii < sizeof($values); $ii++) {
$value_info = $values[$ii];
$value = new object();
$value->id = '';
$value->item = $newitemid;
$value->completed = 0;
$value->tmp_completed = backup_todb($value_info['#']['COMPLETED']['0']['#']);
$value->value = backup_todb($value_info['#']['VAL']['0']['#']);
$value->value = addslashes($value->value);
$value->course_id = backup_todb($value_info['#']['COURSE_ID']['0']['#']);
//put this new value into the database
$newvalueid = insert_record('feedback_value', $value);
$value->id = $newvalueid;
// $allValues[] = $value;
}
}
}
}
}
//Now check if want to restore user data again and do it.
if ($restore_userdata) {
//restore tracking-data
$trackings = $info['MOD']['#']['TRACKINGS']['0']['#']['TRACKING'];
for($i = 0; $i < sizeof($trackings); $i++) {
$tracking_info = $trackings[$i];
$tracking = new object();
$tracking->id = '';
$tracking->userid = backup_todb($tracking_info['#']['USERID']['0']['#']); //have to change later
$tracking->feedback = $newid;
$tracking->completed = backup_todb($tracking_info['#']['COMPLETED']['0']['#']); //have to change later
$tracking->count = backup_todb($tracking_info['#']['COUNT']['0']['#']);
if($tracking->userid > 0) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$tracking->userid);
if ($user) {
$tracking->userid = $user->new_id;
if(isset($info['MOD']['#']['TRACKINGS']['0']['#']['TRACKING'])) {
$trackings = $info['MOD']['#']['TRACKINGS']['0']['#']['TRACKING'];
for($i = 0; $i < sizeof($trackings); $i++) {
$tracking_info = $trackings[$i];
$tracking = new object();
$tracking->id = '';
$tracking->userid = backup_todb($tracking_info['#']['USERID']['0']['#']); //have to change later
$tracking->feedback = $newid;
$tracking->completed = backup_todb($tracking_info['#']['COMPLETED']['0']['#']); //have to change later
if($tracking->userid > 0) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$tracking->userid);
if ($user) {
$tracking->userid = $user->new_id;
}
}
//save the tracking
$newtrackingid = insert_record('feedback_tracking', $tracking);
$tracking->id = $newtrackingid;
// $allTrackings[] = $tracking;
}
//save the tracking
$newtrackingid = insert_record('feedback_tracking', $tracking);
$tracking->id = $newtrackingid;
// $allTrackings[] = $tracking;
}
//restore completeds
$completeds = $info['MOD']['#']['COMPLETEDS']['0']['#']['COMPLETED'];
for($i = 0; $i < sizeof($completeds); $i++) {
$completed_info = $completeds[$i];
$completed = new object();
$completed->feedback = $newid;
$completed->userid = backup_todb($completed_info['#']['USERID']['0']['#']);
$completed->timemodified = backup_todb($completed_info['#']['TIMEMODIFIED']['0']['#']);
$completed->random_response = backup_todb($completed_info['#']['RANDOMRESPONSE']['0']['#']);
if(!$anonymous_response = backup_todb($completed_info['#']['ANONYMOUSRESPONSE']['0']['#'])) {
$anonymous_response = 1;
}
$completed->anonymous_response = $anonymous_response;
if($completed->userid > 0) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$completed->userid);
if ($user) {
$completed->userid = $user->new_id;
if(isset($info['MOD']['#']['COMPLETEDS']['0']['#']['COMPLETED'])) {
$completeds = $info['MOD']['#']['COMPLETEDS']['0']['#']['COMPLETED'];
for($i = 0; $i < sizeof($completeds); $i++) {
$completed_info = $completeds[$i];
$completed = new object();
$completed->feedback = $newid;
$completed->userid = backup_todb($completed_info['#']['USERID']['0']['#']);
$completed->timemodified = backup_todb($completed_info['#']['TIMEMODIFIED']['0']['#']);
$completed->random_response = backup_todb($completed_info['#']['RANDOMRESPONSE']['0']['#']);
if(!$anonymous_response = backup_todb($completed_info['#']['ANONYMOUSRESPONSE']['0']['#'])) {
$anonymous_response = 1;
}
}
//later this have to be changed
$oldcompletedid = backup_todb($completed_info['#']['ID']['0']['#']);
//save the completed
$newcompletedid = insert_record('feedback_completed', $completed);
//the newcompletedid have to be changed at every values
$tochangevals = get_records('feedback_value', 'tmp_completed', $oldcompletedid);
if($tochangevals) {
foreach($tochangevals as $tmpVal) {
$tmpVal->completed = $newcompletedid;
$tmpVal->tmp_completed = 0;
update_record('feedback_value', $tmpVal);
$completed->anonymous_response = $anonymous_response;
if($completed->userid > 0) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$completed->userid);
if ($user) {
$completed->userid = $user->new_id;
}
}
}
//the newcompletedid have to be changed at every tracking
$tochangetracks = get_records('feedback_tracking', 'completed', $oldcompletedid);
if($tochangetracks) {
foreach($tochangetracks as $tmpTrack) {
$tmpTrack->completed = $newcompletedid;
$tmpTrack->tmp_completed = 0;
update_record('feedback_tracking', $tmpTrack);
//later this have to be changed
$oldcompletedid = backup_todb($completed_info['#']['ID']['0']['#']);
//save the completed
$newcompletedid = insert_record('feedback_completed', $completed);
//the newcompletedid have to be changed at every values
$tochangevals = get_records('feedback_value', 'tmp_completed', $oldcompletedid);
if($tochangevals) {
foreach($tochangevals as $tmpVal) {
$tmpVal->completed = $newcompletedid;
$tmpVal->tmp_completed = 0;
update_record('feedback_value', $tmpVal);
}
}
//the newcompletedid have to be changed at every tracking
$tochangetracks = get_records('feedback_tracking', 'completed', $oldcompletedid);
if($tochangetracks) {
foreach($tochangetracks as $tmpTrack) {
$tmpTrack->completed = $newcompletedid;
$tmpTrack->tmp_completed = 0;
update_record('feedback_tracking', $tmpTrack);
}
}
}
}
+1 -1
View File
@@ -10,7 +10,7 @@
*/
$module->version = 2008050104; // The current module version (Date: YYYYMMDDXX)
$module->version = 2008050105; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2007101503; // Requires this Moodle version
$feedback_version_intern = 1; //this version is used for restore older backups
$module->cron = 0; // Period for cron to check this module (secs)