Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master_MDL-28728' of git://github.com/danmarsden/moodle

  • Loading branch information...
commit 2faa009fa17d09b3570621636b3dc5b4037a03a0 2 parents d2861a7 + a12b1d7
@nebgor nebgor authored
View
6 mod/scorm/db/access.php
@@ -76,6 +76,12 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
+ ),
+ 'mod/scorm:deleteownresponses' => array(
+
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array()
)
);
View
1  mod/scorm/lang/en/scorm.php
@@ -73,6 +73,7 @@
$string['defaultothersettings'] = 'Other default settings';
$string['deleteattemptcheck'] = 'Are you absolutely sure you want to completely delete these attempts?';
$string['deleteallattempts'] = 'Delete all SCORM attempts';
+$string['deleteuserattemptcheck'] = 'Are you absolutely sure you want to completely delete all your attempts?';
$string['details'] = 'Track details';
$string['directories'] = 'Show the directory links';
$string['disabled'] = 'Disabled';
View
15 mod/scorm/locallib.php
@@ -1031,8 +1031,8 @@ function scorm_element_cmp($a, $b) {
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
-function scorm_get_attempt_status($user, $scorm) {
- global $DB;
+function scorm_get_attempt_status($user, $scorm, $cm='') {
+ global $DB, $PAGE, $OUTPUT;
$attempts = scorm_get_attempt_count($user->id, $scorm, true);
if (empty($attempts)) {
@@ -1108,6 +1108,17 @@ function scorm_get_attempt_status($user, $scorm) {
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
$result .= '<p><font color="#cc0000">'.get_string('exceededmaxattempts', 'scorm').'</font></p>';
}
+ if (!empty($cm)) {
+ $context = context_module::instance($cm->id);
+ if (has_capability('mod/scorm:deleteownresponses', $context) &&
+ $DB->record_exists('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id))) {
+ //check to see if any data is stored for this user:
+ $deleteurl = new moodle_url($PAGE->url, array('action'=>'delete', 'sesskey' => sesskey()));
+ $result .= $OUTPUT->single_button($deleteurl, get_string('deleteallattempts', 'scorm'));
+ }
+ }
+
+
return $result;
}
View
2  mod/scorm/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
-$module->version = 2011112900; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2011112901; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011112900; // Requires this Moodle version
$module->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics)
$module->cron = 300;
View
17 mod/scorm/view.php
@@ -20,6 +20,7 @@
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$organization = optional_param('organization', '', PARAM_INT); // organization ID
+$action = optional_param('action', '', PARAM_ALPHA);
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
@@ -83,6 +84,20 @@
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
+if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
+ if ($action == 'delete') {
+ $confirmurl = new moodle_url($PAGE->url, array('action'=>'deleteconfirm'));
+ echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
+ echo $OUTPUT->footer();
+ exit;
+ } else if ($action == 'deleteconfirm') {
+ //delete this users attempts.
+ $DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
+ scorm_update_grades($scorm, $USER->id, true);
+ echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
+ }
+}
+
$currenttab = 'info';
require($CFG->dirroot . '/mod/scorm/tabs.php');
@@ -90,7 +105,7 @@
echo $OUTPUT->heading(format_string($scorm->name));
$attemptstatus = '';
if ($scorm->displayattemptstatus == 1) {
- $attemptstatus = scorm_get_attempt_status($USER, $scorm);
+ $attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
Please sign in to comment.
Something went wrong with that request. Please try again.