Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Math Tutor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jannik Wurche
Math Tutor
Commits
00828b4d
Commit
00828b4d
authored
9 months ago
by
Jannik Wurche
Browse files
Options
Downloads
Patches
Plain Diff
add comments
parent
9d0e26ae
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#22346
passed
9 months ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Utils/HelperFunction.elm
+11
-3
11 additions, 3 deletions
src/Utils/HelperFunction.elm
with
11 additions
and
3 deletions
src/Utils/HelperFunction.elm
+
11
−
3
View file @
00828b4d
...
@@ -11,10 +11,12 @@ import Html.Attributes exposing (href)
...
@@ -11,10 +11,12 @@ import Html.Attributes exposing (href)
import
String
exposing
(
toLower
,
replace
)
import
String
exposing
(
toLower
,
replace
)
-- Initialize an empty quiz.
initQuiz
:
Quiz
initQuiz
:
Quiz
initQuiz
=
initQuiz
=
Quiz
"
"
"
"
Nothing
[]
Quiz
"
"
"
"
Nothing
[]
-- URL parser for routing within the application.
urlParser
:
Url
.
Parser
.
Parser
(
Route
->
a
)
a
urlParser
:
Url
.
Parser
.
Parser
(
Route
->
a
)
a
urlParser
=
urlParser
=
Url
.
Parser
.
oneOf
Url
.
Parser
.
oneOf
...
@@ -24,20 +26,24 @@ urlParser =
...
@@ -24,20 +26,24 @@ urlParser =
,
Url
.
Parser
.
map
ResultRoute
<|
Url
.
Parser
.
s
"
result"
,
Url
.
Parser
.
map
ResultRoute
<|
Url
.
Parser
.
s
"
result"
]
]
-- Extract the route from a given URL.
getRoute
:
Url
.
Url
->
Route
getRoute
:
Url
.
Url
->
Route
getRoute
url
=
getRoute
url
=
Maybe
.
withDefault
NotFound
(
Url
.
Parser
.
parse
urlParser
url
)
Maybe
.
withDefault
NotFound
(
Url
.
Parser
.
parse
urlParser
url
)
-- Create a view link element.
viewLink
:
String
->
Html
msg
viewLink
:
String
->
Html
msg
viewLink
path
=
viewLink
path
=
li
[]
[
a
[
href
path
]
[
text
path
]
]
li
[]
[
a
[
href
path
]
[
text
path
]
]
-- Normalize a string by converting it to lowercase and removing spaces.
normalizeString
:
String
->
String
normalizeString
:
String
->
String
normalizeString
str
=
normalizeString
str
=
str
str
|>
toLower
|>
toLower
|>
replace
"
"
"
"
|>
replace
"
"
"
"
-- Retrieve a question at a specific index from the list of questions.
getQuestionAt
:
Int
->
List
Question
->
Maybe
Question
getQuestionAt
:
Int
->
List
Question
->
Maybe
Question
getQuestionAt
index
q
=
getQuestionAt
index
q
=
case
q
of
case
q
of
...
@@ -49,6 +55,7 @@ getQuestionAt index q =
...
@@ -49,6 +55,7 @@ getQuestionAt index q =
else
else
Just
x
Just
x
-- Update a question at a specific index with a new value.
updateQuestionsAt
:
Int
->
String
->
List
Question
->
List
Question
updateQuestionsAt
:
Int
->
String
->
List
Question
->
List
Question
updateQuestionsAt
index
newValue
q
=
updateQuestionsAt
index
newValue
q
=
case
q
of
case
q
of
...
@@ -62,13 +69,14 @@ updateQuestionsAt index newValue q =
...
@@ -62,13 +69,14 @@ updateQuestionsAt index newValue q =
newQuestionType
=
case
x
.
questionType
of
newQuestionType
=
case
x
.
questionType
of
MCQ
a
->
MCQ
a
->
let
let
-- Update the user selection for MCQ (Multiple Choice Question).
newUserSelection
=
if
List
.
member
newValue
a
.
userSelection
newUserSelection
=
if
List
.
member
newValue
a
.
userSelection
then
List
.
filter
(
\
o
->
o
/=
newValue
)
a
.
userSelection
then
List
.
filter
(
\
o
->
o
/=
newValue
)
a
.
userSelection
else
a
.
userSelection
++
[
newValue
]
else
a
.
userSelection
++
[
newValue
]
in
in
MCQ
{
a
|
userSelection
=
newUserSelection
}
MCQ
{
a
|
userSelection
=
newUserSelection
}
SCQ
a
->
SCQ
{
a
|
userSelection
=
newValue
}
SCQ
a
->
SCQ
{
a
|
userSelection
=
newValue
}
-- Update the user selection for SCQ (Single Choice Question).
Input
a
->
Input
{
a
|
userSelection
=
newValue
}
Input
a
->
Input
{
a
|
userSelection
=
newValue
}
-- Update the user selection for Input type question.
newQuestion
=
{
x
|
questionType
=
newQuestionType
}
newQuestion
=
{
x
|
questionType
=
newQuestionType
}
in
in
newQuestion
::
xs
newQuestion
::
xs
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment