Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ARSnova
arsnova-click-v2-backend
Commits
9448f4a4
Commit
9448f4a4
authored
Aug 31, 2019
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Waits now until the quiz is created in the db before returning an uploaded quiz
parent
84b3bd32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
src/lib/async-for-each.ts
src/lib/async-for-each.ts
+5
-0
src/routers/rest/QuizRouter.ts
src/routers/rest/QuizRouter.ts
+5
-4
No files found.
src/lib/async-for-each.ts
0 → 100644
View file @
9448f4a4
export
async
function
asyncForEach
(
array
,
callback
):
Promise
<
void
>
{
for
(
let
index
=
0
;
index
<
array
.
length
;
index
++
)
{
await
callback
(
array
[
index
],
index
,
array
);
}
}
src/routers/rest/QuizRouter.ts
View file @
9448f4a4
...
...
@@ -33,6 +33,7 @@ import { QuizVisibility } from '../../enums/QuizVisibility';
import
{
ExcelWorkbook
}
from
'
../../export/ExcelWorkbook
'
;
import
{
IQuizStatusPayload
}
from
'
../../interfaces/IQuizStatusPayload
'
;
import
{
IQuizEntity
,
IQuizSerialized
}
from
'
../../interfaces/quizzes/IQuizEntity
'
;
import
{
asyncForEach
}
from
'
../../lib/async-for-each
'
;
import
{
MatchTextToAssetsDb
}
from
'
../../lib/cache/assets
'
;
import
{
Leaderboard
}
from
'
../../lib/leaderboard/leaderboard
'
;
import
{
QuizModel
}
from
'
../../models/quiz/QuizModelItem
'
;
...
...
@@ -140,10 +141,10 @@ export class QuizRouter extends AbstractRouter {
}
@
Post
(
'
/upload
'
)
public
uploadQuiz
(
public
async
uploadQuiz
(
@
HeaderParam
(
'
authorization
'
)
privateKey
:
string
,
//
@
UploadedFiles
(
'
uploadFiles[]
'
)
uploadedFiles
:
any
,
//
):
object
{
):
Promise
<
object
>
{
const
duplicateQuizzes
=
[];
const
quizData
=
[];
...
...
@@ -155,7 +156,7 @@ export class QuizRouter extends AbstractRouter {
});
});
quizData
.
forEach
(
(
data
:
{
fileName
:
string
,
quiz
:
IQuizEntity
})
=>
{
await
asyncForEach
(
quizData
,
async
(
data
:
{
fileName
:
string
,
quiz
:
IQuizEntity
})
=>
{
const
existingQuiz
=
QuizDAO
.
getQuizByName
(
data
.
quiz
.
name
);
if
(
existingQuiz
)
{
duplicateQuizzes
.
push
({
...
...
@@ -174,7 +175,7 @@ export class QuizRouter extends AbstractRouter {
throw
result
;
}
quizValidator
.
save
();
await
quizValidator
.
save
();
}
});
...
...
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