(stderr: PHP Warning: Creating default object from empty value in /ww_work/base/exam_class.php on line 1785,)
I'm no php programmer but apache logs are being filled with the creating default object from empty value array in the below function.
// this function put exam answer by student ito exm object.
// it also give the score to question if answer was correct.
public function put_answer($question_id,$answer_id){
$this->given_answer[$question_id]=$answer_id;
$question_obj = $this->questions[$question_id];
//$answer_obj = new stdClass();
$answer_obj = $question_obj->answer[$answer_id];
$answer_obj->given_answer="Y";
if(($answer_obj->given_answer==="Y")&&($answer_obj->correct_answer==="Y")){
$question_obj->given_mark=$given_mark + $question_obj->score;
$question_obj->given_answer=$answer_id;
$question_obj->question_result="right";
}else{
$question_obj->given_mark=$given_mark + 0;
//$answer_obj->given_answer="N";
}
}
The error is being generated on the $answer_obj->given_answer="Y";
line.
Doing some googling i think this may be loosely connected (Creating default object from empty value in PHP?)
But if anyone has any ideas on how I can remove this warning, apart from turning off php warnings, it would be greatly appreciated.