Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-28138

format_float function in question/type/calculated/db/upgradelib.php seems broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 2.1
    • 2.1
    • Questions
    • None
    • MOODLE_21_STABLE
    • MOODLE_21_STABLE
    • Hide

      1. Run the unit tests in question
      2. Create calculated and calculated multi questions with various settings for 'Correct answer shows' and answer Format.
      3. Preview the question, and ensure that the answers are formatted properly.
      4. Switch to a language that uses , as decimal point, and re-preview the question.

      5. Test the upgrade 2.0 to 2.1 including attempts at calculated questions, and make sure there are no errors.

      Show
      1. Run the unit tests in question 2. Create calculated and calculated multi questions with various settings for 'Correct answer shows' and answer Format. 3. Preview the question, and ensure that the answers are formatted properly. 4. Switch to a language that uses , as decimal point, and re-preview the question. 5. Test the upgrade 2.0 to 2.1 including attempts at calculated questions, and make sure there are no errors.

    Description

      format_float function in

      • question/type/calculated/db/upgradelib.php and
      • question/type/calculatedmulti/db/upgradelib.php
        seems broken

      If and else if have same condition in function format_float.

      public function format_float($x, $length = null, $format = null) {
          if (!is_null($length) && !is_null($format)) {
              if ($format == 1) {
                  // Decimal places.
                  $x = sprintf('%.' . $length . 'F', $x);
              } else if ($format == 1) {
                  // Significant figures.
                  $x = sprintf('%.' . $length . 'g', $x);
                  $x = str_replace(',', '.', $x);
              }
          }
          return $x;
      }

      Attachments

        Issue Links

          Activity

            People

              timhunt Tim Hunt
              rajeshtaneja Rajesh Taneja
              Sam Hemelryk Sam Hemelryk
              Rajesh Taneja Rajesh Taneja
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.