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

Reading a student grade when she has none yet results in an error. #81

Closed
Tazaf opened this issue Jul 6, 2018 · 0 comments
Closed

Reading a student grade when she has none yet results in an error. #81

Tazaf opened this issue Jul 6, 2018 · 0 comments

Comments

@Tazaf
Copy link

Tazaf commented Jul 6, 2018

When calling send_read_result() for a student that doesn't have any grade yet, some LMS (specifically Moodle) send back a XML response with a body value of "".

Here's an extract of the received XML sent back by a Moodle instance where the student did not have any grade for the activity :

<resultScore>
  <language>en</language>
  <textString/>
</resultScore>

As you can see, the value of textString is "".
This causes the lib to raise an error.

Having followed the chain of method, I've pinpointed the line that, according to me, causes the issue :

score = parseFloat navigateXml(xml, 'imsx_POXBody.readResultResponse.result.resultScore.textString'), 10

The combination of parseFloat and navigateXml in the same line yield a score value of NaN (which is normal).

But the following check of isNan(score) returns an error as if this was an error case (which is not):

callback new errors.OutcomeResponseError('Invalid score response'), false

I would expect a different behavior between a case where there is no grade yet and a case when the LMS sends back an actual invalid value.

I previously thought about returning a 0 value when there is no grade yet. But it might be confusing with the case where the student has received an actual 0 grade ? Dunno.

@Tazaf Tazaf changed the title Reading the grade when there is none yet results in an error. Reading a student grade when she has none yet results in an error. Jul 6, 2018
@Tazaf Tazaf closed this as completed Sep 1, 2023
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

1 participant