Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Backend
Commits
ffad3485
Commit
ffad3485
authored
Apr 21, 2021
by
Kefas Satrio Bangkit Solidedantyo
Browse files
Merge branch 'fixing-choice-weights' into 'staging'
Fixing choice weights See merge request
!37
parents
5d213b71
261f676b
Pipeline
#71196
passed with stages
in 7 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dietela_quiz/formulas.py
View file @
ffad3485
...
...
@@ -125,9 +125,45 @@ def get_energy_needed_per_dine(breakfast_type, daily_energy_needs):
return
energy_dictionary
return
energy_dictionary
def
get_program_recommendation
(
current_condition
,
problem_to_solve
,
health_problem
):
score
=
current_condition
+
problem_to_solve
+
sum
(
health_problem
)
def
mapping_current_condition
(
item_18
):
current_condition
=
0
if
item_18
<=
2
:
current_condition
=
200
elif
item_18
==
3
:
current_condition
=
10
else
:
current_condition
=
30
return
current_condition
def
mapping_problem_to_solve
(
item_19
):
problem_to_solve
=
0
if
item_19
<=
3
:
problem_to_solve
=
55
elif
4
<=
item_19
<=
6
:
problem_to_solve
=
7
else
:
problem_to_solve
=
115
return
problem_to_solve
def
mapping_health_problem
(
item_20
):
health_problem
=
0
for
i
in
item_20
:
if
i
>=
11
:
health_problem
+=
10
elif
i
==
4
:
health_problem
+=
7
elif
i
==
1
:
health_problem
+=
5
else
:
health_problem
+=
30
return
health_problem
def
get_program_recommendation
(
item_18
,
item_19
,
item_20
):
current_condition
=
mapping_current_condition
(
item_18
)
problem_to_solve
=
mapping_problem_to_solve
(
item_19
)
health_problem
=
mapping_health_problem
(
item_20
)
score
=
current_condition
+
problem_to_solve
+
health_problem
programs_dictionary
=
{}
if
(
22
<=
score
<=
30
)
or
(
70
<=
score
<=
79
):
...
...
dietela_quiz/tests.py
View file @
ffad3485
...
...
@@ -441,15 +441,15 @@ class FormulaTest(TestCase):
self
.
assertEqual
(
energy_needed_error
,
{})
def
test_get_program_recommendation
(
self
):
client_type_1
=
get_program_recommendation
(
10
,
7
,
[
5
])
# Score 22-30
client_type_2
=
get_program_recommendation
(
30
,
7
,
[
30
])
# Score 31-69
client_type_3
=
get_program_recommendation
(
10
,
50
,
[
1
5
])
# Score 70-79
client_type_4
=
get_program_recommendation
(
3
0
,
55
,
[
5
])
# Score 80-99
client_type_5
=
get_program_recommendation
(
30
,
55
,
[
30
])
# Score 100-119
client_type_6
=
get_program_recommendation
(
3
0
,
115
,
[
5
])
# Score 120-150
client_type_7
=
get_program_recommendation
(
3
0
,
1
15
,
[
10
])
# Score 151-159
client_type_8
=
get_program_recommendation
(
30
,
1
15
,
[
30
])
# Score 160-179
client_type_9
=
get_program_recommendation
(
200
,
1
15
,
[
30
])
# Score 180-345
client_type_1
=
get_program_recommendation
(
3
,
6
,
[
1
])
# Score 22-30
client_type_2
=
get_program_recommendation
(
4
,
4
,
[
1
])
# Score 31-69
client_type_3
=
get_program_recommendation
(
3
,
1
,
[
1
])
# Score 70-79
client_type_4
=
get_program_recommendation
(
3
,
1
,
[
2
])
# Score 80-99
client_type_5
=
get_program_recommendation
(
7
,
1
,
[
8
])
# Score 100-119
client_type_6
=
get_program_recommendation
(
3
,
7
,
[
1
])
# Score 120-150
client_type_7
=
get_program_recommendation
(
3
,
1
0
,
[
3
])
# Score 151-159
client_type_8
=
get_program_recommendation
(
4
,
1
,
[
5
,
6
,
7
])
# Score 160-179
client_type_9
=
get_program_recommendation
(
1
,
1
,
[
1
])
# Score 180-345
self
.
assertEqual
(
client_type_1
.
get
(
'priority_1'
),
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment