You are here

function get_grade_options in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/questionlib.php \get_grade_options()

Returns list of 'allowed' grades for grade selection formatted suitably for dropdown box function

Return value

object ->gradeoptionsfull full array ->gradeoptions +ve only

1 call to get_grade_options()
qformat_default::importprocess in includes/moodle/question/format.php
Process the file This method should not normally be overidden

File

includes/moodle/lib/questionlib.php, line 300

Code

function get_grade_options() {

  // define basic array of grades
  $grades = array(
    1.0,
    0.9,
    0.83333,
    0.8,
    0.75,
    0.7,
    0.66666,
    0.6,
    0.5,
    0.4,
    0.33333,
    0.3,
    0.25,
    0.2,
    0.16666,
    0.142857,
    0.125,
    0.11111,
    0.1,
    0.05,
    0,
  );

  // iterate through grades generating full range of options
  $gradeoptionsfull = array();
  $gradeoptions = array();
  foreach ($grades as $grade) {
    $percentage = 100 * $grade;
    $neggrade = -$grade;
    $gradeoptions["{$grade}"] = "{$percentage} %";
    $gradeoptionsfull["{$grade}"] = "{$percentage} %";
    $gradeoptionsfull["{$neggrade}"] = -$percentage . " %";
  }
  $gradeoptionsfull["0"] = $gradeoptions["0"] = get_string("none");

  // sort lists
  arsort($gradeoptions, SORT_NUMERIC);
  arsort($gradeoptionsfull, SORT_NUMERIC);

  // construct return object
  $grades = new stdClass();
  $grades->gradeoptions = $gradeoptions;
  $grades->gradeoptionsfull = $gradeoptionsfull;
  return $grades;
}