<table cellpadding="9" cellspacing="0">
<?php if($this->instance->pagetype != 'mod-quiz-view') { ?>
<tr valign="top">
    <td align="right">
        <?php print_string('config_select_quiz', 'block_quiz_results') ?>
    </td>
    <td>
        <?php
            $quizzes = get_records('quiz', 'course', $this->instance->pageid, '', 'id, name');
            if(empty($quizzes)) {
                echo '<strong>'.get_string('config_no_quizzes_in_course', 'block_quiz_results').'</strong>';
                echo '<p><input type="hidden" name="quizid" value="0" /></p>';
            }
            else {
                $options = array();
                foreach($quizzes as $quiz) {
                    $options[$quiz->id] = $quiz->name;
                }
                choose_from_menu($options, 'quizid', empty($this->config->quizid) ? 0 : $this->config->quizid);
            }
        ?>
    </td>
</tr>
<?php } // end if($this->instance->pagetype != PAGE_QUIZ_VIEW) ?>
<tr valign="top">
    <td align="right">
        <?php print_string('config_show_best', 'block_quiz_results') ?>
    </td>
    <td>
        <input name="showbest" type="text" size="3" value="<?php
            p(empty($this->config->showbest) ? 0 : max(0, intval($this->config->showbest)));
        ?>" />
    </td>
</tr>
<tr valign="top">
    <td align="right">
        <?php print_string('config_show_worst', 'block_quiz_results') ?>
    </td>
    <td>
        <input name="showworst" type="text" size="3" value="<?php
            p(empty($this->config->showworst) ? 0 : max(0, intval($this->config->showworst)));
        ?>" />
    </td>
</tr>
<tr valign="top">
    <td align="right">
        <?php print_string('config_use_groups', 'block_quiz_results') ?>
    </td>
    <td>
        <input name="usegroups" type="radio" id="usegroups_yes" <?php if(!empty($this->config->usegroups)) echo 'checked="checked"'; ?> value="1" /> <label for="usegroups_yes"><?php print_string('yes'); ?></label>
        <input name="usegroups" type="radio" id="usegroups_no"  <?php if(empty($this->config->usegroups)) echo 'checked="checked"'; ?> value="0" /> <label for="usegroups_no"><?php print_string('no'); ?></label>
    </td>
</tr>
<tr valign="top">
    <td align="right">
        <?php print_string('config_name_format', 'block_quiz_results') ?>
    </td>
    <td>
    <?php
        $usenames = array(B_QUIZRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_quiz_results'), B_QUIZRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_quiz_results'), B_QUIZRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_quiz_results'));
        choose_from_menu($usenames, 'nameformat', empty($this->config->nameformat) ? B_QUIZRESULTS_NAME_FORMAT_FULL : $this->config->nameformat, '');
    ?>
    </td>
</tr>
<tr valign="top">
    <td align="right">
        <?php print_string('config_grade_format', 'block_quiz_results') ?>
    </td>
    <td>
    <?php
        $formats = array(B_QUIZRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_quiz_results'), B_QUIZRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_quiz_results'), B_QUIZRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_quiz_results'));
        choose_from_menu($formats, 'gradeformat', empty($this->config->gradeformat) ? 0 : $this->config->gradeformat, '');
    ?>
    </td>
</tr>
<tr>
    <td colspan="2" align="center">
        <input type="submit" value="<?php print_string('savechanges') ?>">
    </td>
</tr>
</table>