forked from science-ation/science-ation
Properly load ALL questions for a user, even if they don't have answer records for some of them
This commit is contained in:
parent
522ea8206d
commit
5676c39b54
@ -26,16 +26,15 @@
|
|||||||
|
|
||||||
function questions_load_answers($section, $users_id)
|
function questions_load_answers($section, $users_id)
|
||||||
{
|
{
|
||||||
$q = mysql_query('SELECT question_answers.*, questions.* '.
|
global $config;
|
||||||
'FROM question_answers '.
|
$yearq=mysql_query("SELECT `year` FROM users WHERE id='$users_id'");
|
||||||
'LEFT JOIN questions ON questions.id=question_answers.questions_id '.
|
$yearr=mysql_fetch_object($yearq);
|
||||||
"WHERE users_id='$users_id' ".
|
$ans=array();
|
||||||
" AND questions.section='$section' ".
|
$qs=questions_load_questions($section,$yearr->year);
|
||||||
'ORDER BY questions.ord ASC');
|
foreach($qs AS $id=>$question) {
|
||||||
|
$q=mysql_query("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'");
|
||||||
$ans = array();
|
$r=mysql_fetch_object($q);
|
||||||
while($r=mysql_fetch_object($q)) {
|
$ans[$id]=$r->answer;
|
||||||
$ans[$r->questions_id] = $r->answer;
|
|
||||||
}
|
}
|
||||||
return $ans;
|
return $ans;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user