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

create ajax method to get user pref

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.6
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide
      1. Edit /index.php and add the following somewhere after the header

        user_preference_allow_ajax_fetch('invalid1');
        user_preference_allow_ajax_update('invalid2', PARAM_INT);
        user_preference_allow_ajax_fetch('auth_manual_passwordupdatetime');
        user_preference_allow_ajax_update('filepicker_recentlicense');
        

      2. Navigate to /index.php and ensure that you are currently logged out
      3. Open the JS console and run to set things up:

        resolve = function() {console.log("Was resolved succesfully. Arguments follow"); console.log(arguments);};
        reject = function() {console.log("Was rejected. Arguments follow"); console.log(arguments);};
        

      4. Now attempt to fetch some settings:
        1. An invalid setting which has been listed:

          M.util.get_user_preference('invalid1', resolve, reject);
          

          • Confirm the output includes "Was resolved successfully"
          • Confirm the output includes an object with name "invalid1", and an empty value
        2. An invalid setting which has not been listed. Setting it for update should not set it for retrieval:

          M.util.get_user_preference('invalid2', resolve, reject);
          

          • Confirm that an AJAX exception dialogue was shown
          • Confirm the output includes "Was rejected"
          • Confirm the output includes a reference to the AJAXEXCEPTION
        3. A valid setting which is allowed

          M.util.get_user_preference('auth_manual_passwordupdatetime', resolve, reject);
          

          • Confirm the output includes "Was resolved successfully"
          • Confirm the output includes an object with name "auth_manual_passwordupdatetime", and a value for the preference
        4. An valid setting which has not been listed. Setting it for update should not set it for retrieval:

          M.util.get_user_preference('filepicker_recentlicense', resolve, reject);
          

          • Confirm that an AJAX exception dialogue was shown
          • Confirm the output includes "Was rejected"
          • Confirm the output includes a reference to the AJAXEXCEPTION
      Show
      Edit /index.php and add the following somewhere after the header user_preference_allow_ajax_fetch('invalid1'); user_preference_allow_ajax_update('invalid2', PARAM_INT); user_preference_allow_ajax_fetch('auth_manual_passwordupdatetime'); user_preference_allow_ajax_update('filepicker_recentlicense'); Navigate to /index.php and ensure that you are currently logged out Open the JS console and run to set things up: resolve = function() {console.log("Was resolved succesfully. Arguments follow"); console.log(arguments);}; reject = function() {console.log("Was rejected. Arguments follow"); console.log(arguments);}; Now attempt to fetch some settings: An invalid setting which has been listed: M.util.get_user_preference('invalid1', resolve, reject); Confirm the output includes "Was resolved successfully" Confirm the output includes an object with name "invalid1", and an empty value An invalid setting which has not been listed. Setting it for update should not set it for retrieval: M.util.get_user_preference('invalid2', resolve, reject); Confirm that an AJAX exception dialogue was shown Confirm the output includes "Was rejected" Confirm the output includes a reference to the AJAXEXCEPTION A valid setting which is allowed M.util.get_user_preference('auth_manual_passwordupdatetime', resolve, reject); Confirm the output includes "Was resolved successfully" Confirm the output includes an object with name "auth_manual_passwordupdatetime", and a value for the preference An valid setting which has not been listed. Setting it for update should not set it for retrieval: M.util.get_user_preference('filepicker_recentlicense', resolve, reject); Confirm that an AJAX exception dialogue was shown Confirm the output includes "Was rejected" Confirm the output includes a reference to the AJAXEXCEPTION
    • Affected Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-41289-master
    • Story Points:
      5

      Description

      we have an ajax method to set a user pref but no way of getting the existing pref.

      It would be good if we could implement M.util.get_user_preference to match M.util.set_user_preference()

      I'd like to use this to replace the use of cookies to mange debugging in SCORM.

      Of course - I'm open to other ideas on how to remove the use of cookies from SCORM debugging if someone has a better idea?

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: