Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Works on my machine
zesje
Commits
3fd50079
Commit
3fd50079
authored
5 years ago
by
Ruben Young On
Browse files
Options
Downloads
Patches
Plain Diff
Inserting a checkbox now also adds a feedback option
parent
ab3c2799
No related branches found
Branches containing commit
No related tags found
1 merge request
!12
Fix relation between MultipleChoiceOption and FeedbackOption
Pipeline
#17679
passed
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zesje/api/mult_choice.py
+11
-6
11 additions, 6 deletions
zesje/api/mult_choice.py
with
11 additions
and
6 deletions
zesje/api/mult_choice.py
+
11
−
6
View file @
3fd50079
from
flask_restful
import
Resource
,
reqparse
from
..database
import
db
,
MultipleChoiceOption
from
..database
import
db
,
MultipleChoiceOption
,
FeedbackOption
def
set_mc_data
(
mc_entry
,
name
,
x
,
y
,
mc_type
,
problem_id
,
feedback_id
,
label
):
...
...
@@ -61,6 +61,11 @@ class MultipleChoice(Resource):
mc_type
=
'
mcq_widget
'
if
not
id
:
# Insert new feedback option
new_feedback_option
=
FeedbackOption
(
problem_id
=
problem_id
,
text
=
''
)
db
.
session
.
add
(
new_feedback_option
)
db
.
session
.
commit
()
# Insert new entry into the database
mc_entry
=
MultipleChoiceOption
()
set_mc_data
(
mc_entry
,
name
,
x
,
y
,
mc_type
,
problem_id
,
feedback_id
,
label
)
...
...
@@ -68,7 +73,9 @@ class MultipleChoice(Resource):
db
.
session
.
add
(
mc_entry
)
db
.
session
.
commit
()
return
dict
(
status
=
200
,
message
=
f
'
New multiple choice question with id
{
mc_entry
.
id
}
inserted
'
),
200
return
dict
(
status
=
200
,
mult_choice_id
=
mc_entry
.
id
,
feedback_id
=
new_feedback_option
.
id
,
message
=
f
'
New multiple choice question with id
{
mc_entry
.
id
}
inserted.
'
+
f
'
New feedback option with id
{
new_feedback_option
.
id
}
inserted.
'
),
200
# Update existing entry otherwise
mc_entry
=
MultipleChoiceOption
.
query
.
get
(
id
)
...
...
@@ -103,14 +110,12 @@ class MultipleChoice(Resource):
'
x
'
:
mult_choice
.
x
,
'
y
'
:
mult_choice
.
y
,
'
type
'
:
mult_choice
.
type
,
'
problem_id
'
:
mult_choice
.
problem_id
'
problem_id
'
:
mult_choice
.
problem_id
,
'
feedback_id
'
:
mult_choice
.
feedback_id
}
# Nullable database fields
if
mult_choice
.
label
:
json
[
'
label
'
]
=
mult_choice
.
label
if
mult_choice
.
feedback_id
:
json
[
'
feedback_id
'
]
=
mult_choice
.
feedback_id
return
json
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