/** * this functions begins the accepted challenge */ public function actionPlay() { $container_guid = $this->url_vars[1]; $start = (bool) $_SESSION['proper_started'][$container_guid]; $contest = new IzapChallenge($container_guid, $start); if (!$_SESSION['challenge'][$contest->guid] || $_SESSION['challenge'][$contest->guid]['completed'] == true) { forward(IzapBase::setHref(array('context' => GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER, 'action' => 'result', 'vars' => array($contest->guid, elgg_get_friendly_title($this->title))))); } if (!$contest->can_play()) { register_error(elgg_echo('izap-contest:challenge:not_accepted_yet')); forward($contest->getURL()); } /** $exit_action = elgg_view('output/confirmlink', array( 'text' => elgg_echo('izap-contest:challenge:play:exit'), 'href' => IzapBase::setHref(array( 'context' => GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER, 'action' => 'saveResults', 'page_handler' => FALSE, 'vars' => array($this->url_vars[1]) )), 'class' => 'elgg-button elgg-button-submit', 'confirm' => elgg_echo('izap-contest-challenge:are_you_sure'))); **/ // $exit_action = '<div style="float:right">' . $exit_action . '</div>'; $quiz = $contest->current_question(); $this->page_elements['title'] = elgg_echo('izap-contest:challenge', array($contest->title)); $this->page_elements['content'] = elgg_view(GLOBAL_IZAP_CONTEST_PLUGIN . '/challenge/playing', array('challenge' => $contest, 'quiz' => $quiz)); $this->page_elements['content'] .= $exit_action; $this->drawPage(); }
} //save the media for the quiz $challenge_entity->izap_upload_generate_thumbs($_FILES, $thumb); if (!$challenge_entity->save()) { register_error(elgg_echo("Error in challenge creation")); forward(REFERER); } // checks the format of the uploaded files, if it is authorised if (!empty($_FILES['related_media']['name'])) { $supproted_media = array('audio/mp3', 'image/jpeg', 'image/gif', 'image/png', 'image/jpg', 'image/jpe', 'image/pjpeg', 'image/x-png'); if (!in_array($_FILES['related_media']['type'], $supproted_media)) { register_error(elgg_echo('izap-contest:no file support')); forward(REFERER); //failed, so forward to previous page } } // saves the uploaded files IzapBase::saveImageFile(array('destination' => 'contest/' . $challenge_entity->guid . '/icon', 'content' => file_get_contents($_FILES['related_media']['tmp_name']), 'owner_guid' => $challenge_entity->owner_guid, 'create_thumbs' => True)); // This will inherit the access_id from challenge to quiz. Check if the entity is going to be edit //if so than check if the old access id same. if so than skip this process. if (isset($challenge_form['guid']) && $old_challenge_access_id != $challenge_entity->access_id) { $quizzes_in_this_challenge = elgg_get_entities(array('type' => 'object', 'subtype' => GLOBAL_IZAP_CONTEST_QUIZ_SUBTYPE, 'container_guid' => $challenge_form['guid'])); foreach ($quizzes_in_this_challenge as $quiz_key => $quiz_entity) { $quiz_entity->access_id = $challenge_entity->access_id; $quiz_entity->save(); } } system_message($challenge_form['guid'] ? "Challenge updated successfully" : "Challenge created successfully"); unset($_SESSION['zcontest']['challenge']); forward($challenge_entity->getURL());