D2L API for News > SortOrder Attribute > Issue?

Hello,

Any D2L experts or internal folks here who can explain to me how the SortOrder attribute is supposed to work for the GET /d2l/api/le/(version)/(orgUnitId)/news/ that returns https://docs.valence.desire2learn.com/res/news.html#News.NewsItem ?

In my initial testing, I see multiple News Items being returned with the exact same value here even after pinning. Multiple items with SortOrder = 0, etc.

I was hoping that this would solve the problem I had about not being able to determine which Pinned item to display first in a custom front-end (because I was told in my PIE item that this attribute should solve it). I'm just really confused about what this number is doing, and honestly I don't see any value in it at all (which makes me feel like I must be missing something).

Answers

  • @Nathan.G.332, the SortOrder attribute is default =0. This ensures that the order they appear within Brightspace is relative to their Start Dates (besides Pinned status of course). If you were to initiate a reorder action and put one of your earlier Announcements up to the top of the list, then it will cause the SortOrder to be set to 0, 1, 2, etc. for each of the posts. Making new Announcements will then continue to change these values, etc.

    I hope that helps!

    -Johnny
    D2L LAM

  • Nathan.G.332
    Nathan.G.332 Posts: 4 🌱
    edited September 10

    Hello @Johnny.B.962 - I appreciate the response.

    EDIT: Are you suggesting that I have to use the "Reorder" action within the Announcements tool before any of these values will change from the default?

    For instance here's the API response for a course I do testing in. I haven't done any sort of manual Reordering, but I have done some Pinning. All three items have a SortOrder = 0. Two out of three items were pinned in a different order than created. How is this SortOrder attribute useful in this scenario (where I didn't manually Reorder)?

    [
    {
    "Id": 1932053,
    "IsHidden": false,
    "Attachments": [],
    "CreatedBy": 60122,
    "CreatedDate": "2024-09-10T17:37:30.277Z",
    "LastModifiedBy": null,
    "LastModifiedDate": "2024-09-10T17:38:23.870Z",
    "Title": "Created 2 Pinned 1",
    "Body": {
    "Text": "Created 2 Pinned 1",
    "Html": "<p>Created 2 Pinned 1</p>"
    },
    "StartDate": "2024-09-10T17:37:00.000Z",
    "EndDate": null,
    "IsGlobal": false,
    "IsPublished": true,
    "ShowOnlyInCourseOfferings": false,
    "IsAuthorInfoShown": true,
    "IsPinned": true,
    "IsStartDateShown": true,
    "SortOrder": 0
    },
    {
    "Id": 1932050,
    "IsHidden": false,
    "Attachments": [],
    "CreatedBy": 60122,
    "CreatedDate": "2024-09-10T17:36:26.170Z",
    "LastModifiedBy": null,
    "LastModifiedDate": "2024-09-10T17:40:38.110Z",
    "Title": "Created 1 Pinned 2",
    "Body": {
    "Text": "Created 1 Pinned 2",
    "Html": "<p>Created 1 Pinned 2</p>"
    },
    "StartDate": "2024-09-10T17:36:00.000Z",
    "EndDate": null,
    "IsGlobal": false,
    "IsPublished": true,
    "ShowOnlyInCourseOfferings": false,
    "IsAuthorInfoShown": true,
    "IsPinned": true,
    "IsStartDateShown": true,
    "SortOrder": 0
    },
    {
    "Id": 1036252,
    "IsHidden": false,
    "Attachments": [],
    "CreatedBy": 79281,
    "CreatedDate": "2022-03-22T15:46:41.757Z",
    "LastModifiedBy": 123820,
    "LastModifiedDate": "2022-04-01T15:24:57.457Z",
    "Title": "Welcome to Hedgehog Behaviours!",
    "Body": {
    "Text": "Please join me for our first class on Monday at 12 pm where we will begin our discussion on hedgehogs.",
    "Html": "<p>Please join me for our first class on Monday at 12 pm where we will begin our discussion on hedgehogs.</p>"
    },
    "StartDate": "2022-03-22T15:46:00.000Z",
    "EndDate": null,
    "IsGlobal": false,
    "IsPublished": true,
    "ShowOnlyInCourseOfferings": false,
    "IsAuthorInfoShown": true,
    "IsPinned": false,
    "IsStartDateShown": true,
    "SortOrder": 0
    }
    ]

  • Nathan.G.332
    Nathan.G.332 Posts: 4 🌱

    @Johnny.B.962

    I guess I have a follow-up question in that case… I had previously created PIE Item D10662 which was marked as "Released" based on the functionality of the SortOrder attribute we've discussed. Here was my original request in that PIE item:

    Regarding the new IsPinned attribute. If there are multiple Announcements which have been pinned - I'm not seeing a way to properly determine which of them is most recent. This is necessary to determine which should be at the very top of the Pinned Announcement set.

    In the Brightspace front-end, I can see that the most recent Pin is respected even when I leave the course and return. So clearly a timestamp or some other sorting mechanism exists behind the front end, but I don't see that represented with the new API implementation.

    This can be implemented in a few different ways:

    1) Use a timestamp similiar to how Course Pinning already works with a PinDate attribute.
    2) Introduce a SortOrder attribute similar to how Content > Modules and Topics already works.

    Given that the SortOrder doesn't actually do anything when an item is Pinned - my PIE item shouldn't really be considered "Released" then. Is there a way that the status can be changed back? Or is my only option to re-create the exact same request as a new item?

  • @Nathan.G.332, "Are you suggesting that I have to use the "Reorder" action within the Announcements tool before any of these values will change from the default?" - Yes that is exactly what I'm saying.

    Regarding that PIE item, I'd suggest just making that same comment you made here, on the PIE item itself. Our development team does look at those, even on items that have been released. So if there's something that you think wasn't addressed, you could go ahead and make a new PIE item, but you can also just comment on the existing one if you think it needs to be clarified further.

    -Johnny
    D2L LAM

  • Nathan.G.332
    Nathan.G.332 Posts: 4 🌱

    Thanks @Johnny.B.962!
    Just wanted to say that I really appreciate your time and patience walking me through this API functionality! Even though it wasn't the "answer" I was hoping for, that's certainly not your fault. That's just how the API works for now. Hopefully my suggestion in PIE about incorporating Pinned timestamp logic into SortOrder will be considered for the future as well. :)