Ejemplo n.º 1
0
$number_of_questions = $score[1];
$database = JFactory::getDBO();
$sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . $quiz_id;
$database->setQuery($sql);
$result_maxscore = $database->loadResult();
if ($number_of_questions > 0) {
    $score = intval($how_many_right_answers / $number_of_questions * 100);
} else {
    $score = 0;
}
if ($score >= $result_maxscore) {
    $score = $score . " %" . JText::_('GURU_QUIZ_PASSED');
} else {
    $score = $score . " %" . JText::_('GURU_QUIZ_FAILED');
}
$ans_gived = $guruModelguruOrder->getAnsGivedF($user_id, $id);
$ans_right = $guruModelguruOrder->getAnsRightF($quiz_id);
$the_question = $guruModelguruOrder->getQuestionNameF($id, $quiz_id);
$all_answers_array = $guruModelguruOrder->getAllAnsF($quiz_id, $id);
$all_answers_text_array = $guruModelguruOrder->getAllAnsTextF($quiz_id, $id);
for ($i = 0; $i < $number_of_questions; $i++) {
    $answer_count = 0;
    $all_answers_array_result = explode("|||", $all_answers_array[$i]);
    $all_answers_text_array_result = explode("|||", $all_answers_text_array[$i]);
    $ans_right_result = explode("|||", $ans_right[$i]->answers);
    $ans_gived_result = explode(" ||", $ans_gived[$i]->answers_gived);
    for ($t = 0; $t < count($ans_gived_result); $t++) {
        if ($ans_gived_result[$t] != "") {
            if (!in_array($ans_gived_result[$t], $ans_right_result)) {
                $gasit = false;
                break;