You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,8 +64,9 @@ The `POST /render` route is used to render a given question. It expects a JSON d
64
64
-`questionDefinition`: The Moodle-XML-Export of a single STACK question. For all routes, the question does not need to be complete. The API will supply defaults
65
65
for all fields so minimum required XML is `<quiz><question type="stack"></question></quiz>`. A YAML representation of the differences between the question and the defaults
66
66
can also be used. (See [Diff Route](#diff-route).) Any non-empty YAML will do e.g. `name: YAML Question`.
67
-
-`seed`: Seed to choose a question variant. Must be contained in the list of deployed variants. If
67
+
-`seed`: Seed to choose a question variant. Must be contained in the list of deployed variants. If
68
68
no seed is provided, the first deployed variant is used.
69
+
-`lang`: Optional language code used for STACK `[[lang]]` blocks and translated strings. If omitted, the `Accept-Language` HTTP header is used as before.
69
70
-`renderInputs`: String. Response will include HTML renders of the inputs if value other than ''. The input divs will have the value added as a prefix to their name attribute.
70
71
-`fullRender`: Array consisting of a string prefix for validation divs and a string prefix for feedback divs e.g. `['validationprefix','feedbackprefix']` (`renderInputs` must also be set.) Response `questionrender` and `questionsamplesolutiontext` will be the full HTML render of the question with the inputs inserted in the correct place, full plot URLs, placeholders replaced with HTML and iframes included. Iframes will still need to be registered on the front
71
72
end to be displayed properly. (`stackjsvle.js->register_iframe()` using the first array entry for each iframe in the response as the iframeid.)
@@ -110,8 +111,9 @@ The following keys can be contained inside the input configuration options. The
110
111
The `POST /grade` route is used to score a given input for a question. The route expects a JSON document in the post body, which must contain the following fields:
111
112
112
113
-`questionDefinition`: The Moodle-XML-Export of a single STACK question.
113
-
-`seed`: Seed to choose a question variant. Must be contained in the list of deployed variants. If
114
+
-`seed`: Seed to choose a question variant. Must be contained in the list of deployed variants. If
114
115
no seed is provided, the first deployed variant is used.
116
+
-`lang`: Optional language code used for STACK `[[lang]]` blocks and translated strings. If omitted, the `Accept-Language` HTTP header is used.
115
117
-`answers`: A map from string to string, containing the answers.
116
118
117
119
For input rendered as single fields, one entry inside the `answers` map, with the input name as key is expected. More complex input types use multiple entries, with the input name as a prefix, e.g. matrix inputs.
@@ -134,6 +136,7 @@ The `POST /validate` route is used to get validation feedback for a single input
134
136
135
137
-`questionDefinition`: The Moodle-XML-Export of a single STACK question.
136
138
-`inputName`: The name of the input to be validated.
139
+
-`lang`: Optional language code used for STACK `[[lang]]` blocks and translated strings. If omitted, the `Accept-Language` HTTP header is used.
137
140
-`answers`. A map from string to string, containing the answers.
138
141
139
142
The validation route returns a string field `Validation` with the corresponding rendered output and an array of arrays `iframes` of arguments to create iframes to hold JS panels e.g. JSXGraph, GeoGebra.
@@ -155,8 +158,9 @@ The requested file is returned.
155
158
The `POST /test` route is used to run a question's test cases.
156
159
157
160
-`questionDefinition`: The Moodle-XML-Export of a single STACK question.
161
+
-`lang`: Optional language code used for STACK `[[lang]]` blocks and translated strings. If omitted, the `Accept-Language` HTTP header is used.
@@ -335,7 +339,7 @@ Any plots generated by stack during rendering or grading, as well as static imag
335
339
336
340
### Multi language content
337
341
338
-
The API currently supports outputting German and English localization, both for internal messages and as part of multi-language questions. To control which language is selected the `Accept-Language` HTTP header is parsed. If not present, the default language is English. Note, in order to add additional languages, you will need to
342
+
The API currently supports outputting German and English localization, both for internal messages and as part of multi-language questions. To control which language is selected for render, grade, validate, and test requests, include the `lang` property in the JSON request body. If not present, the `Accept-Language` HTTP header is parsed as before. If neither is present, the default language is English. Note, in order to add additional languages, you will need to
339
343
set `$CFG->supportedlanguages`. For development you will need to include the Moodle language pack directly inside the appropriate `/lang/??`. These will be downloaded
0 commit comments