$action = optional_param('action', "", PARAM_ALPHANUM); // action if ($action == 'delstats') { $DB->delete_records('game_repetitions', array('gameid' => $game->id, 'userid' => $USER->id)); } if ($action == 'computestats') { game_compute_repetitions($game); } echo '<b>' . get_string('repetitions', 'game') . ': </b>'; echo get_string('user') . ': '; game_showusers($game); echo " <a href=\"{$CFG->wwwroot}/mod/game/showanswers.php?q={$q}&action=delstats\">" . get_string('clearrepetitions', 'game') . '</a>'; echo " <a href=\"{$CFG->wwwroot}/mod/game/showanswers.php?q={$q}&action=computestats\">" . get_string('computerepetitions', 'game') . '</a>'; echo '<br><br>'; $existsbook = $DB->get_record('modules', array('name' => 'book'), 'id,id'); game_showanswers($game, $existsbook); echo $OUTPUT->footer(); function game_compute_repetitions($game) { global $DB, $USER; $DB->delete_records('game_repetitions', array('gameid' => $game->id, 'userid' => $USER->id)); $sql = "INSERT INTO {game_repetitions}( gameid,userid,questionid,glossaryentryid,repetitions) " . "SELECT {$game->id},{$USER->id},questionid,glossaryentryid,COUNT(*) " . "FROM {game_queries} WHERE gameid={$game->id} AND userid={$USER->id} GROUP BY questionid,glossaryentryid"; if (!$DB->execute($sql)) { print_error('Problem on computing statistics for repetitions'); } } function game_showusers($game) { global $CFG, $USER; $users = array(); $context = get_context_instance(CONTEXT_COURSE, $game->course);
$action = optional_param('action', "", PARAM_ALPHANUM); // Action. if ($action == 'delstats') { $DB->delete_records('game_repetitions', array('gameid' => $game->id, 'userid' => $USER->id)); } if ($action == 'computestats') { game_compute_repetitions($game); } echo '<b>' . get_string('repetitions', 'game') . ': </b>'; echo get_string('user') . ': '; game_showusers($game); echo " <a href=\"{$CFG->wwwroot}/mod/game/showanswers.php?q={$q}&action=delstats\">" . get_string('clearrepetitions', 'game') . '</a>'; echo " <a href=\"{$CFG->wwwroot}/mod/game/showanswers.php?q={$q}&action=computestats\">" . get_string('computerepetitions', 'game') . '</a>'; echo '<br><br>'; $existsbook = $DB->get_record('modules', array('name' => 'book'), 'id,id'); game_showanswers($game, $existsbook, $context); echo $OUTPUT->footer(); function game_compute_repetitions($game) { global $DB, $USER; $DB->delete_records('game_repetitions', array('gameid' => $game->id, 'userid' => $USER->id)); $sql = "INSERT INTO {game_repetitions}( gameid,userid,questionid,glossaryentryid,repetitions) " . "SELECT {$game->id},{$USER->id},questionid,glossaryentryid,COUNT(*) " . "FROM {game_queries} WHERE gameid={$game->id} AND userid={$USER->id} GROUP BY questionid,glossaryentryid"; if (!$DB->execute($sql)) { print_error('Problem on computing statistics for repetitions'); } } function game_showusers($game) { global $CFG, $USER; $users = array(); $context = game_get_context_course_instance($game->course);