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
68ae2355
Commit
68ae2355
authored
Aug 22, 2019
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds improvements to the legacy quiz parsing
parent
0bf65003
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
src/db/quiz/QuizDAO.ts
src/db/quiz/QuizDAO.ts
+12
-10
No files found.
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
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