'.$row['title'].'
';
//get all the questions in this test, store them
$sql = "SELECT TQ.*, TQA.* FROM ".TABLE_PREFIX."tests_questions TQ INNER JOIN ".TABLE_PREFIX."tests_questions_assoc TQA USING (question_id) WHERE TQ.course_id=$_SESSION[course_id] AND TQA.test_id=$tid ORDER BY TQA.ordering, TQA.question_id";
$result = mysql_query($sql, $db);
$questions = array();
while ($row = mysql_fetch_assoc($result)) {
$questions[$row['question_id']] = $row;
}
$long_qs = substr($long_qs, 0, -1);
//get the answers: count | q_id | answer
$sql = "SELECT count(*), A.question_id, A.answer, A.score
FROM ".TABLE_PREFIX."tests_answers A, ".TABLE_PREFIX."tests_results R
WHERE R.status=1 AND R.result_id=A.result_id AND R.final_score<>'' AND R.test_id=$tid";
if ($_POST["user_type"] == 1) $sql .= " AND R.member_id not like 'G_%' AND R.member_id > 0 ";
if ($_POST["user_type"] == 2) $sql .= " AND (R.member_id like 'G_%' OR R.member_id = 0) ";
$sql .= " GROUP BY A.question_id, A.answer
ORDER BY A.question_id, A.answer";
$result = mysql_query($sql, $db);
?>