Example #1
0
 /**
  * Standard modular run function for award hooks. Renders a content box for an award/randomisation.
  *
  * @param  array		The database row for the content
  * @param  ID_TEXT	The zone to display in
  * @return tempcode	Results
  */
 function run($row, $zone)
 {
     require_code('quiz');
     return show_quiz_html($row, $zone);
 }
Example #2
0
 /**
  * The UI to browse quizzes/surveys/tests.
  *
  * @return tempcode		The UI
  */
 function archive()
 {
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $start = get_param_integer('start', 0);
     $title = get_page_title('QUIZZES');
     require_code('quiz');
     $max = get_param_integer('max', 20);
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'quizzes WHERE ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? 'q_validated=1 AND ' : '') . 'q_open_time<' . strval((int) time()) . ' AND (q_close_time IS NULL OR q_close_time>' . strval((int) time()) . ') ORDER BY q_type ASC,id DESC', $max, $start);
     $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'quizzes WHERE ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? 'q_validated=1 AND ' : '') . 'q_open_time<' . strval((int) time()) . ' AND (q_close_time IS NULL OR q_close_time>' . strval((int) time()) . ')');
     if (count($rows) == 0) {
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $content_tests = new ocp_tempcode();
     $content_competitions = new ocp_tempcode();
     $content_surveys = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $link = show_quiz_html($myrow);
         switch ($myrow['q_type']) {
             case 'SURVEY':
                 $content_surveys->attach($link);
                 break;
             case 'TEST':
                 $content_tests->attach($link);
                 break;
             case 'COMPETITION':
                 $content_competitions->attach($link);
                 break;
         }
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $num_pages = intval(ceil(floatval($max_rows) / floatval($max)));
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF');
     $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'ab0d27890dd2c1476dcdf82a46d5be90', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('QUIZ_ARCHIVE_SCREEN', array('_GUID' => '3073f74b500deba96b7a3031a2e9c8d8', 'TITLE' => $title, 'CONTENT_SURVEYS' => $content_surveys, 'CONTENT_COMPETITIONS' => $content_competitions, 'CONTENT_TESTS' => $content_tests, 'BROWSE' => $browse));
 }
Example #3
0
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     require_code('quiz');
     return show_quiz_html($row);
 }