From 06facf9671da87cc7e9b7d5ffee89cdd9c3f840f Mon Sep 17 00:00:00 2001
From: Penny Leach <penny@mjollnir.org>
Date: Tue, 18 Aug 2009 16:15:11 +0200
Subject: [PATCH] [UPSTREAM] assignment/uploadpdf backup/restore - fixed a bug

comments weren't properly being backed up/restored
---
 mod/assignment/type/uploadpdf/assignment.class.php |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/mod/assignment/type/uploadpdf/assignment.class.php b/mod/assignment/type/uploadpdf/assignment.class.php
index 5b82afe..ecde842 100644
--- a/mod/assignment/type/uploadpdf/assignment.class.php
+++ b/mod/assignment/type/uploadpdf/assignment.class.php
@@ -1752,13 +1752,11 @@ class assignment_uploadpdf extends assignment_base {
 
     function restore_one_submission($info, $restore, $assignment, $submission) {
         //Get the submissions array - it might not be present
-        if (@isset($info['COMMENTS']['0']['#']['COMMENT'])) {
-            $comments = $info['COMMENTS']['0']['#']['COMMENT'];
+        if (@isset($info['#']['COMMENTS']['0']['#']['COMMENT'])) {
+            $comments = $info['#']['COMMENTS']['0']['#']['COMMENT'];
         } else {
             $comments = array();
         }
-        $oldid = backup_todb($info['#']['ID']['0']['#']);
-        $newid = backup_getid($restore->backup_unique_code, 'assignment_submissions', $oldid);
         foreach ($comments as $comment) {
             $dbc = new stdclass;
             $dbc->posx = backup_todb($comment['#']['POSX']['0']['#']);
@@ -1766,8 +1764,8 @@ class assignment_uploadpdf extends assignment_base {
             $dbc->width = backup_todb($comment['#']['WIDTH']['0']['#']);
             $dbc->rawtext = backup_todb($comment['#']['RAWTEXT']['0']['#']);
             $dbc->pageno = backup_todb($comment['#']['PAGENO']['0']['#']);
-            $dbc->color = backup_todb($item['#']['COLOUR']['0']['#']);
-            $dbc->assignment_submission = $newid->new_id;
+            $dbc->color = backup_todb($commentitei['#']['COLOUR']['0']['#']);
+            $dbc->assignment_submission = $submission->id;
             insert_record('assignment_uploadpdf_comment', $dbc);
         }
     }
-- 
1.6.3.3

