Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Privacy
Imprint
Contact
Login methods
Sign in
Toggle navigation
Menu
Open sidebar
ARSnova
arsnova-click-v2-backend
Commits
68ae2355
Commit
68ae2355
authored
Aug 22, 2019
by
Christopher Mark Fullarton
Browse files
Adds improvements to the legacy quiz parsing
parent
0bf65003
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db/quiz/QuizDAO.ts
View file @
68ae2355
...
...
@@ -112,7 +112,7 @@ class QuizDAO extends AbstractDAO<Array<IQuizEntity>> {
}
public
convertLegacyQuiz
(
legacyQuiz
:
any
):
void
{
this
.
replaceTypeInformationOnLegacyQuiz
(
legacyQuiz
);
legacyQuiz
=
this
.
replaceTypeInformationOnLegacyQuiz
(
legacyQuiz
);
if
(
legacyQuiz
.
hasOwnProperty
(
'
configuration
'
))
{
// Detected old v1 arsnova.click quiz
// noinspection TypeScriptUnresolvedVariable
...
...
@@ -260,24 +260,26 @@ class QuizDAO extends AbstractDAO<Array<IQuizEntity>> {
return
ordered
;
}
private
replaceTypeInformationOnLegacyQuiz
(
obj
):
void
{
if
(
!
obj
.
hasOwnProperty
(
'
type
'
)
)
{
return
;
private
replaceTypeInformationOnLegacyQuiz
(
obj
):
object
{
if
(
typeof
obj
!==
'
object
'
)
{
return
obj
;
}
obj
.
TYPE
=
obj
.
type
;
delete
obj
.
type
;
Object
.
values
(
obj
).
forEach
((
val
)
=>
{
Object
.
entries
(
obj
).
forEach
(([
key
,
val
])
=>
{
if
(
Array
.
isArray
(
val
))
{
val
.
forEach
((
elem
,
index
)
=>
{
this
.
replaceTypeInformationOnLegacyQuiz
(
val
[
index
]);
obj
[
key
][
index
]
=
this
.
replaceTypeInformationOnLegacyQuiz
(
val
[
index
]);
});
}
else
if
(
typeof
val
===
'
object
'
)
{
this
.
replaceTypeInformationOnLegacyQuiz
(
val
);
obj
[
key
]
=
this
.
replaceTypeInformationOnLegacyQuiz
(
val
);
}
});
obj
.
TYPE
=
obj
.
type
;
delete
obj
.
type
;
return
obj
;
}
private
getLastPersistedNumberForQuizzes
(
data
:
Array
<
IQuizEntity
>
):
number
{
...
...
Write
Preview
Supports
Markdown
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