Skip to content

Commit c4dc5a9

Browse files
Fix298 (#445) (#635)
* add idnumber export option * Fix up lang strings for export fields. Co-authored-by: root <[email protected]> cherry-pick form commit 566a116 Co-authored-by: Dan Marsden <[email protected]>
1 parent e401ba3 commit c4dc5a9

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

classes/responsetype/responsetype.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ protected function user_fields_sql() {
287287
$userfieldsarr = get_all_user_name_fields();
288288
}
289289
$userfieldsarr = array_merge($userfieldsarr, ['username', 'department', 'institution']);
290+
$userfieldsarr = array_merge($userfieldsarr, ['username', 'department', 'institution', 'idnumber']);
290291
$userfields = '';
291292
foreach ($userfieldsarr as $field) {
292293
$userfields .= $userfields === '' ? '' : ', ';

lang/en/questionnaire.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@
264264
$string['gradesdeleted'] = 'Questionnaire grades deleted';
265265
$string['headingtext'] = 'Heading text';
266266
$string['horizontal'] = 'Horizontal';
267-
$string['id'] = 'ID';
267+
$string['id'] = 'User id';
268+
$string['useridnumber'] = 'User idnumber';
268269
$string['includerankaverages'] = 'Include rank question averages';
269270
$string['includechoicecodes'] = 'Include choice codes';
270271
$string['includechoicetext'] = 'Include choice text';

questionnaire.class.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,7 @@ protected function user_fields() {
30163016
$userfieldsarr = get_all_user_name_fields();
30173017
}
30183018
$userfieldsarr = array_merge($userfieldsarr, ['username', 'department', 'institution']);
3019+
$userfieldsarr = array_merge($userfieldsarr, ['username', 'department', 'institution', 'idnumber']);
30193020
return $userfieldsarr;
30203021
}
30213022

@@ -3186,6 +3187,9 @@ protected function process_csv_row(array &$row,
31863187
if (in_array('id', $options)) {
31873188
array_push($positioned, $uid);
31883189
}
3190+
if (in_array('useridnumber', $options)) {
3191+
array_push($positioned, $user->idnumber);
3192+
}
31893193
if (in_array('fullname', $options)) {
31903194
array_push($positioned, $fullname);
31913195
}
@@ -3245,7 +3249,7 @@ public function generate_csv($currentgroupid, $rid='', $userid='', $choicecodes=
32453249
$columns = array();
32463250
$types = array();
32473251
foreach ($options as $option) {
3248-
if (in_array($option, array('response', 'submitted', 'id'))) {
3252+
if (in_array($option, array('response', 'submitted', 'id', 'useridnumber'))) {
32493253
$columns[] = get_string($option, 'questionnaire');
32503254
$types[] = 0;
32513255
} else if ($option == 'useridentityfields') {

settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'course' => get_string('course'),
4444
'group' => get_string('group'),
4545
'id' => get_string('id', 'questionnaire'),
46+
'useridnumber' => get_string('useridnumber', 'questionnaire'),
4647
'fullname' => get_string('fullname'),
4748
'username' => get_string('username'),
4849
'useridentityfields' => get_string('showuseridentity', 'admin')

tests/csvexport_test.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,21 @@ private function do_test_csvexport_identity_fields($course, $cm, $user, $roleid,
199199
* @return string[]
200200
*/
201201
private function expected_complete_output() {
202-
return ["Institution Department Course Group Full name Username Q01_Text Box 1000 Q02_Essay Box 1002 " .
202+
return ["Institution Department Course Group User idnumber Full name Username Q01_Text Box 1000 Q02_Essay Box 1002 " .
203203
"Q03_Numeric 1004 Q04_Date 1006 Q05_Radio Buttons 1008 Q06_Drop Down 1010 Q07_Check Boxes 1012->four " .
204204
"Q07_Check Boxes 1012->five Q07_Check Boxes 1012->six Q07_Check Boxes 1012->seven Q07_Check Boxes 1012->eight " .
205205
"Q07_Check Boxes 1012->nine Q07_Check Boxes 1012->ten Q07_Check Boxes 1012->eleven " .
206206
"Q07_Check Boxes 1012->twelve Q07_Check Boxes 1012->thirteen Q08_Rate Scale 1014->fourteen " .
207207
"Q08_Rate Scale 1014->fifteen Q08_Rate Scale 1014->sixteen Q08_Rate Scale 1014->seventeen " .
208208
"Q08_Rate Scale 1014->eighteen Q08_Rate Scale 1014->nineteen Q08_Rate Scale 1014->twenty " .
209209
"Q08_Rate Scale 1014->happy Q08_Rate Scale 1014->sad Q08_Rate Scale 1014->jealous Q09_Slider 1016",
210-
" Test course 1 Testy Lastname1 username1 Test answer Some header textSome paragraph text 83 " .
210+
" Test course 1 Testy Lastname1 username1 Test answer Some header textSome paragraph text 83 " .
211211
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
212-
" Test course 1 Testy Lastname2 username2 Test answer Some header textSome paragraph text 83 " .
212+
" Test course 1 Testy Lastname2 username2 Test answer Some header textSome paragraph text 83 " .
213213
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
214-
" Test course 1 Testy Lastname3 username3 Test answer Some header textSome paragraph text 83 " .
214+
" Test course 1 Testy Lastname3 username3 Test answer Some header textSome paragraph text 83 " .
215215
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
216-
" Test course 1 Testy Lastname4 username4 Test answer Some header textSome paragraph text 83 " .
216+
" Test course 1 Testy Lastname4 username4 Test answer Some header textSome paragraph text 83 " .
217217
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5"];
218218
}
219219

@@ -222,7 +222,7 @@ private function expected_complete_output() {
222222
* @return string[]
223223
*/
224224
private function expected_incomplete_output() {
225-
return ["Institution Department Course Group Full name Username Complete Q01_Text Box 1000 " .
225+
return ["Institution Department Course Group User idnumber Full name Username Complete Q01_Text Box 1000 " .
226226
"Q02_Essay Box 1002 " .
227227
"Q03_Numeric 1004 Q04_Date 1006 Q05_Radio Buttons 1008 Q06_Drop Down 1010 Q07_Check Boxes 1012->four " .
228228
"Q07_Check Boxes 1012->five Q07_Check Boxes 1012->six Q07_Check Boxes 1012->seven Q07_Check Boxes 1012->eight " .
@@ -231,15 +231,15 @@ private function expected_incomplete_output() {
231231
"Q08_Rate Scale 1014->fifteen Q08_Rate Scale 1014->sixteen Q08_Rate Scale 1014->seventeen " .
232232
"Q08_Rate Scale 1014->eighteen Q08_Rate Scale 1014->nineteen Q08_Rate Scale 1014->twenty " .
233233
"Q08_Rate Scale 1014->happy Q08_Rate Scale 1014->sad Q08_Rate Scale 1014->jealous Q09_Slider 1016",
234-
" Test course 1 Testy Lastname1 username1 y Test answer Some header textSome paragraph text 83 " .
234+
" Test course 1 Testy Lastname1 username1 y Test answer Some header textSome paragraph text 83 " .
235235
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
236-
" Test course 1 Testy Lastname2 username2 y Test answer Some header textSome paragraph text 83 " .
236+
" Test course 1 Testy Lastname2 username2 y Test answer Some header textSome paragraph text 83 " .
237237
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
238-
" Test course 1 Testy Lastname3 username3 y Test answer Some header textSome paragraph text 83 " .
238+
" Test course 1 Testy Lastname3 username3 y Test answer Some header textSome paragraph text 83 " .
239239
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
240-
" Test course 1 Testy Lastname4 username4 y Test answer Some header textSome paragraph text 83 " .
240+
" Test course 1 Testy Lastname4 username4 y Test answer Some header textSome paragraph text 83 " .
241241
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5",
242-
" Test course 1 Testy Lastname5 username5 n Test answer Some header textSome paragraph text 83 " .
242+
" Test course 1 Testy Lastname5 username5 n Test answer Some header textSome paragraph text 83 " .
243243
"27/12/2017 wind three 0 0 0 0 0 0 0 0 0 1 1 2 3 4 5 1 2 3 4 5"];
244244
}
245245
}

0 commit comments

Comments
 (0)