From 4e2f0dd63f4e4314b0a1f449c8b0a6d804c22530 Mon Sep 17 00:00:00 2001
From: Penny Leach <penny@mjollnir.org>
Date: Tue, 25 Aug 2009 17:17:03 +0200
Subject: [PATCH] [UPSTREAM] uploadpdf: fix missing $this->type and implement course reset

---
 mod/assignment/type/uploadpdf/assignment.class.php |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/mod/assignment/type/uploadpdf/assignment.class.php b/mod/assignment/type/uploadpdf/assignment.class.php
index bb524d3..7f6affb 100644
--- a/mod/assignment/type/uploadpdf/assignment.class.php
+++ b/mod/assignment/type/uploadpdf/assignment.class.php
@@ -20,6 +20,7 @@ class assignment_uploadpdf extends assignment_base {
 
     function assignment_uploadpdf($cmid=0) {
         parent::assignment_base($cmid);
+        $this->type = 'uploadpdf';
     }
 
     function view() {
@@ -1770,6 +1771,22 @@ class assignment_uploadpdf extends assignment_base {
             insert_record('assignment_uploadpdf_comment', $dbc);
         }
     }
+
+    function reset_userdata($data) {
+        global $CFG;
+        if (!empty($data->reset_assignment_submissions)) {
+            delete_records_select('assignment_uploadpdf_comment',
+                'assignment_submission IN (
+                    SELECT s.id
+                    FROM ' . $CFG->prefix . 'assignment_submissions s
+                    JOIN ' . $CFG->prefix . 'assignment a
+                        ON s.assignment = a.id
+                    WHERE a.course = ' . $data->courseid . '
+                )'
+            );
+        }
+        return parent::reset_userdata($data);
+    }
 }
 
 class mod_assignment_uploadpdf_notes_form extends moodleform {
-- 
1.6.3.3

