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

External badges show date in the future

XMLWordPrintable

    • MOODLE_37_STABLE
    • MOODLE_37_STABLE
    • MDL-65705-master
    • Hide

      Requirements

      1. An account set up on openbadges.org and for the user to have obtained at least one badge (eg http://www.openbadges.org/earn/) and for this badge to be added to a collection and made public (http://backpack.openbadges.org/). MDLQA-13265 explains how to prepare it. When creating the badge, make sure it has some expiring date.
      2. mailcatcher (or similar or working mail) to intercept mails.
      3. It will not work on a localhost Moodle; it must be online to connect to openbadges.org.
      4. Access to the code because it's not easy to reproduce it.

      Setup

      1. As admin verify that badges are enabled in Administration / Site administration / Advanced features.
      2. Go to "Site administration / Badges / Add a new badge" and create a badge at site level. Remember to add an 'Expiry date' to the badge.
      3. Add a criteria to the badge so it can be manually issued by role.
      4. Enable the badge.
      5. Issue the badge to the admin user.
      6. Access to "Site administration / Badges / Backpack settings" and make sure the site backpack is set to "https://backpack.openbadges.org/".
      7. Under the user menu (at the upper right), select 'My preferences'.
      8. Click on "Backpack settings" under Badges.
      9. Add the email address for the backpack.openbadges.org account as the email address for the backpack connection.
      10. Click on 'Sign in with your Email.'
      11. Read the verification email and click on the link to verify the connection to the backpack.
      12. Select the badge collection you wish to display (the one mentioned on the requirements section).
      13. Edit the badges/renderer.php file
      14. Before line 512, add the following $assertion->expires = 1419418965; (this is the timestamp for the 24th December 2014). After the change, the code should look like this: 

        $output .= html_writer::empty_tag('img', array('src' => $issued->image, 'width' => '100'));
         $assertion->expires = 1419418965;
         if (isset($assertion->expires)) {

      1. Before line 569, add the following $assertion->issued_on = 1419418965; (this is the timestamp for the 24th December 2014). After the change, the code should look like this: 

        if (isset($assertion->issued_on)) {
         $assertion->issued_on = 1419418965;
         $issuedate = is_numeric($assertion->issued_on) ? $assertion->issued_on : strtotime($assertion->issued_on);

      Testing instructions

      1. View this user's profile page.
      2. Verify that in "Badges from [Moodle instance name]" you now see your local badge.
      3. Access to the badge.
      4. Verify the "Date issued" field contains the date it was issued (today), following the format "Day, Day Month Year, Hour".
      5. Verify the "Expiry date" field contains the date it will expire, following the format "Day, Day Month Year, Hour".
      6. Come back to the user's profile page.
      7. Verify that in "My badges from other websites" you now see your badge from openbadges.org.
      8. Access to the badge.
      9. Verify the "Date issued" field contains "Wednesday, 24 December 2014, 12:02 PM" (instead of "Friday, 24 May 8965, 2:19 PM").
      10. Verify the "Expiry date" field contains "Wednesday, 24 December 2014, 12:02 PM (This badge has expired!)".
      Show
      Requirements An account set up on openbadges.org and for the user to have obtained at least one badge (eg  http://www.openbadges.org/earn/ ) and for this badge to be added to a collection and made public ( http://backpack.openbadges.org/ ).  MDLQA-13265 explains how to prepare it. When creating the badge, make sure it has some expiring date. mailcatcher (or similar or working mail) to intercept mails. It will not work on a localhost Moodle; it must be online to connect to openbadges.org. Access to the code because it's not easy to reproduce it. Setup As admin verify that badges are enabled in Administration / Site administration / Advanced features. Go to "Site administration / Badges / Add a new badge" and create a badge at site level. Remember to add an 'Expiry date' to the badge. Add a criteria to the badge so it can be manually issued by role. Enable the badge. Issue the badge to the admin user. Access to "Site administration / Badges / Backpack settings" and make sure the site backpack is set to "https://backpack.openbadges.org/". Under the user menu (at the upper right), select 'My preferences'. Click on "Backpack settings" under Badges. Add the email address for the backpack.openbadges.org account as the email address for the backpack connection. Click on 'Sign in with your Email.' Read the verification email and click on the link to verify the connection to the backpack. Select the badge collection you wish to display (the one mentioned on the requirements section). Edit the badges/renderer.php file Before line 512, add the following  $assertion->expires = 1419418965;  (this is the timestamp for the 24th December 2014). After the change, the code should look like this:  $output .= html_writer::empty_tag( 'img' , array( 'src' => $issued->image, 'width' => '100' )); $assertion->expires = 1419418965 ; if (isset($assertion->expires)) { Before line 569, add the following  $assertion->issued_on = 1419418965;  (this is the timestamp for the 24th December 2014). After the change, the code should look like this:  if (isset($assertion->issued_on)) { $assertion->issued_on = 1419418965 ; $issuedate = is_numeric($assertion->issued_on) ? $assertion->issued_on : strtotime($assertion->issued_on); Testing instructions View this user's profile page. Verify that in "Badges from [Moodle instance name] " you now see your local badge. Access to the badge. Verify the "Date issued" field contains the date it was issued (today), following the format "Day, Day Month Year, Hour". Verify the "Expiry date" field contains the date it will expire, following the format "Day, Day Month Year, Hour". Come back to the user's profile page. Verify that in "My badges from other websites" you now see your badge from openbadges.org. Access to the badge. Verify the "Date issued" field contains "Wednesday, 24 December 2014, 12:02 PM" (instead of "Friday, 24 May 8965, 2:19 PM" ). Verify the "Expiry date" field contains "Wednesday, 24 December 2014, 12:02 PM (This badge has expired!)" .

      As noticed by Jon Bolton on Moodle.org, badges awarded on other sites when displayed via his backpack are showing a date a long time in the future - see attached screenshot. This only happened on 3.7 and the badges display the correct date on the original sites.

        1. backpack.jpg
          backpack.jpg
          28 kB
        2. exampledate.png
          exampledate.png
          114 kB
        3. exampledate2.png
          exampledate2.png
          94 kB
        4. expired_badges.png
          expired_badges.png
          119 kB
        5. MDL-65705.jpg
          MDL-65705.jpg
          40 kB
        6. step#7-10.jpg
          step#7-10.jpg
          36 kB

            sarjona Sara Arjona (@sarjona)
            marycooch Mary Cooch
            Carlos Escobedo Carlos Escobedo
            Adrian Greeve Adrian Greeve
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours
                5h

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