Create courseWork with studentWorkFolder - google-api

Using Google Classroom API, I am simply trying to create a coursework (assignment) where I can assign the Drive folder for that coursework then I can upload attachments into that specific folder.
I've tried on the browser with their API Explorer and also does not work.
Here's my code;
const classroom = google.classroom({version: 'v1', auth});
classroom.courses.courseWork.create({
"courseId": assignmentCreationRequest.courseId,
"resource": {
"title": assignmentCreationRequest.title,
"description": assignmentCreationRequest.description,
"workType": "ASSIGNMENT",
"state": "PUBLISHED",
"topicId": assignmentCreationRequest.topicId,
"assignment":
{
"studentWorkFolder": {
"id": "1wTM6YYAk1rp4TtsEQwjZnb3qMbR9iPbe"
}
}
}
})
The folder has been created inside the Classroom courses folder as parent.
The only way I found working to create such folder is; when creating a coursework, add materials where the share mode is set to 'STUDENT_COPY', then the API will create a folder themselves. It's a workaround where I can delete all of the contents once the folder is created, but surely there's a classier way?
Any help would be massively appreciated!

Answer:
You cannot assign a specific, previously existing Drive folder to a CourseWork.
This folder is automatically created by Google when creating the CourseWork, if the workType is ASSIGNMENT.
Also, the studentWorkFolder will only be created if there's content to place there, be it a studentSubmission or Material attached to the course work.
Reference:
If you check the CourseWork fields, you will see that, assignment (containing studentWorkFolder) is read-only:
assignment: Assignment details. This is populated only when workType is ASSIGNMENT.Read-only.
Therefore, this field will be ignored.

As #lamblichus replied, it is not possible to assign specific folder when creating a courseWork.
The studentWorkFolder will only be created when;
You provide material with shareMode set to STUDENT_COPY.
When student submit attachments to their submission.
For my case where for each submission, I'd like to modifyAttachments with custom files, I have created a folder with the name of the course then placed all of the attachments in the folder with correct permissions, then using modifyAttachments I add the file ID to the submission ID. This still won't create a studentWorkFolder but I'm able to modifyAttachments for each student.
If I were to add materials where the shareMode is STUDENT_COPY, which this will create studentWorkFolder containing the files, then I were to delete all of the contents of the folder; this means I will have a studentWorkFolder however on the courseWork, the materials attached will still be available/shown. patch wouldn't allow to update materials.
I hope this helps those also in similar situation.

Related

How to set multiple locations in Outlook compose form?

I am currently working on an Angular outlook addin using Microsoft Graph API. I have to set and get Outlook item data in compose form. I referred the link Get and set data items in outlook compse form for doing that. In the case of location, I used
Office.context.mailbox.item.location.setAsync('LocationA');
But it will take only string. In the case of multiple locations, I cant use this property. Is there any other way to implement the setting of multiple location in Outlook compose form?
You can use EnhancedLocation Preview API to set one or more locations that are associated with email ids. You need to use addAsync and passing the locations to be added to the current list of locations as locationIdentifiers.
Office.context.mailbox.item.enhancedLocation
In read and compose mode, enhancedlocation will return an object of type EnhancedLocation, on which you can perform add/get/remove operation.
var locations = [
{
"id": "ConfRoom101#contoso.com",
"type": Office.MailboxEnums.LocationType.Room
}
];
Office.context.mailbox.item.enhancedLocation.addAsync(locations);
Also be aware that this API is provided as a preview for developers and may change based on the feedback. It is wise not use this API in a production environment.

How to enumerate values of custom user property in Outlook C#

I have created custom user property in Outlook called "Ownership". When someone from the team claim ownership of an email, person's name is saved as its value.
My question, is there any way to enumerate all the values of this custom property into combo box.
In simple words, get a list of all team members names (whoever has claimed ownership of an email in inbox folder).
I want to do something like this.
Outlook.UserDefinedProperties userDefinedProperties = null;
Outlook.UserDefinedProperty userDefinedProperty = null;
Outlook.MAPIFolder currentFolder = application.ActiveExplorer().CurrentFolder;
mailUserProperties = currentFolder.UserDefinedProperties;
mailUserProperty = mailUserProperties["Ownership"];
// Filling up the combo box
PersonCombo.Items.Add(userDefinedProperty.Value);
I want to use current folder because folder will have all the values while an email can only have one value of the custom property.
If this is not possible, is there any other way to get it done?
Thank you in advance.
There isn't a single query that will return all unique values of a particular named property. The best you can do is search for all items where the property exists (not null), and then build a list of unique values.
I do not think, however, this is a good of storing possible values - it really must be a single source, such as a particular GAL distribution list, or a hidden (associated) message in the folder that stores all possible values in a single property.
Thanks everyone for your input.
At the end, I ended up creating GAL distribution list as Dmitry suggested and used it for my purpose.

Alternative for Folder.WellKnownFolderName for older Exchange versions

I use Folder.WellKnownFolderName to detect folder type, but it was introduced only in Exchange 2013. Also it doesn't work with "Clutter" folder. Can i use another Folder property to determinate exchange folder type?
Take a look at the FolderClass property. That tells you the type of folder (Mail, Calendar, etc.).
Iterate through all the WellKnownFolderNames you care about, and fetch the corresponding Folders individually by passing Folder.Bind a FolderId created with the constructor that takes a WellKnownFolderName. The FolderId of the returned Folder will have its unique ID set. Then just keep track of the FolderId-to-WellKnownFolderName mapping.

Is there a way to query for specific folder in Google drive API?

I want to retrieve all the files from a specific folder. Below code gives me all the files in my drive account.
$files = $service->files->listFiles($parameters);
Is there a way to query only a specific folder name?
I see that you are implementing with PHP. You can refer to the 'Children' resource, using the list method to show all the children within the folder you are looking for. Keep in mind that you will need the folder's id in order to list its content.
The code should be something like:
$children = $service->children->listChildren($folderId, $parameters);
You can find more information about this on: https://developers.google.com/drive/v2/reference/children/list

How to create user-specific content in Joomla! 3.0?

I need to create a User-Specific content page, I have registered users and I need to create a module/page/menu/feed or whatever that displays articles that are for only one or some users.
For example, in my site, I show to public some projects (articles redacted as some architecturing project) for example: news, finished projects, etc, some people register and can access to other content that is intended for registered users, for example: new projects that only registered clients would be interested, so far, I managed to make this work, but now, I have work that is for a specific user and he/she only can see it in his/her feed, for example: status of their project made by us, some galleries with photos of the work in progress, etc.
So, This feed must be a module/page/menu that shows articles with a specific category and for registered users. But I want to be able to post an article that is only intended for a specific user or a set of users and shows in this feed (module) or at least a whole new module that shows user-specific content without having to create a category and an access level for each user.
Is there an extension or plug-in that helps me do this?
you need to make do two things:
Make a new user-group (Users->User group) as a sub-group of
registered. Add the users that need the special permission to this
group.
Make a new access-level (Users->access-levels) and add you
new user-group to this access level
Set the access-level on the article(s) that you want to restrict access on.
The module should check the access-level before it displays it to the users, and only display the restricted articles to those that have the correct privileges.
The system don't really support what you ask for, but you could use the following setup:
Make a content-plugin (http://docs.joomla.org/J2.5:Creating_a_content_plugin). In the event onContentPrepareForm, you modify the created_by_alias-field to use it for your special user allowed to view this content article.
function onContentPrepareForm($form, $data){
// first check that context is right
// Then change the type of the field. This should allow to select
// the user when you create the article.
$form->getField('created_by_alias')->__set('type', 'user');
}
In the event onContentPrepareData, check if the data in the created_by_alias references a valid user in the user group your users shoud be in
public function onContentPrepare($context, $article, $params, $page){
// first check that context is right
//Then fetch the user data:
if(is_int($article->created_by_alias)){ // ( Optionally check if the article is in a specific category )
$db=JFactory::getDbo();
$currentuser=JFactory::getUser();
$allowedgroup=2; // the registered users group
$sql="select u.id from #__users inner join #__user_usergroup_map ug (u.id=ug.user_id) where ug.group_id={$allowedgroup}";
$db->setQuery($sql);
$user=$db->loadObject();
if($user->id==$currentuser){
$data->user=$user;
}
else{
//Unset the article content to prevent unothorized users from seeing the content.
unset($article);
}
}
Finally, create a module (http://docs.joomla.org/Creating_a_simple_module) that feeds articles for a particular user, containing at least:
$list=array();
$user=Jfactory::getUser();
if($user->id>0){
$sql="select * from #__content where created_by_alias={$user->id}";
// ( also add sql to check that the user has access,
// the article is published, the correct category etc)
$db=Jfactory::getDbo();
$db->setQuery($sql);
$list=$db->loadObjectList();
if(!count($list)) return;
}
else return;
print_r($list); // Prints the content articles
This scheme should protect unauthorized users from viewing the content of the articles ment for a specific user. The module should (after nicely outputting what you want to display) display a list of articles for the logged inn user. The module can link to the article in the normal way, and the authorized user will have access. So it should be "safe enough", and provide the functionality you need without too much hassle.
I'll try anotherone here:
You could just install a messageing system on your site. UddeIM is one such system. This will allow you to make specific content for your users. UddeIM can be configured so only administrators can send messages. There is also some modules for this component to show latest messages etc.

Resources