core_grades_update_grades syntax

core_grades_update_grades syntax

by Dan Logan -
Number of replies: 4

Hi

Is there any documentation or would anoyone be able to assist with syntax for webservices api for updating a students grades.

I'm trying to update a students quiz grade but don;t know some of the vairables...

Wht is "component"  below referring to? 

Activity ID?

&wsfunction=core_grades_update_grades&moodlewsrestformat=json&source=ap&courseid=252&component=mod_url&activityid=12637&itemnumber=0&itemdetails[itemname]=Activity&itemdetails[idnumber]=0&grades[0][studentid]=14289&grades[0][grade]=79

Thank you

Dan



Average of ratings: -
In reply to Dan Logan

Re: core_grades_update_grades syntax

by Arodi Emmanuel Monge Tevalan -

Hello Dan Nice to meet you, I am writing from Guatemala. Sorry, I ran into your forum "core_grades_update_grades syntax" on moodle.org Did you manage to work with this function? If so, can you give me an example of how to consume it? I look forward to your comments and very grateful in advance.

Best regards,

Sincerely,

Arodi Emmanuel

In reply to Arodi Emmanuel Monge Tevalan

Re: core_grades_update_grades syntax

by Dan Logan -
Hi Arodi, No unfortuantely I didn't continue looking into this function any further. Good luck and if you do find the answer please share!

Thanks
Dan

In reply to Dan Logan

Re: core_grades_update_grades syntax

by Arodi Emmanuel Monge Tevalan -
Hello Dan

I found a way to use the "core_grades_update_grades" function.

It's quite simple, I used Postman. There's attached an example and a screenshot.

https://www.screencast.com/t/7RhCjVghN

https://MOODLEURLSITE.COM/webservice/rest/server.php?wstoken=MYTOKEN&wsfunction=core_grades_update_grades&moodlewsrestformat=json&source=assignment &courseid=IDOFCOURSE&component=mod_assign&activityid=IDOFACTIVITY&itemnumber=0&itemdetails[itemname]=NAMEITEM&itemdetails[hidden]=1

wstoken: MYTOKEN // Token generated from my site in moodle.
wsfunction: core_grades_update_grades // Name of the function used
moodlewsrestformat: json // Format in which I wish the information to be returned
source: assignment // With "source" I have a lot of doubts, due to Moodle documentation says that it must be the companion of the "mod", I do not know why we still use the component.
Courseid: IDOFCOURSE // Course ID, type Int
component: mod_assign // As I mentioned before, "Source" is a bit redundant to use it as a component and source.
activityid: IDOFACTIVITY // ID of the activity, to find this ID I recommend using the "gradereport_user_get_grade_items" function to do it in a systematized way.
itemnumber: 0 // If you have not defined an identifier to the Item this must be "0"
itemdetails[itemname]: NAMEITEM // Name which the Item could to be renamed.
itemdetails[hidden]: 1 // To hide the item use "1" otherwise "0"


This function core_grades_update_grades, can return 4 types of states:
0 => OK, 1 => Fail, 2 => Multiple updated, 4 => Locked (Yes, 0 means OK and 3 is missing, see lib / grade / constans.php) ";

Unfortunately, this function doesn't do what I need. Now I need to block the grade items using a WS function. I have not found the right function. Do you know if you can block rating elements or rating categories?

Best regards,
In reply to Dan Logan

Re: core_grades_update_grades syntax

by Eduardo Ramirez -

Hi, maybe this information can help you, https://www.refineddata.com/api/

Optional //Any grade item settings to alter
object {
itemname string  Optional //The grade item name
idnumber int  Optional //Arbitrary ID provided by the module responsible for the grade item
gradetype int  Optional //The type of grade (0 = none, 1 = value, 2 = scale, 3 = text)
grademax double  Optional //Maximum grade allowed
grademin double  Optional //Minimum grade allowed
scaleid int  Optional //The ID of the custom scale being is used
multfactor double  Optional //Multiply all grades by this number
plusfactor double  Optional //Add this to all grades
deleted int  Optional //True if the grade item should be deleted
hidden int  Optional //True if the grade item is hidden
} 


You can find "core_grades_update_grades" use ctl+f, in this section you will find the parameters.


regards