Skip to content

Commit

Permalink
[BugFix] Bug #5072: user name now links to user profile, Attempts col…
Browse files Browse the repository at this point in the history
…umn changed to Completed On, new column with link Grade to grade all attempts. Other table changes include collapsible columns and its id has been changed to attempts to reuse styles for the attempts table.
  • Loading branch information
mark-nielsen committed Apr 11, 2006
1 parent 6e63c77 commit 804d664
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions mod/quiz/report/grading/report.php
Expand Up @@ -187,8 +187,8 @@ function view_question($quiz, $question) {
$usercount = count($users); $usercount = count($users);


// set up table // set up table
$tablecolumns = array('picture', 'fullname', 'attempt'); $tablecolumns = array('picture', 'fullname', 'attempt', 'grade');
$tableheaders = array('', get_string('fullname'), get_string("attempts", "quiz")); $tableheaders = array('', get_string('fullname'), get_string("completedon", "quiz"), '');


$table = new flexible_table('mod-quiz-report-grading'); $table = new flexible_table('mod-quiz-report-grading');


Expand All @@ -199,24 +199,26 @@ function view_question($quiz, $question) {
$table->sortable(true); $table->sortable(true);
$table->initialbars($usercount>20); // will show initialbars if there are more than 20 users $table->initialbars($usercount>20); // will show initialbars if there are more than 20 users
$table->pageable(true); $table->pageable(true);
$table->collapsible(true);


$table->column_suppress('fullname'); $table->column_suppress('fullname');
$table->column_suppress('picture'); $table->column_suppress('picture');
$table->column_suppress('grade');


$table->column_class('picture', 'picture'); $table->column_class('picture', 'picture');


// attributes in the table tag // attributes in the table tag
$table->set_attribute('cellspacing', '0'); $table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'grading'); $table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox'); $table->set_attribute('class', 'generaltable generalbox');
$table->set_attribute('align', 'center'); $table->set_attribute('align', 'center');
$table->set_attribute('width', '50%'); //$table->set_attribute('width', '50%');


// get it ready! // get it ready!
$table->setup(); $table->setup();


// this sql is a join of the attempts table and the user table. I do this so I can sort by user name and attempt number (not id) // this sql is a join of the attempts table and the user table. I do this so I can sort by user name and attempt number (not id)
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid, qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timestart, u.id AS userid, u.firstname, u.lastname, u.picture '; $select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid, qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, u.id AS userid, u.firstname, u.lastname, u.picture ';
$from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = '.$quiz->id.') '; $from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = '.$quiz->id.') ';
$where = 'WHERE u.id IN ('.$userids.') '; $where = 'WHERE u.id IN ('.$userids.') ';
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 '; $where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
Expand Down Expand Up @@ -251,8 +253,8 @@ function view_question($quiz, $question) {


$picture = print_user_picture($attempt->userid, $quiz->course, $attempt->picture, false, true); $picture = print_user_picture($attempt->userid, $quiz->course, $attempt->picture, false, true);


// link here... grades all for this student // link to student profile
$userlink = "<a href=\"report.php?mode=grading&amp;action=grade&amp;q=$quiz->id&amp;questionid=$question->id&amp;userid=$attempt->userid\">". $userlink = "<a href=\"$CFG->wwwroot/user/view.php?id=$attempt->userid&amp;course=$quiz->course\">".
fullname($attempt, true).'</a>'; fullname($attempt, true).'</a>';


if (!$this->is_graded($question, $attempt)) { if (!$this->is_graded($question, $attempt)) {
Expand All @@ -263,9 +265,13 @@ function view_question($quiz, $question) {


// link for the attempt // link for the attempt
$attemptlink = "<a $style href=\"report.php?mode=grading&amp;action=grade&amp;q=$quiz->id&amp;questionid=$question->id&amp;attemptid=$attempt->attemptid\">". $attemptlink = "<a $style href=\"report.php?mode=grading&amp;action=grade&amp;q=$quiz->id&amp;questionid=$question->id&amp;attemptid=$attempt->attemptid\">".
userdate($attempt->timestart, get_string('strftimedatetime')).'</a>'; userdate($attempt->timefinish, get_string('strftimedatetime')).'</a>';

// grade all attempts for this user
$gradelink = "<a href=\"report.php?mode=grading&amp;action=grade&amp;q=$quiz->id&amp;questionid=$question->id&amp;userid=$attempt->userid\">".
get_string('grade').'</a>';


$table->add_data( array($picture, $userlink, $attemptlink) ); $table->add_data( array($picture, $userlink, $attemptlink, $gradelink) );
} }
} }


Expand Down

0 comments on commit 804d664

Please sign in to comment.