/** * Print table with import errors. */ public function error_report($offlinequiz, $courseid) { global $CFG, $USER, $DB, $OUTPUT; $nologs = optional_param('nologs', 0, PARAM_INT); $pagesize = optional_param('pagesize', 10, PARAM_INT); $sql = "SELECT *\n FROM {offlinequiz_scanned_p_pages}\n WHERE status = 'error'\n AND offlinequizid = :offlinequizid"; $countsql = "SELECT COUNT(*)\n FROM {offlinequiz_scanned_p_pages}\n WHERE status = 'error'\n AND offlinequizid = :offlinequizid"; $params = array('offlinequizid' => $offlinequiz->id); $cparams = array('offlinequizid' => $offlinequiz->id); $tableparams = array('q' => $offlinequiz->id, 'mode' => 'upload', 'pagesize' => $pagesize, 'action' => 'delete', 'strreallydel' => addslashes(get_string('deletepagecheck', 'offlinequiz'))); $table = new offlinequiz_selectall_table('mod-offlinequiz-participants-error', 'participants.php', $tableparams); // Add extra limits due to initials bar. list($ttest, $tparams) = $table->get_sql_where(); if (!empty($ttest)) { $sql .= ' AND ' . $ttest; $params = array_merge($params, $tparams); } if (!empty($countsql)) { $totalinitials = $DB->count_records_sql($countsql, $params); if (!empty($ttest)) { $countsql .= ' AND ' . $ttest; $cparams = array_merge($cparams, $tparams); } $total = $DB->count_records_sql($countsql, $cparams); } // Define table columns. $tablecolumns = array('checkbox', 'time', 'error', 'scan'); $tableheaders = array('', get_string('importedon', 'offlinequiz_rimport'), get_string('error'), ''); $table->define_columns($tablecolumns); $table->define_headers($tableheaders); $baseurl = new moodle_url('/mod/offlinequiz/participants.php', array('q' => $offlinequiz->id, 'mode' => 'upload')); $table->define_baseurl($baseurl); $table->sortable(true); $table->no_sorting('checkbox'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'logs'); $table->set_attribute('class', 'generaltable generalbox'); // Start working -- this is necessary as soon as the niceties are over. $table->setup(); if ($sort = $table->get_sql_sort()) { $sql .= ' ORDER BY ' . $sort; } $table->initialbars($totalinitials > 20); $strtimeformat = get_string('strftimedatetime'); if (!($pages = $DB->get_records_sql($sql, $params))) { return; } // Options for the popup_action. $options = array(); $options['height'] = 1200; // Optional. $options['width'] = 1170; // Optional. $options['resizable'] = false; $counter = 1; foreach ($pages as $page) { $url = new moodle_url($CFG->wwwroot . '/mod/offlinequiz/participants_correct.php?pageid=' . $page->id); $title = get_string('correcterror', 'offlinequiz_rimport'); $actionlink = $OUTPUT->action_link($url, $title, new popup_action('click', $url, 'correct' . $page->id, $options)); $errorstr = ''; if (!empty($page->error)) { $errorstr = get_string('error' . $page->error, 'offlinequiz_rimport'); } $row = array('<input type="checkbox" name="pageid[]" value="' . $page->id . '" />', userdate($page->time, $strtimeformat), $errorstr, $actionlink); $table->add_data($row); $counter++; } echo $OUTPUT->heading(get_string('errorreport', 'offlinequiz'), 3, ''); // Print table. $table->print_html(); }