Skip to content

Commit

Permalink
MDL-30028 - use page pref correctly when pagination or re-ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden authored and Aparup Banerjee committed Dec 8, 2011
1 parent 0f69a9e commit 347f822
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions mod/scorm/report/basic/report.php
Expand Up @@ -36,6 +36,8 @@ function display($scorm, $cm, $course, $download) {
$contextmodule= get_context_instance(CONTEXT_MODULE, $cm->id); $contextmodule= get_context_instance(CONTEXT_MODULE, $cm->id);
$action = optional_param('action', '', PARAM_ALPHA); $action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW); $attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));


if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { //delete responses. if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
Expand All @@ -51,13 +53,11 @@ function display($scorm, $cm, $course, $download) {
if ($fromform = $mform->get_data()) { if ($fromform = $mform->get_data()) {
$detailedrep = $fromform->detailedrep; $detailedrep = $fromform->detailedrep;
$pagesize = $fromform->pagesize; $pagesize = $fromform->pagesize;
$attemptsmode = !empty($fromform->attemptsmode) ? $fromform->attemptsmode : SCORM_REPORT_ATTEMPTS_ALL_STUDENTS;
set_user_preference('scorm_report_detailed', $detailedrep); set_user_preference('scorm_report_detailed', $detailedrep);
set_user_preference('scorm_report_pagesize', $pagesize); set_user_preference('scorm_report_pagesize', $pagesize);
} else { } else {
$detailedrep = get_user_preferences('scorm_report_detailed', false); $detailedrep = get_user_preferences('scorm_report_detailed', false);
$pagesize = get_user_preferences('scorm_report_pagesize', 0); $pagesize = get_user_preferences('scorm_report_pagesize', 0);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_STUDENTS_WITH, PARAM_INT);
} }
if ($pagesize < 1) { if ($pagesize < 1) {
$pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE; $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
Expand Down Expand Up @@ -522,7 +522,7 @@ function display($scorm, $cm, $course, $download) {
} }
} }
if (!$download) { if (!$download) {
$mform->set_data(compact('detailedrep', 'pagesize')); $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode'));
$mform->display(); $mform->display();
} }
} else { } else {
Expand Down
6 changes: 3 additions & 3 deletions mod/scorm/report/interactions/report.php
Expand Up @@ -38,6 +38,8 @@ function display($scorm, $cm, $course, $download) {
$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id); $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
$action = optional_param('action', '', PARAM_ALPHA); $action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW); $attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));


if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { //delete responses. if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
Expand All @@ -55,14 +57,12 @@ function display($scorm, $cm, $course, $download) {
$includeqtext = $fromform->qtext; $includeqtext = $fromform->qtext;
$includeresp = $fromform->resp; $includeresp = $fromform->resp;
$includeright = $fromform->right; $includeright = $fromform->right;
$attemptsmode = !empty($fromform->attemptsmode) ? $fromform->attemptsmode : SCORM_REPORT_ATTEMPTS_ALL_STUDENTS;
set_user_preference('scorm_report_pagesize', $pagesize); set_user_preference('scorm_report_pagesize', $pagesize);
set_user_preference('scorm_report_interactions_qtext', $includeqtext); set_user_preference('scorm_report_interactions_qtext', $includeqtext);
set_user_preference('scorm_report_interactions_resp', $includeresp); set_user_preference('scorm_report_interactions_resp', $includeresp);
set_user_preference('scorm_report_interactions_right', $includeright); set_user_preference('scorm_report_interactions_right', $includeright);
} else { } else {
$pagesize = get_user_preferences('scorm_report_pagesize', 0); $pagesize = get_user_preferences('scorm_report_pagesize', 0);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_STUDENTS_WITH, PARAM_INT);
$includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0); $includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0);
$includeresp = get_user_preferences('scorm_report_interactions_resp', 1); $includeresp = get_user_preferences('scorm_report_interactions_resp', 1);
$includeright = get_user_preferences('scorm_report_interactions_right', 0); $includeright = get_user_preferences('scorm_report_interactions_right', 0);
Expand Down Expand Up @@ -584,7 +584,7 @@ function display($scorm, $cm, $course, $download) {
} }
} }
if (!$download) { if (!$download) {
$mform->set_data(compact('detailedrep', 'pagesize')); $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode'));
$mform->display(); $mform->display();
} }
} else { } else {
Expand Down

0 comments on commit 347f822

Please sign in to comment.