Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Info Visualisation Students performance in exams
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
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Edward Sabinus
Info Visualisation Students performance in exams
Commits
6d10416a
Commit
6d10416a
authored
3 years ago
by
Sabed Ger
Browse files
Options
Downloads
Patches
Plain Diff
Die csv-Daten werden nun decodiert und in einer einfachen Tabelle ausgegeben
parent
bd5bc264
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Programm/src/StudentsPerformanceInExams.elm
+59
-21
59 additions, 21 deletions
Programm/src/StudentsPerformanceInExams.elm
with
59 additions
and
21 deletions
Programm/src/StudentsPerformanceInExams.elm
+
59
−
21
View file @
6d10416a
...
...
@@ -2,7 +2,7 @@ module StudentsPerformanceInExams exposing (main)
-- elm stuff
import
Browser
import
Html
exposing
(
Html
,
text
,
pre
,
div
)
import
Html
exposing
(
Html
,
text
,
pre
,
div
,
table
,
tr
,
th
,
td
)
import
Http
import
Dict
import
Maybe
.
Extra
...
...
@@ -38,7 +38,7 @@ main =
-- MODEL
type
alias
Model
=
{
httpState
:
HttpState
,
fullTexts
:
List
{
description
:
String
,
data
:
String
}
,
data
:
List
Old
Data
,
data
:
List
Data
,
error
:
String
}
...
...
@@ -58,9 +58,9 @@ type alias Data = { gender: String
,
parentEducation
:
String
,
lunch
:
String
,
testPreparation
:
String
,
mathScore
:
String
,
readingScore
:
String
,
writingScore
:
String
,
mathScore
:
Int
,
readingScore
:
Int
,
writingScore
:
Int
}
filesToLoad
=
...
...
@@ -101,10 +101,7 @@ updateModel msg model =
in
{
model
|
httpState
=
Success
,
fullTexts
=
checkedFullTexts
,
data
=
prepareData
<|
List
.
map
(
\
data
->
OldData
data
.
description
<|
csvString_to_data
data
.
data
)
checkedFullTexts
,
data
=
csvString_to_data
<|
Maybe
.
withDefault
"
"
<|
List
.
head
<|
List
.
map
.
data
checkedFullTexts
}
else
{
model
|
httpState
=
Loading
(
filesLeft
-
1
)
,
fullTexts
=
{
description
=
file
,
data
=
fullText
}
::
model
.
fullTexts
...
...
@@ -129,7 +126,36 @@ view model =
text
(
"
Loading... "
++
(
String
.
fromInt
index
)
++
"
left"
)
Success
->
text
<|
Maybe
.
withDefault
"
Nothing here"
<|
List
.
head
<|
List
.
map
.
data
model
.
fullTexts
div
[]
[
table
[]
(
List
.
concat
[[
tr
[]
[
th
[]
[
text
"
gender"
]
,
th
[]
[
text
"
race"
]
,
th
[]
[
text
"
parentEducation"
]
,
th
[]
[
text
"
lunch"
]
,
th
[]
[
text
"
testPreparation"
]
,
th
[]
[
text
"
mathScore"
]
,
th
[]
[
text
"
readingScore"
]
,
th
[]
[
text
"
writingScore"
]
]
]
,
List
.
map
(
\
data
->
tr
[]
[
td
[]
[
text
data
.
gender
]
,
td
[]
[
text
data
.
race
]
,
td
[]
[
text
data
.
parentEducation
]
,
td
[]
[
text
data
.
lunch
]
,
td
[]
[
text
data
.
testPreparation
]
,
td
[]
[
text
<|
String
.
fromInt
data
.
mathScore
]
,
td
[]
[
text
<|
String
.
fromInt
data
.
readingScore
]
,
td
[]
[
text
<|
String
.
fromInt
data
.
writingScore
]
]
)
model
.
data
]
)
--, text <| Maybe.withDefault "Nothing here" <| List.head <| List.map .data model.fullTexts
]
{-
let rawlevel : Int -> List (Int,Int)
...
...
@@ -260,22 +286,34 @@ checkInputFormat input =
in
{
input
|
data
=
dataInCorrectFormat
}
else
input
csvString_to_data
:
String
->
List
(
String
,
Maybe
Float
)
csvString_to_data
:
String
->
List
Data
csvString_to_data
csvRaw
=
Csv
.
parse
csvRaw
|>
Csv
.
Decode
.
decodeCsv
decodeSt
ockDay
|>
Csv
.
Decode
.
decodeCsv
decodeSt
udentsPerformanceInExams
|>
Result
.
toMaybe
|>
Maybe
.
withDefault
[]
decodeStockDay
:
Csv
.
Decode
.
Decoder
((
String
,
Maybe
Float
)
->
a
)
a
decodeStockDay
=
Csv
.
Decode
.
map
(
\
a
b
->
(
a
,
Just
b
))
(
Csv
.
Decode
.
field
"
Date"
Ok
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
Open"
(
String
.
toFloat
>>
Result
.
fromMaybe
"
error parsing string"
)
)
)
{-gender: String
, race: String
, parentEducation: String
, lunch: String
, testPreparation: String
, mathScore: Int
, readingScore: Int
, writingScore: Int
-}
decodeStudentsPerformanceInExams
:
Csv
.
Decode
.
Decoder
(
Data
->
a
)
a
decodeStudentsPerformanceInExams
=
Csv
.
Decode
.
map
(
\
gender
race
pE
lunch
test
math
read
write
->
Data
gender
race
pE
lunch
test
math
read
write
)
(
Csv
.
Decode
.
field
"
gender"
Ok
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
race/ethnicity"
Ok
)
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
parental level of education"
Ok
)
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
lunch"
Ok
)
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
test preparation course"
Ok
)
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
math score"
(
String
.
toInt
>>
Result
.
fromMaybe
"
error parsing math score"
))
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
reading score"
(
String
.
toInt
>>
Result
.
fromMaybe
"
error parsing reading score"
))
|>
Csv
.
Decode
.
andMap
(
Csv
.
Decode
.
field
"
writing score"
(
String
.
toInt
>>
Result
.
fromMaybe
"
error parsing writing score"
))
)
prepareData
:
List
OldData
->
List
OldData
prepareData
rawData
=
...
...
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