1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-05 15:57:04 +02:00

MDL-27523 tidy up links to download files, shift logic for set_page to allow mode to be set correctly

This commit is contained in:
Dan Marsden 2011-07-11 13:35:29 +12:00
parent b2614417a5
commit 5e3014df9e
3 changed files with 28 additions and 29 deletions

@ -32,26 +32,29 @@ $id = required_param('id', PARAM_INT);// Course Module ID, or
$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 @@ if (empty($noheader)) {
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 @@ class scorm_basic_report extends scorm_default_report {
}
// 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 @@ class scorm_basic_report extends scorm_default_report {
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 @@ class scorm_basic_report extends scorm_default_report {
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 @@ class mod_scorm_report_settings extends moodleform {
$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);
//-------------------------------------------------------------------------------