if(substr($sortpart, 0, 1) == '$') {
if(!$questionsort) {
$qid = intval(substr($sortpart, 1));
- $select .= ', grade ';
- $from .= ' LEFT JOIN '.$CFG->prefix.'question_sessions qns ON qns.attemptid = qa.id '.
+ $select .= ', qs.grade AS qgrade ';
+ $from .= ' LEFT JOIN '.$CFG->prefix.'question_sessions qns ON qns.attemptid = qa.uniqueid '.
'LEFT JOIN '.$CFG->prefix.'question_states qs ON qs.id = qns.newgraded ';
$where .= ' AND (qns.questionid IS NULL OR qns.questionid = '.$qid.')';
- $newsort[] = 'grade '.(strpos($sortpart, 'ASC')? 'ASC' : 'DESC');
+ $newsort[] = 'qgrade '.(strpos($sortpart, 'ASC')? 'ASC' : 'DESC');
$questionsort = true;
}
} else {
if (!$download) {
$table->initialbars($totalinitials>20);
}
-
if(!empty($attempts) || !empty($noattempts)) {
if ($attempts) {
foreach ($attempts as $attempt) {