예제 #1
0
파일: answer.php 프로젝트: socialweb/PiGo
 * **************************************************
 * @author iZAP Team "<*****@*****.**>"
 * @link http://www.izap.in/
 * Under this agreement, No one has rights to sell this script further.
 * For more information. Contact "Tarun Jangra<*****@*****.**>"
 * For discussion about corresponding plugins, visit http://www.pluginlotto.com/forum/
 * Follow us on http://facebook.com/PluginLotto and http://twitter.com/PluginLotto
 */
// checks if the user's logged in
izapbase::gatekeeper();
// this page saves the current answer of the user while the test is ongoing
// Get input data
$quiz_form = get_input('quiz');
// Cache to the session
// Make sure the title isn't blank
$quiz_entity = new IzapQuiz($quiz_form['guid']);
$quiz_entity->izap_grant_edit();
$challenge_entity = get_entity($quiz_entity->container_guid);
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;
예제 #2
0
        foreach (IzapBase::getFormErrors() as $error) {
            register_error(elgg_echo($error));
        }
    }
    forward(REFERRER);
    exit;
}
// Get input data
$quiz_form = IzapBase::getPostedAttributes();
if (!isset($quiz_form['correct_option'])) {
    register_error(elgg_echo('izap-contest:quiz:error:no_options'));
    forward(REFERER);
}
$_SESSION['zcontest']['quiz'] = $quiz_form;
// Make sure the title isn't blank
$quiz_entity = new IzapQuiz($quiz_form['guid']);
IzapBase::updatePostedAttribute('tags', string_to_tag_array($quiz_entity['tags']));
$quiz_entity->setAttributes();
if ($quiz_form['qtype'] == 'video') {
    $video_api = new IZAPVideoApi($quiz_form['related_media']);
    $video = $video_api->createVideoEntity();
    if (isset($video_api->errors)) {
        foreach ($video_api->errors as $error) {
            register_error($error);
        }
    }
    $quiz_entity->video_guid = $video->guid;
}
// Set its owner to the current user
$challenge_entity = get_entity($quiz_form['container_guid']);
if (!$quiz_form['guid']) {