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

My Overview label edits are one step behind

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.5
    • Fix Version/s: None
    • Labels:

      Description

      When editing a label with a completion date set, the title of the label shown on the My Overview block shows the previous edit, not the current label. In the database, mdl_label is updated as expected, but mdl_event is not.

      To recreate:

      • create new label on a course. Set "enable" to true on activity completion; set a date in the future.
      • Visit My Overview; label should be shown here.
      • Edit this label. Change the "label text" field to add "edit 1" to the label text. Confirm this is updated on course view.
      • Visit My Overview; edited label text is not shown.
      • Edit the label again; change "edit 1" to "edit 2". Confirm this is updated on course view.
      • Visit My Overview; label text reads "edit 1".
      • Check mdl_label table. The "name" column for the new label will end "edit 2".
      • Check mdl_event table. The corresponding event for the new label will end "edit 1".

      Edit:

      • this can be replicate with label, choice, survey and wiki mods.
      • replicated in 3.4.5+
      • All are coded in the same way, with $DB->update_record(); called after api::update_completion_date_event

      To fix:

      • /mod/label/lib.php:82 - something like:

      function label_update_instance($label){{{
           global $DB;
           $label->name = get_label_name($label);
           $label->timemodified = time();
           $label->id = $label->instance;
           // calling this after update_completion_date_event means the event gets the unedited title from the DB, not the new one, so move it here:
           $update_record = $DB->update_record("label", $label);
           $completiontimeexpected = !empty($label->completionexpected) ? $label->completionexpected : null;
           \core_completion\api::update_completion_date_event($label->coursemodule, 'label', $label->id, $completiontimeexpected);
       
          // now return the record update:
           return $update_record;
       }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              maltpress Adam Maltpress
              Peer reviewer:
              Peter Dias
              Participants:
              Component watchers:
              Sam Marshall, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Adrian Greeve, Mihail Geshoski, Peter Dias
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 minutes
                2m