Index: mod/scorm/locallib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/locallib.php,v
retrieving revision 1.46.2.21
diff -u -r1.46.2.21 locallib.php
--- mod/scorm/locallib.php	14 Nov 2008 00:14:50 -0000	1.46.2.21
+++ mod/scorm/locallib.php	28 Nov 2008 03:44:48 -0000
@@ -1235,4 +1235,26 @@
     }
 }
 
+/**
+* Delete Scorm tracks for selected users
+*
+* @param array $attemptids list of users that need to be deleted
+* @param int $scormid ID of Scorm
+*/   
+function scorm_delete_responses($attemptids, $scormid) {
+    if(!is_array($attemptids) || empty($attemptids)) {
+        return false;
+    }
+
+    foreach($attemptids as $num => $attemptid) {
+        if(empty($attemptid)) {
+            unset($attemptids[$num]);
+        }
+    }
+
+    foreach($attemptids as $attemptid) {
+        delete_records('scorm_scoes_track', 'scormid', $scormid, 'userid', $attemptid);
+    }
+    return true;
+}
 ?>
\ No newline at end of file
Index: mod/scorm/report.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/report.php,v
retrieving revision 1.46.2.5
diff -u -r1.46.2.5 report.php
--- mod/scorm/report.php	19 Aug 2008 06:59:23 -0000	1.46.2.5
+++ mod/scorm/report.php	28 Nov 2008 03:44:48 -0000
@@ -10,6 +10,8 @@
     $b = optional_param('b', '', PARAM_INT);     // SCO ID
     $user = optional_param('user', '', PARAM_INT);  // User ID
     $attempt = optional_param('attempt', '1', PARAM_INT);  // attempt number
+    $action     = optional_param('action', '', PARAM_ALPHA);
+    $attemptids = optional_param('attemptid', array(), PARAM_INT); //get array of responses to delete.
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
@@ -42,10 +44,10 @@
     }
 
     require_login($course->id, false, $cm);
+    
+    $contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id);
 
-    if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id))) {
-        error('You are not allowed to use this script');
-    }
+    require_capability('mod/scorm:viewreport', $contextmodule);
 
     add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id, $cm->id);
 
@@ -93,6 +95,12 @@
         print_heading(format_string($scorm->name));
     }
 
+    if ($action == 'delete' && has_capability('mod/scorm:deleteresponses',$contextmodule)) {
+        if (scorm_delete_responses($attemptids, $scorm->id)) { //delete responses.
+            notify(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
+        }
+    }
+
     $scormpixdir = $CFG->modpixpath.'/scorm/pix';
 
     if (empty($b)) {
@@ -117,11 +125,24 @@
             
             if ($scousers=get_records_sql($sql)) {
                 $table = new stdClass();
-                $table->head = array('&nbsp;', get_string('name'));
-                $table->align = array('center', 'left');
-                $table->wrap = array('nowrap', 'nowrap');
+                $table->head = array();
                 $table->width = '100%';
-                $table->size = array(10, '*');
+                if (has_capability('mod/scorm:deleteresponses',$contextmodule)) {
+                    $table->head[]  = '&nbsp;';
+                    $table->align[] = 'center';
+                    $table->wrap[]  = 'nowrap';
+                    $table->size[]  = '10';
+                }
+
+                $table->head[]  = '&nbsp;';
+                $table->align[] = 'center';
+                $table->wrap[]  = 'nowrap';
+                $table->size[]  = '10';
+
+                $table->head[]  = get_string('name');
+                $table->align[] = 'left';
+                $table->wrap[]  = 'nowrap';
+                $table->size[]  = '*';
 
                 $table->head[]= get_string('attempt','scorm');
                 $table->align[] = 'center';
@@ -148,6 +169,9 @@
                     $attempt = scorm_get_last_attempt($scorm->id,$scouser->userid);    
                     for ($a = 1; $a<=$attempt; $a++) {
                         $row = array();
+                        if (has_capability('mod/scorm:deleteresponses',$contextmodule)) {
+                            $row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid. '" />';
+                        }
                         $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
                         $row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&amp;course='.$course->id.'">'.
                                  fullname($userdata).'</a>';
@@ -161,8 +185,28 @@
                         $table->data[] = $row;
                     }
                 }
+                echo '<div id="scormtablecontainer">';
+                if (has_capability('mod/scorm:deleteresponses',$contextmodule)) {
+                    echo '<form id="attemptsform" method="post" action="'.$_SERVER['PHP_SELF'].'" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \''.addslashes(get_string('deleteattemptcheck','quiz')).'\' : true);">';
+                    echo '<input type="hidden" name="id" value="'.$id.'">';
+                    print_table($table);    
+                    echo '<a href="javascript:select_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
+                    echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
+                    echo '&nbsp;&nbsp;';
+                    $options = array('delete' => get_string('delete'));
+                    echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true);
+                    echo '<noscript id="noscriptmenuaction" style="display: inline;">';
+                    echo '<div>';
+                    echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
+                    echo '<script type="text/javascript">'."\n<!--\n".'document.getElementById("noscriptmenuaction").style.display = "none";'."\n-->\n".'</script>';
+                    echo '</form>';
+                } else {
+                    print_table($table);
+                }
+                echo '</div>';
+            } else {
+                notify(get_string('noactivity', 'scorm'));
             }
-            print_table($table);
         } else {
             if (!empty($user)) {
                 // User SCORM report
Index: mod/scorm/version.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/version.php,v
retrieving revision 1.53.2.3
diff -u -r1.53.2.3 version.php
--- mod/scorm/version.php	1 Aug 2008 04:30:45 -0000	1.53.2.3
+++ mod/scorm/version.php	28 Nov 2008 03:44:48 -0000
@@ -10,8 +10,8 @@
 //       catch up now, so until 27th October please only increment in very tiny steps 
 //       in HEAD, until we get past that date..
 
-$module->version  = 2007110501;   // The (date) version of this module
+$module->version  = 2007110502;   // The (date) version of this module
 $module->requires = 2007101509;   // The version of Moodle that is required
 $module->cron     = 300;            // How often should cron check this module (seconds)?
 
-?>
+?>
\ No newline at end of file
Index: mod/scorm/db/access.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/db/access.php,v
retrieving revision 1.10
diff -u -r1.10 access.php
--- mod/scorm/db/access.php	16 Feb 2007 08:46:59 -0000	1.10
+++ mod/scorm/db/access.php	28 Nov 2008 03:44:48 -0000
@@ -75,8 +75,17 @@
             'editingteacher' => CAP_ALLOW,
             'admin' => CAP_ALLOW
         )
-    )
+    ),
+    'mod/scorm:deleteresponses' => array(
 
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    )
 );
 
-?>
+?>
\ No newline at end of file
Index: lang/en_utf8/scorm.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/scorm.php,v
retrieving revision 1.18.4.10
diff -u -r1.18.4.10 scorm.php
--- lang/en_utf8/scorm.php	14 Nov 2008 00:14:50 -0000	1.18.4.10
+++ lang/en_utf8/scorm.php	28 Nov 2008 03:44:48 -0000
@@ -133,6 +133,7 @@
 $string['scorm:viewreport'] = 'View reports';
 $string['scorm:viewscores'] = 'View scores';
 $string['scormcourse'] = 'Learning Course';
+$string['scormresponsedeleted'] = 'Deleted user attempts';
 $string['scrollbars'] = 'Allow the window to be scrolled';
 $string['sided'] = 'On the left side';
 $string['skipview'] = 'Student skip content structure page';
