proversity-org / badgr-xblock

3 stars 5 forks source link

JS error checking for badge #20

Open bryanlandia opened 5 years ago

bryanlandia commented 5 years ago

I get the following JS error when checking for section completion and earning a badge:

(index):2409 Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Object.getGrades [as success] ((index):2409)
    at fire (lms-main_vendor.53cdacba553b.js:2)
    at Object.fireWith [as resolveWith] (lms-main_vendor.53cdacba553b.js:2)
    at done (lms-main_vendor.53cdacba553b.js:4)
    at XMLHttpRequest.<anonymous> (lms-main_vendor.53cdacba553b.js:4)

The error is with these lines https://github.com/proversity-org/badgr-xblock/blob/7077d499b2f752c78bb41e9c17b4bbc7d57bcd55/badgr/static/js/src/badgr.js#L17-L19 :

No data for section_scores is returned in the JSON from a GET request to /api/grades/v0/course_grade/course-v1:Appsembler+002+2018_Q3/users/?username=bryanlandia

what is returned is:

[{"username":"bryanlandia","letter_grade":null,"percent":0.01,"course_key":"course-v1:Appsembler+002+2018_Q3","passed":false}]

Were you using a custom branch of edx-platform for this? I don't see any section_scores returned by the view method here

https://github.com/edx/edx-platform/blob/edx_master/lms/djangoapps/grades/api/views.py#L164-L186

lidijarad commented 5 years ago

Hi @bryanlandia,

Firstly apologies, the link to the commit in the Badgr Xblock readme doesn't exist anymore unfortunately. But there are a few changes you would have to implement in the grades app of the edx-platform. You can take a look at this version of the views.py file. You will see it contains the section_scores key.

https://github.com/proversity-org/edx-platform/blob/master/lms/djangoapps/grades/api/views.py#L79

I'll try find the original commit showing all the changes to all files in the grades app.

bryanlandia commented 5 years ago

Hi @lidijarad Thanks for the quick response! I'll give that a try. Is that commit something you have tried to push upstream?

giasiranisst commented 5 years ago

Hello @bryanlandia,

I have the same JS error. I copied all the files from api folder from the link that gave @lidijarad and compiled them using the py_compile command. Then I restarted the platform but the lms displays Internal error.

Did you manage to fix the error and how?