Moodle
  1. Moodle
  2. MDL-39790

Make My Latest badges block appear on the course page

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.5.1
    • Component/s: Badges, Blocks
    • Labels:
    • Testing Instructions:
      Hide

      1. To test properly, make sure a user has some site and course badges earned.
      2. Go to the course where a course badge was earned.
      3. Add "My latest badges" block.
      4. Make sure that the block displays only badges earned in this course.

      Show
      1. To test properly, make sure a user has some site and course badges earned. 2. Go to the course where a course badge was earned. 3. Add "My latest badges" block. 4. Make sure that the block displays only badges earned in this course.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE

      Description

      The My Latest badges block can appear on the Front page or on the My home page but as the following two forum threads show, there is interest in having a block displaying badges on the course page. I wonder if it is possible to make this block available on course pages? Both of the following forum threads contain suggested code to make this possible:

      https://moodle.org/mod/forum/discuss.php?d=226195
      and also
      https://moodle.org/mod/forum/discuss.php?d=228787

        Gliffy Diagrams

          Activity

          Hide
          Tim Hunt added a comment -

          Doing

          if (strpos($this->page->pagetype, 'course-view') !== false) {

          feels wrong to me. I think you should replace that block of 4 lines with

          $courseid = $this->page->course->id;
          if ($courseid == SITEID) {
              $courseid = null;
          }
          

          (except that I cannot remember the best way to get SITEID. Is it that, or should you use $SITE->id?

          Anyway, if you do that, the I think the block would work on any page in Moodle.

          Show
          Tim Hunt added a comment - Doing if (strpos($this->page->pagetype, 'course-view') !== false) { feels wrong to me. I think you should replace that block of 4 lines with $courseid = $this->page->course->id; if ($courseid == SITEID) { $courseid = null; } (except that I cannot remember the best way to get SITEID. Is it that, or should you use $SITE->id? Anyway, if you do that, the I think the block would work on any page in Moodle.
          Hide
          Yuliya Bozhko added a comment -

          Thanks, Tim! That seems like mush a better idea as I didn't like using strpos() either Will fix it ASAP.

          Show
          Yuliya Bozhko added a comment - Thanks, Tim! That seems like mush a better idea as I didn't like using strpos() either Will fix it ASAP.
          Hide
          Tim Hunt added a comment -

          Thanks Yuliya. That gets a +1 from me now for the code change. I think you should squash it down to one commit before submitting for integration.

          Show
          Tim Hunt added a comment - Thanks Yuliya. That gets a +1 from me now for the code change. I think you should squash it down to one commit before submitting for integration.
          Hide
          Yuliya Bozhko added a comment -

          Will do! Although, last time I did that, I was asked not to do that again

          Show
          Yuliya Bozhko added a comment - Will do! Although, last time I did that, I was asked not to do that again
          Hide
          Yuliya Bozhko added a comment -

          All done now!

          Show
          Yuliya Bozhko added a comment - All done now!
          Hide
          Mary Cooch added a comment -

          Yuliya - you are a star This will make a lot of people happy!

          Show
          Mary Cooch added a comment - Yuliya - you are a star This will make a lot of people happy!
          Hide
          Tim Hunt added a comment -

          Submitting for integration now.

          Well, to explain the rebasing thing. Probably what the other person was getting at is this:

          • In the middle of the peer review process, it is better if you don't rebase, so that people can see what changed between the first version of your propose patch and the second.
          • ... but then, before submitting for integration, you should rebase.
          • ... unless it is a really big change, in which case it would make more send to do it as a sequence of several commit, but they should break the change into logical chunks. Again there is no point preserving the history of what got changes during peer review.
          Show
          Tim Hunt added a comment - Submitting for integration now. Well, to explain the rebasing thing. Probably what the other person was getting at is this: In the middle of the peer review process, it is better if you don't rebase, so that people can see what changed between the first version of your propose patch and the second. ... but then, before submitting for integration, you should rebase. ... unless it is a really big change, in which case it would make more send to do it as a sequence of several commit, but they should break the change into logical chunks. Again there is no point preserving the history of what got changes during peer review.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (25 & master). The only tiny point is that we should not be using SITEID, but $SITE->id. Not critical, anyway. Thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (25 & master). The only tiny point is that we should not be using SITEID, but $SITE->id. Not critical, anyway. Thanks!
          Hide
          Dan Poltawski added a comment -

          The only tiny point is that we should not be using SITEID, but $SITE->id.

          Do we have that documented anywhere?

          Show
          Dan Poltawski added a comment - The only tiny point is that we should not be using SITEID, but $SITE->id. Do we have that documented anywhere?
          Hide
          Rossiani Wijaya added a comment -

          This is working as expected.

          Tested for 2.5 and master.

          Test passed.

          Show
          Rossiani Wijaya added a comment - This is working as expected. Tested for 2.5 and master. Test passed.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          It's only in code, afaik. And I only remember it because I like get_site() more, hehe.

          Show
          Eloy Lafuente (stronk7) added a comment - It's only in code, afaik. And I only remember it because I like get_site() more, hehe.
          Hide
          Yuliya Bozhko added a comment -

          I couldn't find anything about SITEID. Tim was not sure either, so I left it how he suggested. Would be good to add it somewhere in documentation.

          Show
          Yuliya Bozhko added a comment - I couldn't find anything about SITEID. Tim was not sure either, so I left it how he suggested. Would be good to add it somewhere in documentation.
          Hide
          Dan Poltawski added a comment -

          Feature: Thanks to our superb contributors
            In order to make Moodle better
            As an integrator
            I need to thank all our contributors
           
            Scenario: Dan thanks you all
              Given I log in as "dan"
              And I see "lots of fixed issues"
              When I follow "Close integrated issues"
              Then I should see "Lots of thanks to all our contributors"
          

          Your changes are upstream

          Show
          Dan Poltawski added a comment - Feature: Thanks to our superb contributors In order to make Moodle better As an integrator I need to thank all our contributors   Scenario: Dan thanks you all Given I log in as "dan" And I see "lots of fixed issues" When I follow "Close integrated issues" Then I should see "Lots of thanks to all our contributors" Your changes are upstream

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: