From 7660aa80e0beb7b117dc11bb99c41b44e9674a15 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 24 Jun 2008 16:36:44 +0000 Subject: [PATCH] MDL-15393 "show group name in drop down select for what to show in report" AND MDL-15394 "disable showing 'all attempts' and remove option from drop down box in form if there is a group selected" --- lang/en_utf8/quiz_overview.php | 7 +++--- .../report/overview/overviewsettings_form.php | 20 ++++++++++++----- mod/quiz/report/overview/report.php | 22 ++++++++++++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/lang/en_utf8/quiz_overview.php b/lang/en_utf8/quiz_overview.php index 11fbc43d1d..dddc39ab41 100644 --- a/lang/en_utf8/quiz_overview.php +++ b/lang/en_utf8/quiz_overview.php @@ -12,9 +12,9 @@ $string['highlightinggraded'] = 'The user attempt that contributes to final grad $string['noattemptsonly'] = 'Show / download $a with no attempts only'; $string['onlyoneattemptallowed'] = 'Only one attempt per user allowed on this quiz.'; $string['optallattempts'] = 'all attempts'; -$string['optallstudents'] = 'all \'$a\''; -$string['optattemptsonly'] = '\'$a\' with attempts only'; -$string['optnoattemptsonly'] = '\'$a\' with no attempts only'; +$string['optallstudents'] = 'all $a who have or have not attempted the quiz'; +$string['optattemptsonly'] = '$a who have attempted the quiz'; +$string['optnoattemptsonly'] = '$a who have not attempted the quiz'; $string['optonlygradedattempts'] = 'only the attempt that is graded for each user ($a)'; $string['overview'] = 'Grades'; $string['overviewdownload'] = 'Overview download'; @@ -28,4 +28,5 @@ $string['show'] = 'Show / download'; $string['showinggraded'] = 'Showing only the attempt graded for each user.'; $string['showinggradedandungraded'] = 'Showing graded and ungraded attempts for each user. The one attempt for each user that is graded is highlighted. The grading method for this quiz is $a.'; $string['showdetailedmarks'] = 'Show / download marks for each question'; +$string['studentingroup'] = '\'$a->coursestudent\' in group \'$a->groupname\''; ?> diff --git a/mod/quiz/report/overview/overviewsettings_form.php b/mod/quiz/report/overview/overviewsettings_form.php index c67d49acf1..e250e0aa67 100644 --- a/mod/quiz/report/overview/overviewsettings_form.php +++ b/mod/quiz/report/overview/overviewsettings_form.php @@ -8,13 +8,23 @@ class mod_quiz_report_overview_settings extends moodleform { //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); + if (!$this->_customdata['currentgroup']){ + $studentsstring = "'".$COURSE->students."'"; + } else { + $a = new object(); + $a->coursestudent = $COURSE->students; + $a->groupname = groups_get_group_name($this->_customdata['currentgroup']); + $studentsstring = get_string('studentingroup', 'quiz_overview', $a); + } $options = array(); - $options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts','quiz_overview'); - if ($COURSE->id != SITEID) { - $options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents','quiz_overview', $COURSE->students); + if (!$this->_customdata['currentgroup']){ + $options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts','quiz_overview'); + } + if ($this->_customdata['currentgroup'] || $COURSE->id != SITEID) { + $options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents','quiz_overview', $studentsstring); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] = - get_string('optattemptsonly','quiz_overview', $COURSE->students); - $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $COURSE->students); + get_string('optattemptsonly','quiz_overview', $studentsstring); + $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $studentsstring); } $mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options); if ($this->_customdata['qmsubselect']){ diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index ae4f17537a..95b44fb13d 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -55,7 +55,10 @@ class quiz_overview_report extends quiz_default_report { $reporturl = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $pageoptions); $qmsubselect = quiz_report_qm_filter_subselect($quiz); // careful: these are named params in $params!! - $mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect'=> $qmsubselect, 'quiz'=>$quiz)); + /// find out current groups mode + $currentgroup = groups_get_activity_group($cm, true); + + $mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect'=> $qmsubselect, 'quiz'=>$quiz, 'currentgroup'=>$currentgroup)); if ($fromform = $mform->get_data()){ $attemptsmode = $fromform->attemptsmode; if ($qmsubselect){ @@ -72,7 +75,19 @@ class quiz_overview_report extends quiz_default_report { $pagesize = $fromform->pagesize; } else { $qmfilter = optional_param('qmfilter', 0, PARAM_INT); - $attemptsmode = optional_param('attemptsmode', QUIZ_REPORT_ATTEMPTS_ALL, PARAM_INT); + $attemptsmode = optional_param('attemptsmode', null, PARAM_INT); + if ($attemptsmode === null){ + //default + $attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL; + } else if ($currentgroup){ + //default for when a group is selected + if ($attemptsmode === null || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL){ + $attemptsmode = QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH; + } + } else if (!$currentgroup && $course->id == SITEID) { + //force report on front page to show all, unless a group is selected. + $attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL; + } $detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1); $pagesize = get_user_preferences('quiz_report_pagesize', 0); } @@ -92,9 +107,6 @@ class quiz_overview_report extends quiz_default_report { $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['qmfilter'] = $qmfilter; - /// find out current groups mode - $currentgroup = groups_get_activity_group($cm, true); - //work out the sql for this table. if (!$students = get_users_by_capability($context, 'mod/quiz:attempt','','','','','','',false)){ $students = array(); -- 2.39.5