Пример #1
0
if (!$user->user_exists) {
    $page = "error";
    $smarty->assign('error_header', 639);
    $smarty->assign('error_message', 656);
    $smarty->assign('error_submit', 641);
    include "footer.php";
}
$quiz_info = he_quiz::get_quiz_info($quiz_id);
if (!$quiz_info) {
    $page = "error";
    $smarty->assign('error_header', 639);
    $smarty->assign('error_message', 690691178);
    $smarty->assign('error_submit', 641);
    include "footer.php";
}
$steps = he_quiz::check_steps($quiz_id);
if (array_sum($steps) < 4 || $quiz_info['status'] == 0) {
    $page = "error";
    $smarty->assign('error_header', 639);
    $smarty->assign('error_message', 690691179);
    $smarty->assign('error_submit', 641);
    include "footer.php";
}
$quiz_questions = he_quiz::get_quiz_questions($quiz_id);
$message = array();
if ($task == 'get_result') {
    $answers = $_POST['answer'];
    $result_id = he_quiz::save_user_play($user->user_info['user_id'], $quiz_id, $answers);
    if ($result_id) {
        $replace_arr = array($user->user_info['user_username'], $user->user_displayname, $quiz_id, $quiz_info['name']);
        $actions->actions_add($user, 'playquiz', $replace_arr);
Пример #2
0
 function user_quiz_list($user_id, $first, $count)
 {
     if (!$user_id) {
         return array();
     }
     $query = he_database::placeholder("SELECT * FROM `se_he_quiz`\r\n            WHERE `user_id`=? ORDER BY `status` DESC LIMIT ?, ?", $user_id, $first, $count);
     $res = he_database::query($query);
     $quiz_list = array();
     $quiz_ids = array();
     while ($quiz = he_database::fetch_row_from_resource($res)) {
         $quiz_ids[] = $quiz['quiz_id'];
         $steps = he_quiz::check_steps($quiz['quiz_id']);
         $quiz['takes'] = 0;
         $quiz['photo_url'] = $quiz['photo'] ? he_quiz::photo_url() . $quiz['photo'] : '';
         $quiz['steps'] = $steps;
         $quiz['can_publish'] = array_sum($steps) == 4;
         $quiz_list[$quiz['quiz_id']] = $quiz;
     }
     if (count($quiz_ids)) {
         $quiz_ids_str = implode(', ', $quiz_ids);
         $res = he_database::query("SELECT `quiz_id`, COUNT(`id`) AS `count` FROM `se_he_quiz_play`\r\n                WHERE `quiz_id` IN ({$quiz_ids_str}) GROUP BY `quiz_id`");
         while ($take = he_database::fetch_row_from_resource($res)) {
             $quiz_list[$take['quiz_id']]['takes'] = $take['count'];
         }
     }
     return $quiz_list;
 }