Index: lang/en_utf8/quiz_overview.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/quiz_overview.php,v retrieving revision 1.19 diff -u -r1.19 quiz_overview.php --- lang/en_utf8/quiz_overview.php 21 Nov 2008 23:13:24 -0000 1.19 +++ lang/en_utf8/quiz_overview.php 26 Nov 2008 07:49:21 -0000 @@ -10,6 +10,7 @@ $string['attemptprogress'] = 'Attempt $a->done of $a->todo'; $string['deleteselected'] = 'Delete selected attempts'; $string['done'] = 'Done'; +$string['downloadreportas'] = 'Download report as'; $string['err_failedtorecalculateattemptgrades'] = 'Failed to recalculate attempt grades'; $string['err_failedtodeleteregrades'] = 'Failed to delete calculated attempt grades'; $string['highlightinggraded'] = 'The user attempt that contributes to final grade is highlighted.'; @@ -44,10 +45,10 @@ $string['regradealldrygroup'] = 'Dry run a full regrade for group \'$a->groupname\''; $string['regradeselected'] = 'Regrade selected attempts'; $string['show'] = 'Show / download'; -$string['showattempts'] = 'Only show / download attempts'; +$string['showattempts'] = 'Only include attempts'; $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['showdetailedmarks'] = 'Marks for each question'; $string['studentingroup'] = '\'$a->coursestudent\' in group \'$a->groupname\''; $string['studentingrouplong'] = '\'$a->coursestudent\' in this group'; ?> Index: lang/en_utf8/table.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/table.php,v retrieving revision 1.2 diff -u -r1.2 table.php --- lang/en_utf8/table.php 15 Aug 2008 10:06:11 -0000 1.2 +++ lang/en_utf8/table.php 26 Nov 2008 07:49:21 -0000 @@ -1,4 +1,5 @@ _form; //------------------------------------------------------------------------------- - $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); + $mform->addElement('header', 'preferences', get_string('reportsettings', 'grades')); if (!$this->_customdata['currentgroup']){ $studentsstring = get_string('participants'); @@ -44,14 +44,18 @@ $mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '
', false); } //------------------------------------------------------------------------------- - $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview')); $mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview')); $mform->setType('pagesize', PARAM_INT); $mform->addElement('selectyesno', 'detailedmarks', get_string('showdetailedmarks', 'quiz_overview')); - $this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview')); + // Show report button. + $mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview')); + + // Download report controls. + $downloadgrp = flexible_table::download_form_controls($mform); + $mform->addGroup($downloadgrp, null, get_string('downloadreportas', 'quiz_overview'), ' '); } } ?> Index: mod/quiz/report/overview/report.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/report/overview/report.php,v retrieving revision 1.162 diff -u -r1.162 report.php --- mod/quiz/report/overview/report.php 25 Nov 2008 12:11:27 -0000 1.162 +++ mod/quiz/report/overview/report.php 26 Nov 2008 07:49:23 -0000 @@ -31,8 +31,6 @@ $reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $this->context); $showgrades = quiz_has_grades($quiz) && $reviewoptions->scores; - $download = optional_param('download', '', PARAM_ALPHA); - /// find out current groups mode $currentgroup = groups_get_activity_group($cm, true); if (!$students = get_users_by_capability($this->context, 'mod/quiz:attempt','','','','','','',false)){ @@ -138,9 +136,8 @@ } // We only want to show the checkbox to delete attempts // if the user has permissions and if the report mode is showing attempts. - $candelete = has_capability('mod/quiz:deleteattempts', $this->context) - && ($attemptsmode!= QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO); - + $showcheckboxes = has_any_capability(array('mod/quiz:deleteattempts', 'mod/quiz:regrade'), + $this->context) && ($attemptsmode!= QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO); $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; @@ -154,10 +151,11 @@ $questions = array(); } $table = new quiz_report_overview_table($quiz , $qmsubselect, $groupstudents, - $students, $detailedmarks, $questions, $candelete, $reporturl, + $students, $detailedmarks, $questions, $showcheckboxes, $reporturl, $displayoptions, $this->context); - $table->is_downloading($download, get_string('reportoverview','quiz'), - "$COURSE->shortname ".format_string($quiz->name,true)); + $table->is_downloading(true, get_string('reportoverview','quiz'), + $COURSE->shortname . ' ' . format_string($quiz->name, true)); + $table->show_download_buttons_at(array()); if (!$table->is_downloading()) { // Only print headers if not asked to download data $this->print_header_and_tabs($cm, $course, $quiz, "overview"); @@ -200,14 +198,9 @@ $mform->set_data($displayoptions +compact('detailedmarks', 'pagesize')); $mform->display(); } - - - if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)){ - - - + // Construct the SQL $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, '; if ($qmsubselect) { @@ -277,6 +270,10 @@ $columns = array(); $headers = array(); if (!$table->is_downloading()) { //do not print notices when downloading + // Print information on the grading method + if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { + echo '
' . $strattempthighlight . '
'; + } //regrade buttons if (has_capability('mod/quiz:regrade', $this->context)){ $countregradeneeded = $this->count_regrade_all_needed($quiz, $groupstudents); @@ -306,13 +303,9 @@ echo ''; echo ''; } - // Print information on the grading method - if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { - echo '
' . $strattempthighlight . '
'; - } } - if (!$table->is_downloading() && $candelete) { + if (!$table->is_downloading() && $showcheckboxes) { $columns[]= 'checkbox'; $headers[]= NULL; } @@ -349,14 +342,7 @@ foreach ($questions as $id => $question) { // Ignore questions of zero length $columns[] = 'qsgrade'.$id; - $header = '#'.$question->number; - if (!$table->is_downloading()) { - $header .='
'; - } else { - $header .=' '; - } - $header .='--/'.quiz_rescale_grade($question->maxgrade, $quiz); - $headers[] = $header; + $headers[] = '#' . $question->number . ' --/' . quiz_rescale_grade($question->maxgrade, $quiz); } } if (!$table->is_downloading() && has_capability('mod/quiz:regrade', $this->context) && $regradedattempts){ Index: mod/quiz/report/overview/overview_table.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/quiz/report/overview/overview_table.php,v retrieving revision 1.16 diff -u -r1.16 overview_table.php --- mod/quiz/report/overview/overview_table.php 25 Nov 2008 12:11:27 -0000 1.16 +++ mod/quiz/report/overview/overview_table.php 26 Nov 2008 07:49:22 -0000 @@ -4,13 +4,13 @@ var $useridfield = 'userid'; - var $candelete; + var $showcheckboxes; var $reporturl; var $displayoptions; var $regradedqs = array(); function quiz_report_overview_table($quiz , $qmsubselect, $groupstudents, - $students, $detailedmarks, $questions, $candelete, $reporturl, $displayoptions, $context){ + $students, $detailedmarks, $questions, $showcheckboxes, $reporturl, $displayoptions, $context){ parent::table_sql('mod-quiz-report-overview-report'); $this->quiz = $quiz; $this->qmsubselect = $qmsubselect; @@ -18,7 +18,7 @@ $this->students = $students; $this->detailedmarks = $detailedmarks; $this->questions = $questions; - $this->candelete = $candelete; + $this->showcheckboxes = $showcheckboxes; $this->reporturl = $reporturl; $this->displayoptions = $displayoptions; $this->context = $context; @@ -27,7 +27,7 @@ global $CFG, $DB; if ($this->rawdata) { // Define some things we need later to process raw data from db. - $this->strtimeformat = str_replace(',', '', get_string('strftimedatetime')); + $this->strtimeformat = str_replace(',', '', get_string('strftimedatetimeshort')); parent::build_table(); //end of adding data from attempts data to table / download //now add averages at bottom of table : @@ -72,7 +72,7 @@ function wrap_html_start(){ if (!$this->is_downloading()) { - if ($this->candelete) { + if ($this->showcheckboxes) { // Start form echo '
'; echo '
'; @@ -80,13 +80,7 @@ echo $this->reporturl->hidden_params_out(array(), 0, $this->displayoptions); echo '
'; echo '
'; - } - } - } - function wrap_html_finish(){ - if (!$this->is_downloading()) { - // Print "Select all" etc. - if ($this->candelete) { + // Print "Select all" etc. $strreallydel = addslashes_js(get_string('deleteattemptcheck','quiz')); echo '
'; echo ''. @@ -97,8 +91,16 @@ if (has_capability('mod/quiz:regrade', $this->context)){ echo ''; } - echo ''; + if (has_capability('mod/quiz:deleteattempts', $this->context)){ + echo ''; + } echo '
'; + } + } + } + function wrap_html_finish(){ + if (!$this->is_downloading()) { + if ($this->showcheckboxes) { // Close form echo '
'; echo ''; @@ -108,7 +110,7 @@ function col_checkbox($attempt){ - if ($attempt->attempt){ + if ($attempt->attempt && $this->showcheckboxes){ return ''; } else { return ''; Index: theme/standard/styles_layout.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_layout.css,v retrieving revision 1.646 diff -u -r1.646 styles_layout.css --- theme/standard/styles_layout.css 26 Nov 2008 04:03:45 -0000 1.646 +++ theme/standard/styles_layout.css 26 Nov 2008 07:49:24 -0000 @@ -4252,12 +4252,33 @@ .quizquestionlistcontrols { text-align: center; } - +#mod-quiz-report div.allcoursegrades { + width: auto; + float: right; + padding: 0.3em 0; + margin: 0; +} +#mod-quiz-report div.groupselector { + float: left; + padding: 0.3em 0; + margin: 0; +} +#mod-quiz-report div.quizattemptcounts { + text-align: center; + padding: 0.3em 0; + margin: 0; + clear: none; +} +#mod-quiz-report div.quizattemptcounts p { + margin: 0; +} +#mod-quiz-report div#commands { + text-align: center; +} #mod-quiz-report table#attempts, -#mod-quiz-report div#commands, #mod-quiz-report table#itemanalysis { - width: 80%; + width: 100%; margin: auto; } #mod-quiz-report table.titlesleft td.c0 @@ -4274,14 +4295,19 @@ #mod-quiz-report table#attempts .header, #mod-quiz-report table#attempts .cell { - padding: 4px; -} -#mod-quiz-report table#attempts .header .commands { - display: inline; + padding: 1px 4px; } #mod-quiz-report table#attempts .picture { width: 40px; } +#mod-quiz-report table#attempts .picture img.userpicture { + width: 20px; + height: 20px; +} +#mod-quiz-report table#attempts p, +#mod-quiz-report table#attempts .que { + margin: 0; +} #mod-quiz-report table#attempts td { border-left-width: 1px; border-right-width: 1px; @@ -4307,9 +4333,6 @@ { padding: 4px; } -#mod-quiz-report table#itemanalysis .header .commands { - display: inline; -} #mod-quiz-report table#itemanalysis td { border-width: 1px; border-style: solid; @@ -4357,10 +4380,6 @@ padding: 4px; } -#mod-quiz-grading table#grading .header .commands -{ - display: inline; -} #mod-quiz-grading table#grading .picture { Index: lib/tablelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/tablelib.php,v retrieving revision 1.39 diff -u -r1.39 tablelib.php --- lib/tablelib.php 14 Oct 2008 15:00:26 -0000 1.39 +++ lib/tablelib.php 26 Nov 2008 07:49:22 -0000 @@ -7,8 +7,8 @@ define('TABLE_VAR_ILAST', 5); define('TABLE_VAR_PAGE', 6); -define('TABLE_P_TOP', 1); -define('TABLE_P_BOTTOM', 2); +define('TABLE_P_TOP', 1); +define('TABLE_P_BOTTOM', 2); class flexible_table { @@ -94,23 +94,33 @@ } /** - * Call this to pass the download type. Use : - * $download = optional_param('download', '', PARAM_ALPHA); - * To get the download type. We assume that if you call this function with + * Call this to pass the download type. It is recommended that you just pass + * true, then the format will be determined automatically from the form + * controls ouput by download_buttons or download_form_controls. + * + * We assume that if you call this function with * params that this table's data is downloadable, so we call is_downloadable - * for you (even if the param is '', which means no download this time. - * Also you can call this method with no params to get the current set - * download type. - * @param string $download download type. One of csv, tsv, xhtml, ods, etc + * for you (even if the type is '', which means no download this time. + * Also you can call this method with no params to get the download type. + * @param mixed $download Either a specific type 'csv', 'tsv', 'xhtml', 'ods', + * to force download in this type, or true to initialise from submitted params 'downloadtable' and 'downloadtabletype' * @param string $filename filename for downloads without file extension. * @param string $sheettitle title for downloaded data. * @return string download type. One of csv, tsv, xhtml, ods, etc */ - function is_downloading($download = null, $filename='', $sheettitle=''){ - if ($download!==null){ + function is_downloading($type = null, $filename='', $sheettitle=''){ + if (!is_null($type)) { $this->sheettitle = $sheettitle; $this->is_downloadable(true); - $this->download = $download; + if ($type === true) { + if (optional_param('downloadtable', false, PARAM_BOOL)) { + $this->download = optional_param('downloadtableformat', '', PARAM_ALPHA); + } else { + $this->download = ''; + } + } else { + $this->download = $type; + } $this->filename = clean_filename($filename); $this->export_class_instance(); } @@ -856,32 +866,48 @@ } return $row; } + /** * This function is not part of the public api. */ - function get_download_menu(){ - $allclasses= get_declared_classes(); + static function get_download_menu() { + $allclasses = get_declared_classes(); $exportclasses = array(); foreach ($allclasses as $class){ $matches = array(); if (preg_match('/^table\_([a-z]+)\_export\_format$/', $class, $matches)){ $type = $matches[1]; - $exportclasses[$type]= get_string("download$type", 'table'); + $exportclasses[$type] = get_string("download$type", 'table'); } } return $exportclasses; } /** - * This function is not part of the public api. + * Return a group of form controls that can be added to $mform to control + * downloading of this report. + * + * @param object $mform a Moodle form. + * @return array an array of form controls that can be added to $mform. + */ + static function download_form_controls($mform) { + $downloadgrp = array(); + $downloadgrp[] =& $mform->createElement('select', 'downloadtableformat', null, flexible_table::get_download_menu()); + $mform->setDefault('downloadtableformat', 'csv'); + $downloadgrp[] =& $mform->createElement('submit', 'downloadtable', get_string('download', 'table')); + return $downloadgrp; + } + + /** + * @return string HTML for a simple form to let people download this table in a variety of formats. */ function download_buttons(){ if ($this->is_downloadable() && !$this->is_downloading()){ $downloadoptions = $this->get_download_menu(); $html = '
'; $html .= '
'; - $html .= ''; - $html .= choose_from_menu ($downloadoptions, 'download', $this->defaultdownloadformat, '', '', '', true); + $html .= ''; + $html .= choose_from_menu($downloadoptions, 'downloadtableformat', $this->defaultdownloadformat, '', '', '', true); $html .= helpbutton('tableexportformats', get_string('tableexportformats', 'table'), 'moodle', true, false, '', true); $html .= '
';