Skip to content

Instantly share code, notes, and snippets.

@mkolb
Created January 31, 2014 20:51
Show Gist options
  • Save mkolb/8742894 to your computer and use it in GitHub Desktop.
Save mkolb/8742894 to your computer and use it in GitHub Desktop.
Unstaged changes:
Modified mod/quiz/edit.php
diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php
index 884fa23..ce331bf 100644
--- a/mod/quiz/edit.php
+++ b/mod/quiz/edit.php
@@ -84,15 +84,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
question_bank::get_qtype('random')->get_available_questions_from_category(
$category->id, $recurse);
$maxrand = count($randomusablequestions);
- if ($maxrand > 0) {
- for ($i = 1; $i <= min(10, $maxrand); $i++) {
- $randomcount[$i] = $i;
- }
- for ($i = 20; $i <= min(100, $maxrand); $i += 10) {
- $randomcount[$i] = $i;
- }
- } else {
- $randomcount[0] = 0;
+ if ($maxrand == 0) {
$disabled = ' disabled="disabled"';
}
@@ -100,7 +92,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
'</label></strong><br />';
$attributes = array();
$attributes['disabled'] = $disabled ? 'disabled' : null;
- $select = html_writer::select($randomcount, 'randomcount', '1', null, $attributes);
+ $select = html_writer::select(range(1,$maxrand), 'randomcount', '1', null, $attributes);
$out .= get_string('addrandom', 'quiz', $select);
$out .= '<input type="hidden" name="recurse" value="'.$recurse.'" />';
$out .= '<input type="hidden" name="categoryid" value="' . $category->id . '" />';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment