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

The serialize_precision value set in setup.php is no longer the default for PHP since 7.1

XMLWordPrintable

    • Any
    • MOODLE_403_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-82286-403
    • MDL-82286-404
    • MDL-82286-main
    • Hide

      Automated Testing

      The config_key_test::test_config_key_hash_is_derived_correctly() method has been added to cover testing the serialization of floating point numbers in a SEB config file. Running this test with the updated serialize_precision value passes but fails when it has not been updated.

      Manual Testing - Setup

      Using Windows, download and install the latest version of Safe Exam Browser for Windows from here... https://safeexambrowser.org/download_en.html

      For clarity I am only able to test using SEB in a Windows 10 VM running on an Ubuntu linux laptop, if you wish to use a Windows VM for testing then some additional configuration options must be checked in step 1 or SEB will give an error about running in a VM and exit...

      • Security > Allow to run inside virtual machine
      • Security > Ignore errors when validating display configuration.

      Manual Testing - Steps

      1. Create a configuration file using SEB Configuration Tool...
        1. Enter the absolute URL for your quiz in General > Start URL
        2. Tick "Exam > Use Browser Exam Key and Configuration Key"
        3. For "Config file > Use SEB settings for...", select the "starting an exam" and ensure there is no settings password entered.
        4. Click Save Settings As from the file menu to create a new settings file. On the "No Encryption Credentials Chosen" prompt select "Yes".
        5. Open the configuration file in a text editor and verify that it contains decimal numbers like 0.1 or 0.2, if it does not then add the following properties to the file directly above the first <key> as a child of the outer <dict> element...

      <key>batteryChargeThresholdCritical</key><real>0.1</real><key>batteryChargeThresholdLow</key><real>0.2</real>

      1. On Moodle as a teacher in a normal web browser...
        1. Create a new quiz activity.
        2. In General settings add a name.
        3. In Safe Exam Browser settings select "Yes - Upload my own config" from the "Require the use of Safe Exam Browser" dropdown list.
        4. Upload your settings file created above.
        5. Do not enter a browser key.
        6. Click Save and display.
      2. As a student in a normal web browser...
        1. Browse to quiz activity.
        2. Click download configuration and double click the downloaded .seb file.
        3. SEB will launch.
        4. Log into Moodle.
        5. Verify Moodle gives no error and allows the student to proceed with the quiz attempt.
      Show
      Automated Testing The config_key_test::test_config_key_hash_is_derived_correctly() method has been added to cover testing the serialization of floating point numbers in a SEB config file. Running this test with the updated serialize_precision value passes but fails when it has not been updated. Manual Testing - Setup Using Windows, download and install the latest version of Safe Exam Browser for Windows from here... https://safeexambrowser.org/download_en.html For clarity I am only able to test using SEB in a Windows 10 VM running on an Ubuntu linux laptop, if you wish to use a Windows VM for testing then some additional configuration options must be checked in step 1 or SEB will give an error about running in a VM and exit... Security > Allow to run inside virtual machine Security > Ignore errors when validating display configuration. Manual Testing - Steps Create a configuration file using SEB Configuration Tool... Enter the absolute URL for your quiz in General > Start URL Tick "Exam > Use Browser Exam Key and Configuration Key" For "Config file > Use SEB settings for...", select the "starting an exam" and ensure there is no settings password entered. Click Save Settings As from the file menu to create a new settings file. On the "No Encryption Credentials Chosen" prompt select "Yes". Open the configuration file in a text editor and verify that it contains decimal numbers like 0.1 or 0.2, if it does not then add the following properties to the file directly above the first <key> as a child of the outer <dict> element... <key>batteryChargeThresholdCritical</key> <real> 0.1 </real> <key>batteryChargeThresholdLow</key> <real> 0.2 </real> On Moodle as a teacher in a normal web browser... Create a new quiz activity. In General settings add a name. In Safe Exam Browser settings select "Yes - Upload my own config" from the "Require the use of Safe Exam Browser" dropdown list. Upload your settings file created above. Do not enter a browser key. Click Save and display. As a student in a normal web browser... Browse to quiz activity. Click download configuration and double click the downloaded .seb file. SEB will launch. Log into Moodle. Verify Moodle gives no error and allows the student to proceed with the quiz attempt.

      In setup.php, serialize_precision is set to 17 to enforce consistency across environments that have changed this PHP setting from the default value...

      https://github.com/moodle/moodle/blob/ad7fc69c25185b7c6e2fe4707d121aee71b8277f/lib/setup.php#L259

      A new default value was introduced with PHP 7.1 however, we should change setup.php to reflect the new default value as it will cause json_encode() to incorrectly serialize float values between 0 and 1.

      This affects Safe Exam Browser integration when using a quiz set to use an uploaded .seb config file via the "Upload my own config" option, SEB will present "The Safe Exam Browser keys could not be validated" when a student attempts to enter a quiz after downloading the SEB config.

      During the process of deriving the config key hash, Moodle converts the property_list to a json string using json_encode(). If some of the properties have floating point values like 0.1 these are being converted to 0.10000000000000001 (hence a difference in the json string causing a different hash). This behaviour seems to be caused by Moodle setting serialize_precision to 17 in setup.php. The default value in PHP since 7.1 is -1 which uses a "an enhanced algorithm for rounding such numbers". See this bug... https://bugs.php.net/bug.php?id=72567

      I found that when creating a SEB config file using a laptop, the following properties are added. For clarity I am only able to use SEB in a Windows 10 VM running on an Ubuntu linux laptop...

      <key>batteryChargeThresholdCritical</key>
      <real>0.1</real>
      <key>batteryChargeThresholdLow</key>
      <real>0.2</real> 

      Steps to reproduce this issue with Safe Exam Browser:

      Using a Windows laptop, create a configuration file using SEB Configuration Tool...

      • Enter the absolute URL for your quiz in General > Start URL
      • Tick Exam > Use Browser Exam Key and Configuration Key
      • Click Save Settings As from the file menu, create a new settings file.
      • Verify the settings file contains properties with floating point numbers, like the ones mentioned above.

      On Moodle as a teacher in a normal web browser...

      • Create a new quiz activity.
      • In General settings add a name.
      • In Safe Exam Browser settings select "Yes - Upload my own config" from the "Require the use of Safe Exam Browser" dropdown list.
      • Upload your settings file created above.
      • Do not enter a browser key.
      • Click Save and display.

      As a student in a normal web browser...

      • Browse to quiz activity.
      • Click download configuration and double click the downloaded .seb file.
      • SEB will launch.
      • Log into Moodle
      • Observe an error from Moodle.

        1. MDL-82286_main.webm
          5.40 MB
          Angelia Dela Cruz
        2. MDL-82286_403.webm
          8.42 MB
          Angelia Dela Cruz
        3. MDL-82286_404.webm
          11.63 MB
          Angelia Dela Cruz

            daviesdale Dale Davies
            daviesdale Dale Davies
            Mark Johnson Mark Johnson
            Jun Pataleta Jun Pataleta
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            8 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 2 minutes
                3h 2m

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