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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1
    • Component/s: Questions
    • Labels:
      None
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      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;
      }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    1/Jul/11