if (!$challenge_entity->can_play()) { register_error(elgg_echo('izap-contest:challenge:not_accepted_yet')); forward($challenge_entity->getURL()); } // check time... if user can answer if (!$challenge_entity->timeLeft()) { register_error(elgg_echo('izap-contest:challenge:error:timeout')); $result = $challenge_entity->save_results(FALSE); forward(IzapBase::setHref(array('context' => GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER, 'action' => 'result', 'page_owner' => false, 'vars' => array($challenge_entity->guid, $result->guid, elgg_get_friendly_title($challenge_entity->title))))); } // set total to zero, if it is not set yet, to calculate the negative marking. if (!isset($_SESSION['challenge'][$challenge_entity->guid]['totals'])) { $_SESSION['challenge'][$challenge_entity->guid]['totals'] = 0; } // get all access from the system to user Izapbase::getAllAccess(); // all answers $answers_array = unserialize($quiz_entity->options); $answer_var = elgg_get_logged_in_user_entity()->username . '_answer'; $correct_var = elgg_get_logged_in_user_entity()->username . '_is_correct'; if ($quiz_form['answer'] == 'Answer' && $quiz_entity->correct_option == $quiz_form['correct_option']) { $quiz_entity->{$correct_var} = 'yes'; $_SESSION['challenge'][$challenge_entity->guid]['answers'][$quiz_entity->guid]['is_correct'] = TRUE; $_SESSION['challenge'][$challenge_entity->guid]['totals']++; $_SESSION['challenge'][$challenge_entity->guid]['total_correct_answers']++; } else { $quiz_entity->{$correct_var} = 'no'; $_SESSION['challenge'][$challenge_entity->guid]['answers'][$quiz_entity->guid]['is_correct'] = FALSE; if ($quiz_form['answer'] == 'Answer') { if ($challenge_entity->negative_marking) { $_SESSION['challenge'][$challenge_entity->guid]['totals']--;