Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS error checking for badge #20

Open
bryanlandia opened this issue Sep 27, 2018 · 3 comments
Open

JS error checking for badge #20

bryanlandia opened this issue Sep 27, 2018 · 3 comments

Comments

@bryanlandia
Copy link

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

var section_scores = data['section_scores'];
// Check that the section name specified in Xblock exists in Grades report
if (section_scores.hasOwnProperty(section_title)) {
:

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
Copy link
Contributor

lidijarad commented Sep 28, 2018

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
Copy link
Author

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

@giasiranisst
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants