Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
arsnova-click-v2-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
arsnova-click-v2-backend
Commits
2b9fa7ca
Commit
2b9fa7ca
authored
Aug 31, 2019
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds check for the leaderboard in case there are invalid responses
parent
6819ba5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
src/lib/leaderboard/leaderboard.ts
src/lib/leaderboard/leaderboard.ts
+13
-1
No files found.
src/lib/leaderboard/leaderboard.ts
View file @
2b9fa7ca
...
...
@@ -170,10 +170,18 @@ export class Leaderboard {
}
private
isCorrectSingleChoiceQuestion
(
response
:
number
,
question
:
AbstractChoiceQuestionEntity
):
boolean
{
if
(
typeof
response
===
'
undefined
'
||
typeof
response
!==
'
number
'
||
!
question
.
answerOptionList
[
response
])
{
return
false
;
}
return
question
.
answerOptionList
[
response
]
&&
question
.
answerOptionList
[
response
].
isCorrect
;
}
private
isCorrectMultipleChoiceQuestion
(
response
:
Array
<
number
>
,
question
:
AbstractChoiceQuestionEntity
):
number
{
if
(
!
Array
.
isArray
(
response
))
{
return
-
1
;
}
let
hasCorrectAnswers
=
0
;
let
hasWrongAnswers
=
0
;
question
.
answerOptionList
.
forEach
((
answeroption
,
answerIndex
)
=>
{
...
...
@@ -193,11 +201,15 @@ export class Leaderboard {
}
private
isCorrectRangedQuestion
(
response
:
number
,
question
:
RangedQuestionEntity
):
number
{
if
(
typeof
response
===
'
undefined
'
||
typeof
response
!==
'
number
'
)
{
return
-
1
;
}
return
response
===
question
.
correctValue
?
1
:
response
>=
question
.
rangeMin
&&
response
<=
question
.
rangeMax
?
0
:
-
1
;
}
private
isCorrectFreeTextQuestion
(
response
:
string
,
question
:
FreeTextQuestionEntity
):
boolean
{
if
(
!
response
)
{
if
(
typeof
response
===
'
undefined
'
||
typeof
response
!==
'
string
'
)
{
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment