Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Machina Callida
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
callidus
Machina Callida
Commits
8bf2f3b2
Commit
8bf2f3b2
authored
May 18, 2020
by
Konstantin Schulz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
language is now set correctly when creating new exercises
parent
123ac1df
Pipeline
#11589
passed with stages
in 30 minutes and 8 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
27 deletions
+24
-27
mc_backend/mcserver/app/api/exerciseAPI.py
mc_backend/mcserver/app/api/exerciseAPI.py
+15
-17
mc_backend/mcserver/app/models.py
mc_backend/mcserver/app/models.py
+0
-3
mc_backend/tests.py
mc_backend/tests.py
+2
-1
mc_frontend/src/app/exercise-parameters/exercise-parameters.page.ts
...d/src/app/exercise-parameters/exercise-parameters.page.ts
+7
-6
No files found.
mc_backend/mcserver/app/api/exerciseAPI.py
View file @
8bf2f3b2
...
...
@@ -57,27 +57,24 @@ def get_graph_data(title: str, conll_string_or_urn: str, aqls: List[str], exerci
def
make_new_exercise
(
conll
:
str
,
correct_feedback
:
str
,
exercise_type
:
str
,
general_feedback
:
str
,
graph_data_raw
:
dict
,
incorrect_feedback
:
str
,
instructions
:
str
,
partially_correct_feedback
:
str
,
search_values
:
str
,
solutions
:
List
[
Solution
],
type_translation
:
str
,
urn
:
str
,
work_author
:
str
,
work_title
:
str
)
->
AnnisResponse
:
graph_data_raw
:
dict
,
incorrect_feedback
:
str
,
instructions
:
str
,
language
:
str
,
partially_correct_feedback
:
str
,
search_values
:
str
,
solutions
:
List
[
Solution
]
,
type_translation
:
str
,
urn
:
str
,
work_author
:
str
,
work_title
:
str
)
->
AnnisResponse
:
""" Creates a new exercise and makes it JSON serializable. """
# generate a GUID so we can offer the exercise XML as a file download
xml_guid
=
str
(
uuid
.
uuid4
())
# assemble the mapped exercise data
ed
:
ExerciseData
=
AnnotationService
.
map_graph_data_to_exercise
(
graph_data_raw
=
graph_data_raw
,
solutions
=
solutions
,
xml_guid
=
xml_guid
)
ed
:
ExerciseData
=
AnnotationService
.
map_graph_data_to_exercise
(
graph_data_raw
=
graph_data_raw
,
solutions
=
solutions
,
xml_guid
=
xml_guid
)
# for markWords exercises, add the maximum number of correct solutions to the description
instructions
+=
(
f
"(
{
len
(
solutions
)
}
)"
if
exercise_type
==
ExerciseType
.
markWords
.
value
else
""
)
# map the exercise data to our database data model
new_exercise
:
Exercise
=
map_exercise_data_to_database
(
solutions
=
solutions
,
exercise_data
=
ed
,
exercise_type
=
exercise_type
,
instructions
=
instructions
,
xml_guid
=
xml_guid
,
correct_feedback
=
correct_feedback
,
partially_correct_feedback
=
partially_correct_feedback
,
incorrect_feedback
=
incorrect_feedback
,
general_feedback
=
general_feedback
,
exercise_type_translation
=
type_translation
,
conll
=
conll
,
work_author
=
work_author
,
work_title
=
work_title
,
search_values
=
search_values
,
urn
=
urn
)
new_exercise
:
Exercise
=
map_exercise_data_to_database
(
solutions
=
solutions
,
exercise_data
=
ed
,
exercise_type
=
exercise_type
,
instructions
=
instructions
,
xml_guid
=
xml_guid
,
correct_feedback
=
correct_feedback
,
partially_correct_feedback
=
partially_correct_feedback
,
incorrect_feedback
=
incorrect_feedback
,
general_feedback
=
general_feedback
,
exercise_type_translation
=
type_translation
,
conll
=
conll
,
work_author
=
work_author
,
work_title
=
work_title
,
search_values
=
search_values
,
urn
=
urn
,
language
=
language
)
# create a response
return
AnnisResponse
(
solutions
=
json
.
loads
(
new_exercise
.
solutions
),
uri
=
f
"
{
Config
.
SERVER_URI_FILE
}
/
{
new_exercise
.
eid
}
"
,
...
...
@@ -87,7 +84,8 @@ def make_new_exercise(conll: str, correct_feedback: str, exercise_type: str, gen
def
map_exercise_data_to_database
(
exercise_data
:
ExerciseData
,
exercise_type
:
str
,
instructions
:
str
,
xml_guid
:
str
,
correct_feedback
:
str
,
partially_correct_feedback
:
str
,
incorrect_feedback
:
str
,
general_feedback
:
str
,
exercise_type_translation
:
str
,
search_values
:
str
,
solutions
:
List
[
Solution
],
conll
:
str
,
work_author
:
str
,
work_title
:
str
,
urn
:
str
):
solutions
:
List
[
Solution
],
conll
:
str
,
work_author
:
str
,
work_title
:
str
,
urn
:
str
,
language
:
str
):
"""Maps the exercise data so we can save it to the database."""
# sort the nodes according to the ordering links
AnnotationService
.
sort_nodes
(
graph_data
=
exercise_data
.
graph
)
...
...
@@ -100,7 +98,7 @@ def map_exercise_data_to_database(exercise_data: ExerciseData, exercise_type: st
new_exercise
:
Exercise
=
ExerciseMC
.
from_dict
(
conll
=
conll
,
correct_feedback
=
correct_feedback
,
eid
=
xml_guid
,
exercise_type
=
exercise_type
,
exercise_type_translation
=
exercise_type_translation
,
general_feedback
=
general_feedback
,
incorrect_feedback
=
incorrect_feedback
,
instructions
=
instructions
,
incorrect_feedback
=
incorrect_feedback
,
instructions
=
instructions
,
language
=
language
,
last_access_time
=
datetime
.
utcnow
().
timestamp
(),
partially_correct_feedback
=
partially_correct_feedback
,
search_values
=
search_values
,
solutions
=
quiz_solutions
,
text_complexity
=
tc
.
all
,
work_author
=
work_author
,
work_title
=
work_title
,
urn
=
urn
)
...
...
@@ -136,7 +134,7 @@ def post(exercise_data: dict) -> Union[Response, ConnexionResponse]:
conll
=
response
[
"conll"
],
correct_feedback
=
exercise_data
.
get
(
"correct_feedback"
,
""
),
exercise_type
=
exercise_data
[
"type"
],
general_feedback
=
exercise_data
.
get
(
"general_feedback"
,
""
),
graph_data_raw
=
response
[
"graph_data_raw"
],
incorrect_feedback
=
exercise_data
.
get
(
"incorrect_feedback"
,
""
),
instructions
=
exercise_data
[
"instructions"
],
instructions
=
exercise_data
[
"instructions"
],
language
=
exercise_data
.
get
(
"language"
,
"de"
),
partially_correct_feedback
=
exercise_data
.
get
(
"partially_correct_feedback"
,
""
),
search_values
=
exercise_data
[
"search_values"
],
solutions
=
solutions
,
type_translation
=
exercise_data
.
get
(
"type_translation"
,
""
),
urn
=
urn
,
...
...
mc_backend/mcserver/app/models.py
View file @
8bf2f3b2
"""Models for dealing with text data, both in the database and in the application itself."""
from
typing
import
Dict
,
List
,
Union
,
Any
from
enum
import
Enum
import
typing
from
sqlalchemy.orm.state
import
InstanceState
from
mcserver.app
import
db
from
mcserver.config
import
Config
from
mcserver.models_auto
import
TExercise
,
Corpus
,
TCorpus
,
Exercise
,
TLearningResult
,
LearningResult
...
...
mc_backend/tests.py
View file @
8bf2f3b2
...
...
@@ -543,7 +543,8 @@ class McTestCase(unittest.TestCase):
conll
=
exercise_expected
.
conll
,
correct_feedback
=
exercise_expected
.
correct_feedback
,
partially_correct_feedback
=
exercise_expected
.
partially_correct_feedback
,
urn
=
Mocks
.
urn_custom
,
incorrect_feedback
=
exercise_expected
.
incorrect_feedback
,
search_values
=
exercise_expected
.
search_values
,
general_feedback
=
exercise_expected
.
general_feedback
,
work_author
=
""
,
work_title
=
""
)
general_feedback
=
exercise_expected
.
general_feedback
,
work_author
=
exercise_expected
.
work_author
,
work_title
=
exercise_expected
.
work_title
,
language
=
exercise_expected
.
language
)
expected_values
:
List
[
str
]
=
[
exercise_expected
.
conll
,
exercise_expected
.
general_feedback
,
exercise_expected
.
incorrect_feedback
,
exercise_expected
.
search_values
,
exercise_expected
.
partially_correct_feedback
,
...
...
mc_frontend/src/app/exercise-parameters/exercise-parameters.page.ts
View file @
8bf2f3b2
...
...
@@ -108,15 +108,16 @@ export class ExerciseParametersPage implements OnInit {
this
.
corpusService
.
currentTextRange
.
pipe
(
take
(
1
)).
subscribe
((
tr
:
TextRange
)
=>
{
// TODO: change the corpus title to something meaningful, e.g. concatenate user ID and wanted exercise title
const
workTitle
:
string
=
cc
.
title
+
'
,
'
+
tr
.
start
.
filter
(
x
=>
x
).
join
(
'
.
'
)
+
'
-
'
+
tr
.
end
.
filter
(
x
=>
x
).
join
(
'
.
'
);
formData
.
append
(
'
work_title
'
,
workTitle
);
formData
.
append
(
'
type
'
,
MoodleExerciseType
[
this
.
corpusService
.
exercise
.
type
]);
formData
.
append
(
'
type_translation
'
,
this
.
corpusService
.
exercise
.
typeTranslation
);
formData
.
append
(
'
instructions
'
,
instructions
);
formData
.
append
(
'
correct_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
correct
);
formData
.
append
(
'
partially_correct_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
partiallyCorrect
);
formData
.
append
(
'
incorrect_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
incorrect
);
formData
.
append
(
'
instructions
'
,
instructions
);
formData
.
append
(
'
general_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
general
);
formData
.
append
(
'
incorrect_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
incorrect
);
formData
.
append
(
'
language
'
,
this
.
translateService
.
currentLang
);
formData
.
append
(
'
partially_correct_feedback
'
,
this
.
corpusService
.
exercise
.
feedback
.
partiallyCorrect
);
formData
.
append
(
'
type
'
,
MoodleExerciseType
[
this
.
corpusService
.
exercise
.
type
]);
formData
.
append
(
'
type_translation
'
,
this
.
corpusService
.
exercise
.
typeTranslation
);
formData
.
append
(
'
work_author
'
,
cc
.
author
);
formData
.
append
(
'
work_title
'
,
workTitle
);
this
.
getH5Pexercise
(
formData
).
then
(()
=>
{
return
resolve
();
});
...
...
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