Skip to content

Commit

Permalink
MDL-15729 "detailled responses report not showing responses"
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesensei committed Jul 21, 2008
1 parent 2c1363e commit 3e71541
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
6 changes: 3 additions & 3 deletions mod/quiz/report/responses/report.php
Expand Up @@ -177,7 +177,7 @@ function display($quiz, $cm, $course) {


// Construct the SQL
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, ';
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, ';
if ($qmsubselect) {
$fields .=
"(CASE " .
Expand All @@ -186,7 +186,7 @@ function display($quiz, $cm, $course) {
"END) AS gradedattempt, ";
}

$fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
$fields .='qa.uniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
' u.lastname, u.institution, u.department, u.email, u.picture, u.imagealt, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration, ' .
'qa.layout ';
Expand Down Expand Up @@ -303,7 +303,7 @@ function display($quiz, $cm, $course) {

$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'uniqueid');
$table->sortable(true, 'concattedid');

// Set up the table
$table->define_baseurl($reporturl->out(false, $displayoptions));
Expand Down
36 changes: 8 additions & 28 deletions mod/quiz/report/responses/responses_table.php
Expand Up @@ -20,21 +20,10 @@ function quiz_report_responses_table($quiz , $qmsubselect, $groupstudents,
$this->displayoptions = $displayoptions;
}
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 :
$params = array($this->quiz->id);

$this->add_separator();
if ($this->is_downloading()){
$namekey = 'lastname';
} else {
$namekey = 'fullname';
}
}
}

Expand Down Expand Up @@ -149,26 +138,17 @@ function col_sumgrades($attempt){
}
}
function other_cols($colname, $attempt){
static $gradedstatesbyattempt = null, $states =array();
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;
$states[$attempt->attemptuniqueid] = get_question_states($this->questions, $this->quiz, $attempt);
}
}
$gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');
}
static $states =array();
if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)){
if ($attempt->uniqueid > 0 && !isset($states[$attempt->uniqueid])){
$states[$attempt->uniqueid] = get_question_states($this->questions, $this->quiz, $attempt);
}
$statesforattempt = $states[$attempt->uniqueid];
$questionid = $matches[1];
$question = $this->questions[$questionid];
$stateforqinattempt = $gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
$responses = get_question_actual_response($question, $states[$attempt->attemptuniqueid][$questionid]);
$responses = get_question_actual_response($question, $statesforattempt[$questionid]);
$response = (!empty($responses)? implode(', ',$responses) : '-');
$grade = $stateforqinattempt->grade;
$grade = $statesforattempt[$questionid]->last_graded->grade;
if (!$this->is_downloading()) {
$format_options = new stdClass;
$format_options->para = false;
Expand All @@ -183,7 +163,7 @@ function other_cols($colname, $attempt){
}
return '<span class="'.$qclass.'">'.format_text($response, FORMAT_MOODLE, $format_options).'</span>';
} else {
return format_text($response, FORMAT_MOODLE, $format_options);
return $response;
}
} else {
return NULL;
Expand Down

0 comments on commit 3e71541

Please sign in to comment.