dirroot.'/course/moodleform_mod.php'); require( '../locallib.php'); require_once( "../header.php"); $currenttab = 'bookquiz'; include('../tabs.php'); $attempt = game_getattempt( $game, $detail); if( $game->bookid == 0){ error( get_string( 'bookquiz_not_select_book', 'game')); } if ($form = data_submitted()) { /// Filename $ids = explode( ',', $form->ids); game_bookquiz_save( $game->id, $game->bookid, $ids, $form); redirect( "$CFG->wwwroot/mod/game/bookquiz/questions.php?id=$cm->id", '', 0); } /// Print upload form print_heading_with_help( get_string( 'bookquiz_questions', 'game'), 'questions', 'game'); print_simple_box_start( 'center'); $select = "gameid={$game->id}"; $categories = array(); if( ($recs = get_records_select( 'game_bookquiz_questions', $select, '', 'chapterid,questioncategoryid')) != false){ foreach( $recs as $rec){ $categories[ $rec->chapterid] = $rec->questioncategoryid; } } $select = ''; $top = 0; $recs = get_records_select( 'question_categories', '', '', '*', 0, 1); foreach( $recs as $rec){ if( array_key_exists( 'course', $rec)){ $select = "course=$cm->course"; $categoriesarray = question_category_options($game->course, $top, $currentcat, false, $nochildrenof); }else{ $context = get_context_instance(50, $cm->course); $select = " contextid in ($context->id)"; require_once($CFG->dirroot.'/lib/questionlib.php'); $categoriesarray = question_category_options(game_get_contexts(), $top); } break; } /* $sql = "SELECT chapterid, COUNT(*) as c ". "FROM {$CFG->prefix}game_bookquiz_questions gbq,{$CFG->prefix}question q ". "WHERE gbq.questioncategoryid=q.category ". "AND gameid=$game->id AND hidden=0 ". "GROUP BY chapterid"; $numbers = array(); if( ($recs = get_records_sql( $sql)) != false){ foreach( $recs as $rec){ $numbers[ $rec->chapterid] = $rec->c; } } */ echo '