Permalink
Browse files

MDL-27523 tidy up links to download files, shift logic for set_page t…

…o allow mode to be set correctly
  • Loading branch information...
1 parent b261441 commit 5e3014df9e5da6a98e5b2887f2330d5def72a639 @danmarsden danmarsden committed Jul 11, 2011
Showing with 28 additions and 29 deletions.
  1. +13 −16 mod/scorm/report.php
  2. +13 −10 mod/scorm/report/basic/report.php
  3. +2 −3 mod/scorm/reportsettings_form.php
View
@@ -32,26 +32,29 @@
$download = optional_param('download', '', PARAM_RAW);
$mode = optional_param('mode', '', PARAM_ALPHA); // Report mode
-$url = new moodle_url('/mod/scorm/report.php');
-
-if ($mode !== '') {
- $url->param('mode', $mode);
-}
-
-$url->param('id', $id);
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
+$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+$reportlist = scorm_report_list($contextmodule);
+
+$url = new moodle_url('/mod/scorm/report.php');
+
+$url->param('id', $id);
+if (empty($mode)) {
+ $mode = reset($reportlist);
+} else if (!in_array($mode, $reportlist)) {
+ print_error('erroraccessingreport', 'scorm');
+}
+$url->param('mode', $mode);
+
$PAGE->set_url($url);
require_login($course->id, false, $cm);
-$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
-
require_capability('mod/scorm:viewreport', $contextmodule);
-$reportlist = scorm_report_list($contextmodule);
if (count($reportlist) < 1) {
print_error('erroraccessingreport', 'scorm');
}
@@ -76,12 +79,6 @@
echo $OUTPUT->heading(format_string($scorm->name));
}
-if (empty($mode)) {
- $mode = reset($reportlist);
-} else if (!in_array($mode, $reportlist)) {
- print_error('erroraccessingreport', 'scorm');
-}
-
// Open the selected Scorm report and display it
$reportclassname = "scorm_{$mode}_report";
$report = new $reportclassname();
@@ -61,10 +61,11 @@ function display($scorm, $cm, $course, $download) {
}
// select group menu
- $PAGE->url->param('attemptsmode', $attemptsmode);
+ $displayoptions = array();
+ $displayoptions['attemptsmode'] = $attemptsmode;
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$download) {
- groups_print_activity_menu($cm, $PAGE->url);
+ groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
}
}
@@ -339,7 +340,7 @@ function display($scorm, $cm, $course, $download) {
if ($candelete) {
// Start form
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
- echo '<form id="attemptsform" method="post" action="' . $PAGE->url .
+ echo '<form id="attemptsform" method="post" action="' . $PAGE->url->out(false) .
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
echo '<input type="hidden" name="action" value="delete"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
@@ -486,17 +487,19 @@ function display($scorm, $cm, $course, $download) {
if (!empty($attempts)) {
echo '<table class="boxaligncenter"><tr>';
echo '<td>';
- $PAGE->url->param('download', 'ODS');
- echo $OUTPUT->single_button($PAGE->url, get_string('downloadods'));
+ echo $OUTPUT->single_button(new moodle_url($PAGE->url,
+ array('download'=>'ODS') + $displayoptions),
+ get_string('downloadods'));
echo "</td>\n";
echo '<td>';
- $PAGE->url->param('download', 'Excel');
- echo $OUTPUT->single_button($PAGE->url, get_string('downloadexcel'));
+ echo $OUTPUT->single_button(new moodle_url($PAGE->url,
+ array('download'=>'Excel') + $displayoptions),
+ get_string('downloadexcel'));
echo "</td>\n";
echo '<td>';
- $PAGE->url->param('download', 'CSV');
- echo $OUTPUT->single_button($PAGE->url, get_string('downloadtext'));
- $PAGE->url->param('download', '');
+ echo $OUTPUT->single_button(new moodle_url($PAGE->url,
+ array('download'=>'CSV') + $displayoptions),
+ get_string('downloadtext'));
echo "</td>\n";
echo "<td>";
echo "</td>\n";
@@ -28,12 +28,11 @@ function definition() {
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'scorm'));
$options = array();
- /*Group support is broken - see MDL-28282
- if ($this->_customdata['currentgroup'] || $COURSE->id != SITEID) {
+ if ($COURSE->id != SITEID) {
$options[SCORM_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents', 'scorm');
$options[SCORM_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly', 'scorm');
$options[SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'scorm');
- }*/
+ }
$mform->addElement('select', 'attemptsmode', get_string('show', 'scorm'), $options);
//-------------------------------------------------------------------------------

0 comments on commit 5e3014d

Please sign in to comment.