Skip to content

DN-3840: Show photos from Canvas - #217

Open
dj-petersen wants to merge 13 commits into
mainfrom
feature/DN-3840
Open

DN-3840: Show photos from Canvas#217
dj-petersen wants to merge 13 commits into
mainfrom
feature/DN-3840

Conversation

@dj-petersen

Copy link
Copy Markdown
Contributor

uses this new version of the LTI-consumer package uva/LTI-consumer#8

@goomens goomens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is there a way to get picture urls from Canvas without the user logging in via Canvas? If we would want to do some bulk operation via the API?


[BsonElement("Picture")]
[BsonIgnoreIfNull]
public string? Picture { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an url I think? Should we call it PictureUrl?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's the url of the user avatar. I used Picture to match LtiPrincipal of the canvas response. But I agree that maybe PictureUrl would be clearer.

}
}

// Enrich Picture on embedded instance user snapshots from the live users table

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a logical place to do this? Do we always want to do this? Most of the time a context won't need users or pictures I guess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't really know what a good place would be. Now it runs every time an instance is opened so you have the updated pictures. Do you have another suggestion?

@dj-petersen

Copy link
Copy Markdown
Contributor Author

Question: is there a way to get picture urls from Canvas without the user logging in via Canvas? If we would want to do some bulk operation via the API?

This currently uses the picture field which is returned in the login call. There is also an avatar_url field in the /users/{user_id}/profile endpoint. I guess we could access with an admin token if we know/ask the user id used by canvas.

@dj-petersen

Copy link
Copy Markdown
Contributor Author

I'm now syncing all the info for users to the instances. Because I guess we don't want stale data in the instances. But that also means the name of the person updates to the name in Canvas. Do we want that as the source of truth? Or only for pictures?

@goomens

goomens commented Aug 3, 2026

Copy link
Copy Markdown
Member

I'm now syncing all the info for users to the instances. Because I guess we don't want stale data in the instances. But that also means the name of the person updates to the name in Canvas. Do we want that as the source of truth? Or only for pictures?

It should always be the same but maybe best not to rely on Canvas because not all users come from Canvas. So let's use an another single source of truth for that

@dj-petersen

Copy link
Copy Markdown
Contributor Author

I'm now syncing all the info for users to the instances. Because I guess we don't want stale data in the instances. But that also means the name of the person updates to the name in Canvas. Do we want that as the source of truth? Or only for pictures?

It should always be the same but maybe best not to rely on Canvas because not all users come from Canvas. So let's use an another single source of truth for that

So do we want to sync the email address or the organisation?

@goomens

goomens commented Aug 3, 2026

Copy link
Copy Markdown
Member

No, let's not use Canvas for any of that

Comment thread UvA.Workflow/Users/UserService.cs Outdated
/// Finds all instances containing this user in any user-type property and replaces the
/// fields in the embedded snapshot with the value from the current User state.
/// </summary>
public async Task SyncUserInInstances(User user, string[] fields, CancellationToken ct)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For strong typing, do we maybe want to use expressions here instead of strings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some changes to fix this

Comment thread UvA.Workflow/Users/UserService.cs Outdated
foreach (var instance in instances)
{
if (SyncUserInInstance(instance, user, fields))
await instanceRepository.Update(instance, ct);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to avoid using this whenever possible because it overwrites the full instance, which can cause very strange effects when operations are performed simultaneously. Can we use a property-level update here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants