Get list of courses with username in moodle programmatically from database - moodle

I need to get the list of all courses available with their username who created it in moodle site programmatically from database. As I am using drupal with moodle. In drupal I connected the moodle database so I need to fetch the courses with username for further development. Please help me on this.
Regards
Neha Singhania

The only place where you can find out who created a course is in the mdl_log table. Look for an entry with module = course and action is something like 'create' (I haven't got the code in front of me right now to check). The 'course' field will match the id of the mdl_course table, where you can find the course name (fullname / shortname). The user field will match the id of the mdl_user table, where you can find the firstname, lastname and username for the user.

Related

How to access Employee Id from Azure AD using Microsoft graph

At first I want to mentioned I did search for the answer but I did not get the concrete answer. So here I am asking again.
I am using MVC.net project and using Microsoft graph to get informaiton from Azure AD. I am trying to get EmployeeId along with DisplayName. For the scope I am using 'user.readbasic.all
With below query I am getting DiplayName for all the users but for EmployeeID I am getting null. Except for myself.
"https://graph.microsoft.com/v1.0/users?$select=DisplayName,EmployeeId";
When I use "me" then again get the EmployeeID.
"https://graph.microsoft.com/v1.0/me?$select=DisplayName,EmployeeId";
So using the user.readbasic.all I do get employee id but for myself but why not for others
This is due to for others Employee ID has not been set.
Example: Employee ID has not been set for a user ,so it is showing null.
Let me Set an employee ID for a user.
Now I am testing for with same API I am getting my EmployeeID value.
In below Picture you can see as I have set EID for Rahul Only and for others it is showing null.

Field visibility restriction/access control in MongoDB

I currently own a MongoDB database that contains a collection named User. User collection has a field called contact_info among several other fields.
My requirement is to allow a member in my team having access to the database with 'admin' role to view contact_info when querying a user, however, a team member with 'developer' role should be able to query a user but not view his/her contact_info (i.e. contact_info key in the user document should be hidden or masked for a team member with 'developer' role). I am looking for a field-level visibility restriction in MongoDB to comply with GDPR standards.
I am comparatively new to MongoDB and did some search for this requirement, but could not find any direct solution for this. Any help with be greatly appreciated.
Looks like you could create a view with only the fields needed (https://docs.mongodb.com/manual/core/views/).
Then I would create an extra user developer and 1 extra role developerRole
This developerRole should only have access to the view created.

Microsoft Master Data Services 2016 Additonal Domain Atrribute Referencing

Is it possible to reference additional columns apart from the 'Code' and 'Name' columns when using a domain attribute in an entity?
E.g. A person entity has a code of '1' and a name of 'Smith' and a Gender of 'Male'
In a customer entity there is a domain value referencing the person entity which displays the following 1 {Smith}. The users would like an additional read only attribute which would copy the Gender value of 'Male' into the customer entity based on the domain value. Can this be done using out of the box MDS UI?
I know this is duplicate data and breaks normal form but for usability this would be useful. It would be the equivalent of referencing additional columns in an MS Access drop down list.
Many thanks in advance for any help
This is not possible with the standard UI. One option would be to develop a custom UI where you can handle these kind of requests.
If you want to stick with the standard product I can see a workaround but this is a bit of a "dirty" one.
You can misuse (abuse) the Name attribute of the Person entity by adding a business rule to the Person entity that generates the content of the Name attribute as a concatenation of multiple attributes. You of course need an additional attribute that serves as a place holder for the original Name. The concatenated field will then show in your customer entity.
One question that does come to mind is why a user would like/need to see the gender of a person in a customer list? As you have a separate Person entity I expect you to have multiple persons per customers. What would the gender of one person - even if it is the main contact - matter?

Get Username using GUID in Sugarcrm

I have an issue with my SugarCRM reset password page. When a user visits the Reset Password form through the link provided through mail, he/she has to put the username. If the username is kept empty the form gets submitted but the password doesn't change.
I want to either make username required field or fetch the username using GUID. Thanks.
$user = BeanFactory::getBean('Users',$guid);
$username = $user->user_name;
The guid included in the password reset link is not the guid for that user (that would be a security risk). Instead, it is a guid to the users_password_link table. If you are using the guid passed in from such a link, then you could find the username by the following SQL statement:
select users.user_name from users join users_password_link on users_password_link.username = users.user_name where users_password_link.id = '$guid';
If you were working with the user's actual guid, egg's answer is the correct way to find the information using SugarCRM's best practices.

Entity Framework code first aspnet_Users mapping / joins

I was wondering with Entity Framework 4.1 code first how do you guys handle queries that involve an existing aspnet_Users table?
Basically I have a requirement for a query that involves the aspnet_Users so that I can return the username:
SELECT t.Prop1, u.Username
FROM Table1 t
INNER JOIN aspnet_User u ON t.UserId = u.UserId
Where t.Prop2 = true
Ideally in linq I would like:
from t in context.Table1
join u in context.aspnet_Users on t.UserId equals u.UserId
where t.Prop2 = true
But I'm not sure how to get aspnet_Users mapping to a class User? how do I make aspnet_Users part of my dbset ?
Any help would be appreciated, thanks in advance
Don't map aspnet_Users table or any other table related to aspnet. These tables have their own data access and their own logic for accessing. Mapping these tables will introduce code duplication, possible problems and breaks separation of concerns. If you need users for queries, create view with only needed information like id, user name, email and map the view. The point is that view will be read only, it will contain only allowed data and your application will not accidentally modify these data without using ASP.NET API.
First read Ladislav's answer. If you still want to go ahead : to do what you want would involve mapping the users and roles and members tables into the codefirst domain - which means writing a membership provider in code-first.
Luckily there is a project for that http://codefirstmembership.codeplex.com/ although its not a perfect implementation. The original is VB, look in the Discussion tab for my work on getting it running in c# MVC.
I'm working with the author on a better implementation that protects the membership data (password, last logged on date, all of the non-allowed data) but allow you to map and extend the user table. But its not ready yet!
You don't really need to use Entity Framework to access aspnet_membership provider accounts. You really just need to create an instance of the membership object, pass in a unique user identifier and a Boolean value indicating whether to update the LastActivityDate value for the user and the method returns a MembershipUser object populated with current values from the data source for the specified user.
You can then access the username by using the property of "Username".
Example:
private MembershipUser user =
Membership.GetUser(7578ec40-9e91-4458-b3d6-0a69dee82c6e, True);
Response.Write(user.UserName);
In case you have additional questions about MembershipProvider, you can read up on it on the MSDN website under the title of "Managing Users by Using Membership".
Hope this helps you some with your requirement.