I'm trying to get Moodle's quizzes as JSON. I've already tried
http://desenvolvimento.imd.ufrn.br/qmmoodle/webservice/rest/server.php?wstoken=cf5a6639a4431341a40e7a75d8bb9cba&wsfunction=get_quizzes_by_course&moodlewsrestformat=json&course_id=2
To get all quizzes from a specific course. And
http://desenvolvimento.imd.ufrn.br/qmmoodle/webservice/rest/server.php?wstoken=cf5a6639a4431341a40e7a75d8bb9cba&wsfunction=get_quiz&moodlewsrestformat=json&quiz_id=3
To get a specific quiz.
I don't know what is wrong in my URL.
Thanks.
I think that you are referring to this document. If you read closely, you'll notice that it's a proposal about how the quiz web service should be written.
In fact, when I tried your query, to get all quizzes from a course, I got:
{"exception":"dml_missing_record_exception","errorcode":"invalidrecord",
"message":"Can not find data record in database table external_functions.",
"debuginfo":"SELECT * FROM {external_functions}
WHERE name = ?\n[array (\n 0 => 'get_quiz',\n)]"}
Moodle didn't found the external function get_quiz. That means... unfortunately, as of now, Moodle does not have a web service for quizzes.
If you feel adventurous, and what you need is just getting the quizzes, you could implement a web service to do that. The relevant moodle table about quizzes is mdl_quiz (for a full schema, look at this article), and here's the tutorial that shows how to implement it: Adding a web service to a plugin - Moodle Docs.
mod_quiz_get_quizzes_by_courses
is the function that does the job. How to call it
https://yourmoodledomain/webservice/rest/server.php?moodlewsrestformat=json&courseids[0]=courseid&wsfunction=mod_quiz_get_quizzes_by_courses&wstoken=yourusertoken
Related
At the moment I am adding the user to one group at a time using this endpoint:
PUT /{realm}/users/{id}/groups/{groupId}
In my use case it would be beneficial to perform the affectations in bulk, so far I haven't found a documented way of doing so, is there a way to do it?
Thanks
PUT /{realm}/users/{id}
It's in the documentation, but it doesn't work.
I started discussion on github
You could try to update the full user data
PUT /{realm}/users/{id}
with a partial UserRepresentation containing a minimal json with "groups" array only ?
I see that nearly all fields are marked as optional:
cfr https://www.keycloak.org/docs-api/12.0/rest-api/index.html#_userrepresentation
I have created a ASP.net core web app with user authentication. The user authentication has been auto-implemented and it works like a charm. However, I need to do 2 things:
-Add a text field 'Name' to the user registration
-Write a record into another (custom-made) table when AspNetUsers is written to.
However, I can't seem to find where (meaning in what file/method) either of these things can be done.
I tried and debugged the web app, but it didn't help.
As I expect that IdentityUsers are written to the data base using DbContext.Add, I also searched for that but didn't help either.
Thank you in advance.
The following article explains everything: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio .
Could somebody help to find out the expected behavior in filtering data within REST.
I have an ordinary REST-service with API
GET /api/articles <-- extract all articles
GET /api/articles?category=1 <-- extract all articles belonging the
particular category
I have doubts regarding the second stuff. What must a request return if user set an invalid category. There're 3 options:
return all articles
return an empty collection
return error
I suppose that it might be up to me, but anyway I wonder whether somebody have implemented this and how he/she resolved it.
You have answered your question yourself, but to provide you an example how this is already implemented (in numerous cases) but just pointing to one such example using JIRA.
You can use JIRA's REST APIs to GET the ticket details and which is what I'm showing you here:
Using CURL, I've tried to get the ticket details providing an invalid JIRA ticket id and the above is the response that I received.
It is up to us to decide upon what needs to be the outcome of the REST APIs that we develop, just pointing out one of the scenarios from JIRA REST APIs where they chose to error out (instead of showing no response or etc).
Hope this answers your question well!
I am trying to build a little web application with the MEAN stack (MongoDB, ExpressJS, AngularJS and NodeJS).
My question is very simple. If you take the example of a blog, it will contains blog posts, that you could list at this url:
GET /api/posts
You could also get the comments for that posts:
GET /api/posts/:postId/comments
and get a single comment:
GET /api/posts/:postId/comments/:commentId
The relation between post and comment is really obvious here, but does it still makes it mandatory to have it this way? or could I just perform my CRUD operations through /api/comments? In the end, a comment object in mongodb will always have a postId attribute anyway which will reference the post that it is related to... Moreover, the API will not be exposed and is strictly meant to be used by the application.
does it still makes it mandatory to have it this way?
No. This is not mandatory at all.
or could I just perform my CRUD operations through /api/comments?
Yes. This will result in cleaner resources URIs (endpoints).
You can also get post-specific comments with:
GET /api/comments?postId={postId}
Further, you could also drop the /api prefix if you are serving only an API at the given host.
I want to make my system redirect unknown requests such as
www.address.com/a_company
to the adress
www.address.com/companies/company/ and display the company a_company if it exists in the database, otherwise throw the user to a 404 not found page.
So in detail, I want to make namespace that is as the first example dynamically, if the company exist in the database, I have no problem connecting to the database and retrieving information or finding a way to parse a company name, I just need help how to make my system check and run a function every time the address doesn't exist and show the second page (/companies/company/)..
I am using an Acl as well, but I think it should be fine if the page is /companies/company and then possibly add /?c=a_company or similar.
Thank you.
/Marcus
simply create a front controller plugin which checks the request params agains the database before the request is dispatched.