Example #1
0
 // Print the report heading.
 echo $OUTPUT->heading($title);
 // Initialise the table.
 $table = new html_table();
 $table->head = array(get_string('context', 'role'), get_string('totalquestions', 'report_questioninstances'), get_string('visiblequestions', 'report_questioninstances'), get_string('hiddenquestions', 'report_questioninstances'));
 $table->data = array();
 $table->class = '';
 $table->id = '';
 // Add the data for each row.
 $totalquestions = 0;
 $totalvisible = 0;
 $totalhidden = 0;
 foreach ($counts as $count) {
     // Work out a link for editing questions in this context.
     $contextname = print_context_name($count);
     $url = question_edit_url($count);
     if ($url) {
         $contextname = '<a href="' . $url . '" title="' . get_string('editquestionshere', 'report_questioninstances') . '">' . $contextname . '</a>';
     }
     // Put the scores in the table.
     $numvisible = $count->numquestions - $count->numhidden;
     $table->data[] = array($contextname, $count->numquestions, $numvisible, $count->numhidden);
     // Update the totals.
     $totalquestions += $count->numquestions;
     $totalvisible += $numvisible;
     $totalhidden += $count->numhidden;
 }
 // Add a totals row.
 $table->data[] = array('<b>' . get_string('total') . '</b>', $totalquestions, $totalvisible, $totalhidden);
 // Print it.
 echo $OUTPUT->table($table);
Example #2
0
            get_string('visiblequestions', 'report_questioninstances'),
            get_string('hiddenquestions', 'report_questioninstances'));
    $table->data = array();
    $table->class = '';
    $table->id = '';

    // Add the data for each row.
    $totalquestions = 0;
    $totalvisible = 0;
    $totalhidden = 0;
    foreach ($counts as $count) {
        // Work out a link for editing questions in this context.
        context_helper::preload_from_record($count);
        $context = context::instance_by_id($count->contextid);
        $contextname = $context->get_context_name();
        $url = question_edit_url($context);
        if ($url) {
            $contextname = '<a href="' . $url . '" title="' .
                    get_string('editquestionshere', 'report_questioninstances') .
                    '">' . $contextname . '</a>';
        }

        // Put the scores in the table.
        $numvisible = $count->numquestions - $count->numhidden;
        $table->data[] = array(
                $contextname,
                $count->numquestions,
                $numvisible,
                $count->numhidden);

        // Update the totals.