whitmer / canvabadges

MIT License
29 stars 14 forks source link

A student isn't detected as a student when the application is translated #2

Closed Kulgar closed 11 years ago

Kulgar commented 11 years ago

Hi again Whitmer :)

I have found an important issue that prevent students from being detected as student when they access a badge.

In your file "lib/views.rb" you have this line of code:

@student = scores_json['enrollments'].detect{|e| e['type'] == 'student' }

But when the Canvas application is translated, for instance, in French, the e['type'] isn't student but "Étudiant". So the detect fails and @student is empty and so it breaks the "badge_check" page.

Wouldn't it be better to test the "role" attribute? It seems to be quite a 'constant' as in French the role appears as "StudentEnrollment".

I've made my own change within my instance of canvabadges and it does work. But maybe there is a drawback I haven't thought about?

Do you want me to help you solving this issue? It's an important one but I think it is an easy one to solve, isn't it?

Best regards, Kulgar.

whitmer commented 11 years ago

You're right, that would be better. Happy to accept a pull request to give you credit :-).

Kulgar commented 11 years ago

Ok! Thanks :) No problem, I'll do it tomorrow. (French time ;) )

Kulgar commented 11 years ago

Done :-)