Index: question/restorelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/restorelib.php,v retrieving revision 1.30.2.5 diff -u -r1.30.2.5 restorelib.php --- question/restorelib.php 9 May 2008 15:10:42 -0000 1.30.2.5 +++ question/restorelib.php 15 Jan 2009 05:38:45 -0000 @@ -337,6 +337,28 @@ $question->createdby = backup_todb_optional_field($que_info, 'CREATEDBY', null); $question->modifiedby = backup_todb_optional_field($que_info, 'MODIFIEDBY', null); + // Set the createdby field, if the user was in the backup, or if we are on the same site. + $createdby = backup_todb_optional_field($que_info, 'CREATEDBY', null); + if (!empty($createdby)) { + $user = backup_getid($restore->backup_unique_code, 'user', $createdby); + if ($user) { + $question->createdby = $user->new_id; + } else if ($restore->original_wwwroot == $CFG->wwwroot) { + $question->createdby = $createdby; + } + } + + // Set the modifiedby field, if the user was in the backup, or if we are on the same site. + $modifiedby = backup_todb_optional_field($que_info, 'MODIFIEDBY', null); + if (!empty($createdby)) { + $user = backup_getid($restore->backup_unique_code, 'user', $modifiedby); + if ($user) { + $question->modifiedby = $user->new_id; + } else if ($restore->original_wwwroot == $CFG->wwwroot) { + $question->modifiedby = $modifiedby; + } + } + if ($restore->backup_version < 2006032200) { // The qtype was an integer that now needs to be converted to the name $qtypenames = array(1=>'shortanswer',2=>'truefalse',3=>'multichoice',4=>'random',5=>'match',