]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14203 "split report into two seperate reports - Quiz Statistics report and Indivi...
authorjamiesensei <jamiesensei>
Sun, 15 Jun 2008 11:58:16 +0000 (11:58 +0000)
committerjamiesensei <jamiesensei>
Sun, 15 Jun 2008 11:58:16 +0000 (11:58 +0000)
lang/en_utf8/quiz_statistics.php
mod/quiz/report/statistics/report.php
mod/quiz/report/statistics/statistics_table.php
theme/standard/styles_layout.css

index 7feab43a30dfde1558ddbb8096f86723fdb72b32..f6341df9f35a43ab1cb655011c004e0aad6a0819 100644 (file)
@@ -28,4 +28,8 @@ $string['kurtosis'] = 'Score distribution kurtosis';
 $string['cic'] = 'Coefficient of internal consistency';
 $string['errorratio'] = 'Error ratio';
 $string['standarderror'] = 'Standard error';
+$string['questionnumber'] = 'Q#';
+$string['quizstructureanalysis'] = 'Quiz structure analysis';
+$string['questiontype'] = 'Q type';
+$string['intended_weight'] = 'Intended question weight';
 ?>
\ No newline at end of file
index 7780c5089cf042fea3f675589f30ff084fe0b9e0..ea931266da3852651487cea235010785360225de 100644 (file)
@@ -55,9 +55,9 @@ class quiz_report extends quiz_default_report {
             $allowedlist = $groupstudentslist;
         }
 
-        $questions = quiz_report_load_questions($quiz);
+        $questions = question_load_questions(quiz_questions_in_quiz($quiz->questions));
 
-        $table = new quiz_report_statistics_table($quiz , $questions, $reporturl);
+        $table = new quiz_report_statistics_table();
         $table->is_downloading($download, get_string('reportstatistics','quiz_statistics'),
                     "$course->shortname ".format_string($quiz->name,true));
         if (!$table->is_downloading()) {
@@ -261,8 +261,16 @@ class quiz_report extends quiz_default_report {
             $quizattsstatistics->data[] = array(get_string('standarderror', 'quiz_statistics'), 
                 quiz_report_scale_sumgrades_as_percentage($standarderror, $quiz));
             print_table($quizattsstatistics);
-
+            
+        }
+        if (!$table->is_downloading()){
+            print_heading(get_string('quizstructureanalysis', 'quiz_statistics'));
+        }
+        $table->setup($quiz, $cm->id, $reporturl);
+        foreach ($questions as $question){
+            $table->add_data_keyed($table->format_row($question));
         }
+        $table->finish_output();
         return true;
     }
 
index 38941bb398b0f13cf99dea5ed0ee9a47baa48bf6..6d4889c36a29a6ff033726d90e37c6939b084703 100644 (file)
 <?php  // $Id$
 
