Student Roles in Desire2Learn - desire2learn

How can I get a list of students from D2L? I want to get the grades of the students and when I get the classlist, I get both instructors and student marks.

You can use /d2l/api/lp/{ver}/enrollments/orgUnits/{orgUnitId}/users/. This will fetch a paged result set of all the users enrolled in the course offering identified by orgUnitId. Note that you can filter the result set with the roleId query parameter; if you know the role ID for students, you can provide that to fetch back just the users in the course with a student role:
https://your.lms/d2l/api/lp/1.0/enrollments/orgUnits/6784/users/?roleId=78&{all_auth_qparms}
Note that the enrollments API calls require certain role permissions of the calling user context. The calling user account needs 'View User Enrollments' permission, and to have the 'Search for <rolename>' permission for the enrolled user roles visible in the output:
Without 'View User Enrollments', you won't have any permission to query enrollments at all, and you'll likely get a 403 back (no permission, or forbidden).
If you don't have the 'Search for Student' or 'Search for Instructor' permission (or whatever your local roles are), then although you can make the enrollments call, the list of enrolled users you get back will get filtered down to only the roles you can 'Search for'.
Edit. I've fixed this answer; the default role ID for students was not 3 (that's the default OrgUnitID for course offerings, I think). On our test server the default student role ID is '78'.
Edit 2. I've added more information about the permissions required to get useful information from the enrollments call.

Related

Azure AD B2C Audit Logs doesn't show custom attributes value changes

I've setup an editing profile user flow in AzureAD B2C with standard attributes (GivenName, Surname, DisplayName and Country) and also with custom attributes (e.g. VAT and FavoriteProduct).
After I run the user flow and modified the attributes values, I see the resulting audit log with the value changes, but only for the standard attributesv (GivenName, Surname, DisplayName and Country).
Is there a way to see also the changed values of custom attributes (in my case VAT and FavoriteProduct) in the audit logs? I need to collect them.
Also tried with a custom policy user journey, same result

Authentication Redirection and Security done right?

I am building an Application where alongside general public pages there will be a login page and 3 Dashboard Versions for each 3 role levels.
Table
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('firstname');
$table->string('surname');
$table->string('username');
$table->string('email')->unique();
$table->string('password', 60);
$table->string('role');
$table->rememberToken();
$table->datetime('created_at');
$table->datetime('updated_at');
});
With that i have another table Roles:
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('role_type');
});
Relationship
Users::hasOne('roles');
Roles::hasMany('users');
Essentially on login function i want to check the users role_type and then redirect them based on the role.
I would like to know if this table structure and idea is correctly thought out.
Additionally when a user accesses a specific route i will have the route either display login if no user or 404/503 if user is logged in But does not match a specific role_type.
Thanks guys
On your users table instead of the role column you have, it should be these two lines:
$table->integer('role_id')->unsigned()->nullable();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('set null');
The downside to this is it allows a null value for the 'role_id' column on users. The reason it needs this is to deal with what would happen if a Role that is assigned to a user is deleted.
But a better solution would be to use a many-to-many relationship, I personally would suggest using Entrust, since it has what you want built in, plus more options that you might want later.

How to update the same attributes in several tables with Postgresql and Rails

In order to minimize the number of joins that I have to execute in my application I decided to copy in my database the same field in several tables for example :
I have a User, Product and a Wishlist Table.
My Product pages shows the user who created the product, as the wishlists pages which also shows the user who created them.
So I added in my products and wishlists table all the users field needed to show the required informations.
How can I update the users related fields in my Products and Wishlists Table as soon as the user change his information ?
Here is a part of my model :
User Table
Full Name
UserName
Avatar URL
Product Table
Product Name
Product Price
User ID
User Full Name
Username
User Avatar URL
Wishlist Table
Wishlist Name
User ID
User Full Name
Username
User Avatar URL
Thanks in advance for your answers !
Firstly, by denormalizing the data in the way that you are, you are working against what relational databases are meant to do. They thrive on joins, and having each piece of data appear as few times as possible. So you really want to make sure that this is the schema that you want.
That being said, you can use the basic update_attibute syntax to update any field in any table. So, if a user edited his or her username, you would do:
User.update_attribute(:username, username)
Product.update_attribute(:username, username)
Wishlist.update_attribute(:username, username)

sfDoctrineGuard - get only groups logged in user is a member of

I have a table that has a sfGuardGroup column so when a user logs in, they can only see the records users in their group have made.
When creating a record I want to have a select box for the sfGuardGroup that only contains the groups that the logged in user is a member of.
Anyone know how to do this please?
Thanks
In the form::configure
get user: use sfContex::getInstance()->getUser() (easy way, not recommend) or inject sfUser from controller as option
$this->form = new myAwesomeUserForm(array(),array('user'=>$this->getUser()));
Use sfWidgetFormChoice
Use sfGuardSecurityUser::getGroups ($user->getGroups) to set choices for sfWidgetFormChoice widget. Here $user is instance of myUser>sfGuardSecurityUser
Do not forget validator

Does this User Permissions set-up make sense?

I am building a Rails 3 app and I am working on a design for a sophisticated user permissions tool where a Company user determines specific roles for each PM.
Imagine this scenario - the Company wants to establish specific roles over three types of data.
Project table
Client table
Corporate Account (i.e. Company table)
I am thinking of adding a Role polymorphic table with these fields:
user_id (the user this role applies to, unless all_users == true)
item type (such as "Project", "Client", or "Company", unless all_items == true)
item id (as above)
role (such as "read", "edit", "destroy", or even "custom")
all_users (boolean: does this item's role apply to all users)
all_items (boolean: does this user's role apply to all items)
company_id (the company who 'owns' this role)
I feel that CanCan would be a nice lean way of accomplishing this, but here's my question. 1. Is the above table a good way to do this? 2. Could CanCan tie in with this to create an effective solution?
Your table seems like a sensible way to implement a very complicated authorization scheme, which seems to be what you're after.
As far as CanCan goes, yes it will tie in perfectly with this. All CanCan does is provide you with the ability to define authorization on actions, models, etc. according to certain criteria. These criteria could be anything (e.g. day of the month, etc.) but are usually tied to roles. So all you'll have to do is specify the authorization rights according to the information in your Role table and the specific model instance that is going to be evaluated.

Resources