I am using open edx api with my react app so I just want to return json response of all course related content. Please help me out.
Hi @Richa_Tiwari, you can use the course blocks API to get that information. That’s the same API used by the mobile app.
GET /api/courses/v1/blocks/?course_id=<course_id>
&username=<username here, must be enrolled in the course>
&depth=all
&requested_fields=graded,student_view_data
&student_view_data=video
In particular, the JSON data for each XBlock is the student_view_data
field, so you may need to change the student_view_data=
parameter to list each XBlock type that you are using.
Thank You so much @braden but when I am hitting api
http://localhost:18000/api/courses/v1/blocks/block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef/?username=staff&depth=all&requested_fields=graded,format,student_view_multi_device,lti_url,due&block_counts=video&student_view_data=video on postman I am not getting student_view_data
my response is like:
{
“root”: “block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef”,
“blocks”: {
“block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef”: {
“id”: “block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef”,
“block_id”: “27cc702cdac7431c9cd51eaf986651ef”,
“lms_web_url”: “http://localhost:18000/courses/course-v1:edX+E2E-101+course/jump_to/block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef”,
“student_view_url”: “http://localhost:18000/xblock/block-v1:edX+E2E-101+course+type@problem+block@27cc702cdac7431c9cd51eaf986651ef”,
“type”: “problem”,
“display_name”: “Question 1”,
“graded”: false,
“student_view_multi_device”: true
}
}
}
Note: an answer to the above was posted here: In XBlock api not getting student_view_data