1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
use serde::{self, Deserialize, Serialize};
/// Array of course ids
pub type r#ParamsCourseids = Vec<i64>;
#[derive(Serialize, Deserialize, Debug)]
pub struct Params {
/// Array of course ids
#[serde(rename = "courseids")]
pub r#courseids: Option<r#ParamsCourseids>,
}
/// File.
#[derive(Serialize, Deserialize, Debug)]
pub struct ReturnsQuizzesItemIntrofilesItem {
/// File name.
#[serde(rename = "filename")]
pub r#filename: Option<String>,
/// File path.
#[serde(rename = "filepath")]
pub r#filepath: Option<String>,
/// File size.
#[serde(rename = "filesize")]
pub r#filesize: Option<i64>,
/// Downloadable file url.
#[serde(rename = "fileurl")]
pub r#fileurl: Option<String>,
/// Time modified.
#[serde(rename = "timemodified")]
pub r#timemodified: Option<i64>,
/// File mime type.
#[serde(rename = "mimetype")]
pub r#mimetype: Option<String>,
/// Whether is an external file.
#[serde(rename = "isexternalfile")]
pub r#isexternalfile: Option<bool>,
/// The repository type for external files.
#[serde(rename = "repositorytype")]
pub r#repositorytype: Option<String>,
}
/// Files in the introduction
pub type r#ReturnsQuizzesItemIntrofiles = Vec<ReturnsQuizzesItemIntrofilesItem>;
#[derive(Serialize, Deserialize, Debug)]
pub struct ReturnsQuizzesItem {
/// Activity instance id
#[serde(rename = "id")]
pub r#id: Option<i64>,
/// Course module id
#[serde(rename = "coursemodule")]
pub r#coursemodule: Option<i64>,
/// Course id
#[serde(rename = "course")]
pub r#course: Option<i64>,
/// Activity name
#[serde(rename = "name")]
pub r#name: Option<String>,
/// Activity introduction
#[serde(rename = "intro")]
pub r#intro: Option<String>,
/// intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN
#[serde(rename = "introformat")]
pub r#introformat: Option<i64>,
/// Files in the introduction
#[serde(rename = "introfiles")]
pub r#introfiles: Option<r#ReturnsQuizzesItemIntrofiles>,
/// Course section id
#[serde(rename = "section")]
pub r#section: Option<i64>,
/// Visible
#[serde(rename = "visible")]
pub r#visible: Option<bool>,
/// Group mode
#[serde(rename = "groupmode")]
pub r#groupmode: Option<i64>,
/// Group id
#[serde(rename = "groupingid")]
pub r#groupingid: Option<i64>,
/// Forced activity language
#[serde(rename = "lang")]
pub r#lang: Option<String>,
/// The time when this quiz opens. (0 = no restriction.)
#[serde(rename = "timeopen")]
pub r#timeopen: Option<i64>,
/// The time when this quiz closes. (0 = no restriction.)
#[serde(rename = "timeclose")]
pub r#timeclose: Option<i64>,
/// The time limit for quiz attempts, in seconds.
#[serde(rename = "timelimit")]
pub r#timelimit: Option<i64>,
/// The method used to handle overdue attempts. 'autosubmit', 'graceperiod' or 'autoabandon'.
#[serde(rename = "overduehandling")]
pub r#overduehandling: Option<String>,
/// The amount of time (in seconds) after the time limit runs out during which attempts can still be submitted, if overduehandling is set to allow it.
#[serde(rename = "graceperiod")]
pub r#graceperiod: Option<i64>,
/// The behaviour to ask questions to use.
#[serde(rename = "preferredbehaviour")]
pub r#preferredbehaviour: Option<String>,
/// Allows students to redo any completed question within a quiz attempt.
#[serde(rename = "canredoquestions")]
pub r#canredoquestions: Option<i64>,
/// The maximum number of attempts a student is allowed.
#[serde(rename = "attempts")]
pub r#attempts: Option<i64>,
/// Whether subsequent attempts start from the answer to the previous attempt (1) or start blank (0).
#[serde(rename = "attemptonlast")]
pub r#attemptonlast: Option<i64>,
/// One of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
#[serde(rename = "grademethod")]
pub r#grademethod: Option<i64>,
/// Number of decimal points to use when displaying grades.
#[serde(rename = "decimalpoints")]
pub r#decimalpoints: Option<i64>,
/// Number of decimal points to use when displaying question grades. (-1 means use decimalpoints.)
#[serde(rename = "questiondecimalpoints")]
pub r#questiondecimalpoints: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. This is a bit field, decoded by the \mod_quiz\question\display_options class. It is formed by ORing together the constants defined there.
#[serde(rename = "reviewattempt")]
pub r#reviewattempt: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewcorrectness")]
pub r#reviewcorrectness: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewmarks")]
pub r#reviewmarks: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewspecificfeedback")]
pub r#reviewspecificfeedback: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewgeneralfeedback")]
pub r#reviewgeneralfeedback: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewrightanswer")]
pub r#reviewrightanswer: Option<i64>,
/// Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt.
#[serde(rename = "reviewoverallfeedback")]
pub r#reviewoverallfeedback: Option<i64>,
/// How often to insert a page break when editing the quiz, or when shuffling the question order.
#[serde(rename = "questionsperpage")]
pub r#questionsperpage: Option<i64>,
/// Any constraints on how the user is allowed to navigate around the quiz. Currently recognised values are 'free' and 'seq'.
#[serde(rename = "navmethod")]
pub r#navmethod: Option<String>,
/// Whether the parts of the question should be shuffled, in those question types that support it.
#[serde(rename = "shuffleanswers")]
pub r#shuffleanswers: Option<i64>,
/// The total of all the question instance maxmarks.
#[serde(rename = "sumgrades")]
pub r#sumgrades: Option<f64>,
/// The total that the quiz overall grade is scaled to be out of.
#[serde(rename = "grade")]
pub r#grade: Option<f64>,
/// The time when the quiz was added to the course.
#[serde(rename = "timecreated")]
pub r#timecreated: Option<i64>,
/// Last modified time.
#[serde(rename = "timemodified")]
pub r#timemodified: Option<i64>,
/// A password that the student must enter before starting or continuing a quiz attempt.
#[serde(rename = "password")]
pub r#password: Option<String>,
/// Used to restrict the IP addresses from which this quiz can be attempted. The format is as requried by the address_in_subnet function.
#[serde(rename = "subnet")]
pub r#subnet: Option<String>,
/// Restriciton on the browser the student must use. E.g. 'securewindow'.
#[serde(rename = "browsersecurity")]
pub r#browsersecurity: Option<String>,
/// Delay that must be left between the first and second attempt, in seconds.
#[serde(rename = "delay1")]
pub r#delay1: Option<i64>,
/// Delay that must be left between the second and subsequent attempt, in seconds.
#[serde(rename = "delay2")]
pub r#delay2: Option<i64>,
/// Option to show the user's picture during the attempt and on the review page.
#[serde(rename = "showuserpicture")]
pub r#showuserpicture: Option<i64>,
/// Whether blocks should be shown on the attempt.php and review.php pages.
#[serde(rename = "showblocks")]
pub r#showblocks: Option<i64>,
/// Mark quiz complete when the student has exhausted the maximum number of attempts
#[serde(rename = "completionattemptsexhausted")]
pub r#completionattemptsexhausted: Option<i64>,
/// Whether to require passing grade
#[serde(rename = "completionpass")]
pub r#completionpass: Option<i64>,
/// Whether to allow the quiz to be attempted offline in the mobile app
#[serde(rename = "allowofflineattempts")]
pub r#allowofflineattempts: Option<i64>,
/// Auto-save delay
#[serde(rename = "autosaveperiod")]
pub r#autosaveperiod: Option<i64>,
/// Whether the quiz has any non-blank feedback text
#[serde(rename = "hasfeedback")]
pub r#hasfeedback: Option<i64>,
/// Whether the quiz has questions
#[serde(rename = "hasquestions")]
pub r#hasquestions: Option<i64>,
}
pub type r#ReturnsQuizzes = Vec<ReturnsQuizzesItem>;
/// warning
#[derive(Serialize, Deserialize, Debug)]
pub struct ReturnsWarningsItem {
/// item
#[serde(rename = "item")]
pub r#item: Option<String>,
/// item id
#[serde(rename = "itemid")]
pub r#itemid: Option<i64>,
/// the warning code can be used by the client app to implement specific behaviour
#[serde(rename = "warningcode")]
pub r#warningcode: Option<String>,
/// untranslated english message to explain the warning
#[serde(rename = "message")]
pub r#message: Option<String>,
}
/// list of warnings
pub type r#ReturnsWarnings = Vec<ReturnsWarningsItem>;
#[derive(Serialize, Deserialize, Debug)]
pub struct Returns {
#[serde(rename = "quizzes")]
pub r#quizzes: Option<r#ReturnsQuizzes>,
/// list of warnings
#[serde(rename = "warnings")]
pub r#warnings: Option<r#ReturnsWarnings>,
}
pub async fn call<'a>(
client: &'a mut moodle_client::MoodleClient,
params: &'a mut Params,
) -> anyhow::Result<Returns> {
let json = client
.post("mod_quiz_get_quizzes_by_courses", params)
.await?;
serde_json::from_value(json).map_err(|e| e.into())
}
pub async fn call_raw<'a>(
client: &'a mut moodle_client::MoodleClient,
params: &'a mut Params,
) -> anyhow::Result<serde_json::Value> {
client.post("mod_quiz_get_quizzes_by_courses", params).await
}