-class quiz_report_statistics_table extends table_sql {
+class quiz_report_statistics_table extends flexible_table {
     
-    var $useridfield = 'userid';
+    var $quiz; 
     
-    var $candelete;
-    var $reporturl;
-    var $displayoptions;
-    
-    function quiz_report_statistics_table($quiz , $questions, $reporturl){
-        parent::table_sql('mod-quiz-report-statistics-report');
-        $this->quiz = $quiz;
-        $this->questions = $questions;
-        $this->reporturl = $reporturl;
+    function quiz_report_statistics_table(){
+        parent::flexible_table('mod-quiz-report-statistics-report');
     }
-    function build_table(){
-        global $CFG, $DB;
 
-        if ($this->rawdata) {
-            // Define some things we need later to process raw data from db.
-            $this->strtimeformat = get_string('strftimedatetime');
-            parent::build_table();
-            //end of adding data from attempts data to table / download
-            //now add averages at bottom of table :
-            $averagesql = "SELECT AVG(qg.grade) AS grade " .
-                    "FROM {quiz_grades} qg " .
-                    "WHERE quiz=".$this->quiz->id;
-                    
-            $this->add_separator();
-            if ($this->is_downloading()){
-                $namekey = 'lastname';
-            } else {
-                $namekey = 'fullname';
-            }
-            if ($this->groupstudents){
-                $groupaveragesql = $averagesql." AND qg.userid IN ($this->groupstudents)";
-                $groupaverage = $DB->get_record_sql($groupaveragesql);
-                $groupaveragerow = array($namekey => get_string('groupavg', 'grades'),
-                        'sumgrades' => round($groupaverage->grade, $this->quiz->decimalpoints),
-                        'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($groupaverage->grade, $this->quiz->id)));
-                if($this->detailedmarks && $this->qmsubselect) {
-                    $avggradebyq = quiz_get_average_grade_for_questions($this->quiz, $this->groupstudents);
-                    $groupaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $this->questions, $this->quiz, $this->is_downloading());
-                }
-                $this->add_data_keyed($groupaveragerow);
-            }
-            $overallaverage = $DB->get_record_sql($averagesql." AND qg.userid IN ($this->students)");
-            $overallaveragerow = array($namekey => get_string('overallaverage', 'grades'),
-                        'sumgrades' => round($overallaverage->grade, $this->quiz->decimalpoints),
-                        'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($overallaverage->grade, $this->quiz->id)));
-            if($this->detailedmarks && $this->qmsubselect) {
-                $avggradebyq = quiz_get_average_grade_for_questions($this->quiz, $this->students);
-                $overallaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $this->questions, $this->quiz, $this->is_downloading());
-            }
-            $this->add_data_keyed($overallaveragerow);
-        }
-    }
-    
-    function wrap_html_start(){
-        if (!$this->is_downloading()) {
-            if ($this->candelete) {
-                // Start form
-                $strreallydel  = addslashes_js(get_string('deleteattemptcheck','quiz'));
-                echo '<div id="tablecontainer">';
-                echo '<form id="attemptsform" method="post" action="' . $this->reporturl->out(true) .
-                        '" onsubmit="confirm(\''.$strreallydel.'\');">';
-                echo $this->reporturl->hidden_params_out(array(), 0, $this->displayoptions);
-                echo '<div>';
-            }
-        }
-    }
-    function wrap_html_finish(){
-        if (!$this->is_downloading()) {
-            // Print "Select all" etc.
-            if ($this->candelete) {
-                echo '<table id="commands">';
-                echo '<tr><td>';
-                echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.
-                        get_string('selectall', 'quiz').'</a> / ';
-                echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.
-                        get_string('selectnone', 'quiz').'</a> ';
-                echo '&nbsp;&nbsp;';
-                echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
-                echo '</td></tr></table>';
-                // Close form
-                echo '</div>';
-                echo '</form></div>';
-            }
-        }
-    }
-
-    
-    function col_checkbox($attempt){
-        if ($attempt->attempt){
-            return '<input type="checkbox" name="attemptid[]" value="'.$attempt->attempt.'" />';
+    /**
+     * Setup the columns and headers and other properties of the table and then
+     * call flexible_table::setup() method.
+     */
+    function setup($quiz, $cmid, $reporturl){
+        $this->quiz = $quiz;
+        $this->cmid = $cmid;
+        // Define table columns
+        $columns = array();
+        $headers = array();
+        
+        $columns[]= 'number';
+        $headers[]= get_string('questionnumber', 'quiz_statistics');
+        
+        if (!$this->is_downloading()){
+            $columns[]= 'icon';
+            $headers[]= '';
+            $columns[]= 'actions';
+            $headers[]= '';
         } else {
-            return '';
+            $columns[]= 'qtype';
+            $headers[]= get_string('questiontype', 'quiz_statistics');
         }
-    }
-    
-    function col_picture($attempt){
-        global $COURSE;
-        return print_user_picture($attempt->userid, $COURSE->id, $attempt->picture, false, true);
+        $columns[]= 'name';
+        $headers[]= get_string('questionname', 'quiz');
+        
+        $columns[]= 'intended_weight';
+        $headers[]= get_string('intended_weight', 'quiz_statistics');
+        
+        $this->define_columns($columns);
+        $this->define_headers($headers);
+        $this->sortable(false);
+
+        // Set up the table
+        $this->define_baseurl($reporturl->out());
+
+        $this->collapsible(true);
+
+/*        $this->column_suppress('picture');
+        $this->column_suppress('fullname');
+        $this->column_suppress('idnumber');
+
+        $this->no_sorting('feedbacktext');
+
+        $this->column_class('picture', 'picture');
+        $this->column_class('lastname', 'bold');
+        $this->column_class('firstname', 'bold');
+        $this->column_class('fullname', 'bold');
+        $this->column_class('sumgrades', 'bold');*/
+        
+        $this->column_class('intended_weight', 'numcol');
+
+        $this->set_attribute('id', 'questionstatistics');
+        $this->set_attribute('class', 'generaltable generalbox boxaligncenter');
+
+        parent::setup();
     }
 
-    
-    function col_timestart($attempt){
-        if ($attempt->attempt) {
-            $startdate = userdate($attempt->timestart, $this->strtimeformat);
-            if (!$this->is_downloading()) {
-                return  '<a href="review.php?q='.$this->quiz->id.'&amp;attempt='.$attempt->attempt.'">'.$startdate.'</a>';
-            } else {
-                return  $startdate;
-            }
-        } else {
-            return  '-';
-        }
+
+    function col_name($question){
+        return $question->name;
+
     }
-    function col_timefinish($attempt){
-        if ($attempt->attempt) {
-            if ($attempt->timefinish) {
-                $timefinish = userdate($attempt->timefinish, $this->strtimeformat);
-                if (!$this->is_downloading()) {
-                    return '<a href="review.php?q='.$this->quiz->id.'&amp;attempt='.$attempt->attempt.'">'.$timefinish.'</a>';
-                } else {
-                    return $timefinish;
-                }
-            } else {
-                return  '-';
-            }
-        } else {
-            return  '-';
-        }
+    
+    function col_icon($question){
+        return print_question_icon($question, true);
     }
     
-    function col_duration($attempt){
-        if ($attempt->timefinish) {
-            return format_time($attempt->duration);
-        } elseif ($attempt->timestart) {
-            return get_string('unfinished', 'quiz');
-        } else {
-            return '-';
-        }
+    function col_number($question){
+        return $question->number;
     }
-    function col_sumgrades($attempt){
-        if ($attempt->timefinish) {
-            $grade = quiz_rescale_grade($attempt->sumgrades, $this->quiz);
-            if (!$this->is_downloading()) {
-                $gradehtml = '<a href="review.php?q='.$this->quiz->id.'&amp;attempt='.$attempt->attempt.'">'.$grade.'</a>';
-                if ($this->qmsubselect && $attempt->gradedattempt){
-                    $gradehtml = '<div class="highlight">'.$gradehtml.'</div>';
-                }
-                return $gradehtml;
-            } else {
-                return $grade;
-            }
-        } else {
-            return '-';
-        }
+    function col_actions($question){
+        return quiz_question_action_icons($this->quiz, $this->cmid, $question, $this->baseurl);
     }
-    function other_cols($colname, $attempt){
-        static $gradedstatesbyattempt = null;
-        if ($gradedstatesbyattempt === null){
-            //get all the attempt ids we want to display on this page
-            //or to export for download.
-            $attemptids = array();
-            foreach ($this->rawdata as $attempt){
-                if ($attempt->attemptuniqueid > 0){
-                    $attemptids[] = $attempt->attemptuniqueid;
-                }
-            }
-            $gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');
-        }
-        if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)){
-            $questionid = $matches[1];
-            $question = $this->questions[$questionid];
-            $stateforqinattempt = $gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
-            if (question_state_is_graded($stateforqinattempt)) {
-                $grade = quiz_rescale_grade($stateforqinattempt->grade, $this->quiz);
-            } else {
-                $grade = '--';
-            }
-            if (!$this->is_downloading()) {
-                $grade = $grade.'/'.quiz_rescale_grade($question->grade, $this->quiz);
-                return link_to_popup_window('/mod/quiz/reviewquestion.php?state='.
-                        $stateforqinattempt->id.'&amp;number='.$question->number,
-                        'reviewquestion', $grade, 450, 650, get_string('reviewresponse', 'quiz'),
-                        'none', true);
-            } else {
-                return $grade;
-            }     
-        } else {
-            return NULL;
-        }
+    function col_qtype($question){
+        return $question->qtype;
     }
-    
-    function col_feedbacktext($attempt){
-        if ($attempt->timefinish) {
-            if (!$this->is_downloading()) {
-                return quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz), $this->quiz->id);
-            } else {
-                return strip_tags(quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz), $this->quiz->id));
-            }
-        } else {
-            return '-';
-        }
-    
+    function col_intended_weight($question){
+        return quiz_report_scale_sumgrades_as_percentage($question->grade, $this->quiz);
     }
+            
+
 }
 ?>
index 2e0d86f70ae8a8fe5e5204a0f8c75179fb2452e8..500ea91afbd82937250a6e135166b7d6b5c02b3c 100644 (file)
@@ -3989,7 +3989,7 @@ table.quizreviewsummary td.cell {
 #mod-quiz-report table#itemanalysis .header {
   text-align: left;
 }
-#mod-quiz-report table#itemanalysis .numcol {
+#mod-quiz-report table .numcol {
   text-align: center;
   vertical-align : middle !important;
 }