Skip to content

Commit 43faa5c

Browse files
committed
nrw-external-api - Hide search if no API key config. Add more data to search result display.
1 parent d447b8a commit 43faa5c

5 files changed

Lines changed: 27 additions & 2 deletions

File tree

lang/en/qtype_stack.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,14 +1869,16 @@
18691869
$string['stack_library_import'] = 'Import';
18701870
$string['stack_library_importlist'] = 'Imported questions:';
18711871
$string['stack_library_import_folder'] = 'Import folder';
1872+
$string['stack_library_license'] = 'License';
18721873
$string['stack_library_quiz'] = 'This is a quiz:';
18731874
$string['stack_library_quiz_course'] = 'The quiz will be imported into course: ';
18741875
$string['stack_library_quiz_prefix'] = 'Quiz:';
18751876
$string['stack_library_refresh'] = 'Refresh library contents';
18761877
$string['stack_library_selected'] = 'Displayed question:';
18771878
$string['stack_library_select'] = 'Select library:';
1879+
$string['stack_library_source'] = 'Source';
18781880
$string['stack_library_nrw'] = 'Search NRW database';
1879-
$string['stack_library_apikey'] = 'using API key';
1881+
$string['stack_library_subject'] = 'Subject';
18801882
$string['stack_library_success'] = 'Successful import of:';
18811883
$string['stack_library_not_stack'] = 'This is not a STACK question and so cannot be fully rendered here but you can still import it.';
18821884
$string['stack_library_quiz_return'] = 'Return to quiz';

questionlibrary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
$outputdata->category = $mform->render();
188188
$outputdata->coursename = $coursename;
189189
$outputdata->courseid = $courseid;
190-
$outputdata->apikey = $apikey;
190+
$outputdata->isnrwapikey = (get_config('qtype_stack', 'nrwapikey')) ? true : false;
191191
$outputdata->search = $search;
192192
$outputdata->libraries = new StdClass();
193193
$outputdata->libraries->items = [];

stack/questionlibrary.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ public static function list_nrw_search(array $details) {
345345
foreach ($data['results'] as $item) {
346346
$files->children[] = (object)[
347347
'label' => $item['question']['data']['title'],
348+
'description' => $item['question']['data']['description'],
349+
'license' => $item['question']['data']['license'],
350+
'source' => $item['question']['data']['source'],
351+
'subject' => (is_array($item['question']['data']['subject'])) ?
352+
implode(', ', $item['question']['data']['subject']) : $item['question']['data']['subject'],
348353
'path' => $item['question']['id'],
349354
'isdirectory' => 0,
350355
'url' => '',

templates/questionfolder.mustache

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,21 @@
7272
<button class="btn btn-link library-file-link" type="button" data-filepath="{{path}}">
7373
{{#pix}} i/files, core {{/pix}}{{label}}
7474
</button>
75+
{{#subject}}
76+
<br>
77+
{{#str}} stack_library_subject, qtype_stack {{/str}}: {{subject}}
78+
{{/subject}}
79+
{{#source}}
80+
<br>
81+
{{#str}} stack_library_source, qtype_stack {{/str}}: {{source}}
82+
{{/source}}
83+
{{#license}}
84+
<br>
85+
{{#str}} stack_library_license, qtype_stack {{/str}}: {{license}}
86+
{{/license}}
87+
{{#description}}
88+
<br>
89+
{{description}}
90+
{{/description}}
7591
{{/isdirectory}}
7692
</div>

templates/questionlibrary.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
</span>
117117
</p>
118118
{{/libraries.hasitems}}
119+
{{#isnrwapikey}}
119120
<form name='stack_lib_search' id='stack_lib_search' method='post' action='{{{searchurl}}}'>
120121
<div class="mb-1" style="display:flex; flex-direction:row;">
121122
<label for="stack_library_search">{{#str}} stack_library_nrw, qtype_stack {{/str}}: </label>&nbsp;
@@ -124,6 +125,7 @@
124125
</div>
125126
</form>
126127
<br>
128+
{{/isnrwapikey}}
127129
<div class="alert alert-secondary" style="position: relative; color: black;">
128130
<div class="stack-library-category-holder">
129131
{{#str}} stack_library_destination, qtype_stack {{/str}}

0 commit comments

Comments
 (0)