Skip to content

Commit 2865e6f

Browse files
authored
Merge pull request #1457 from maths/api-wording
API wording
2 parents ac194f2 + ea17699 commit 2865e6f

8 files changed

Lines changed: 83 additions & 16 deletions

File tree

api/emulation/Localization.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,17 @@ function current_language() {
3636
function get_string($identifier, $component, $a = null) {
3737
$userlanguage = current_language();
3838

39+
static $string = [];
3940
switch ($userlanguage)
4041
{
4142
case 'de':
42-
static $string = [];
4343
if (empty($string)) {
4444
// Load en values as defaults.
4545
include(__DIR__ .'/../../lang/en/qtype_stack.php');
4646
include(__DIR__ .'/../../lang/de/qtype_stack.php');
4747
}
4848
break;
4949
default:
50-
static $string = [];
5150
if (empty($string)) {
5251
include(__DIR__ .'/../../lang/en/qtype_stack.php');
5352
}

api/public/api.css

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,63 @@ a.nav-link:link, a.nav-link:visited, a.nav-link:hover, a.nav-link:active {
5656
.sidebar {width: 100%; height: auto; position: relative; border-style: solid; border-width: 0px 0px 1px 0px; border-color: #e0dfdf}
5757
.sidebar a {text-align: center; float: none;}
5858
.main-content {margin-left: 0; padding: 0px;}
59-
}
59+
}
60+
.container-footer {
61+
width: 100%;
62+
padding-right: 1rem;
63+
padding-left: 1rem;
64+
max-width: 97.75rem;
65+
margin-right: auto;
66+
margin-left: auto
67+
}
68+
@media (min-width: 768px) {
69+
.container-footer {
70+
padding-right:2rem;
71+
padding-left: 2rem
72+
}
73+
}
74+
.footer-discover {
75+
background: #252525
76+
}
77+
.footer-discover-heading {
78+
width: 100%;
79+
padding-right: 1rem;
80+
padding-left: 1rem;
81+
max-width: 97.75rem;
82+
margin-right: auto;
83+
margin-left: auto;
84+
font-size: calc(1.34375rem + .65625vw);
85+
padding-top: 1.5rem;
86+
padding-bottom: 1.3rem;
87+
margin-bottom: 0;
88+
font-family: "Crimson Text",serif;
89+
font-weight: 400;
90+
line-height: 1;
91+
color: #b0b0b0;
92+
text-transform: uppercase
93+
}
94+
@media (min-width: 768px) {
95+
.footer-discover-heading {
96+
padding-right:2rem;
97+
padding-left: 2rem
98+
}
99+
}
100+
@media (min-width: 1600px) {
101+
.footer-discover-heading {
102+
font-size:2rem
103+
}
104+
}
105+
.footer {
106+
padding: 1rem 0;
107+
color: #d4d4d4;
108+
background: linear-gradient(to bottom,#3a3a3a 0,#252525 100%) repeat scroll 0 0;
109+
background-color: #3a3a3a;
110+
}
111+
footer a {
112+
color: white;
113+
text-decoration: none
114+
}
115+
footer a:hover {
116+
--edgel-link-color-rgb: var(--edgel-link-hover-color-rgb);
117+
text-decoration: underline
118+
}

api/public/favicon.ico

101 KB
Binary file not shown.

api/public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
$app->post('/grade', GradingController::class);
5252
$app->post('/validate', ValidationController::class);
5353
$app->post('/download', DownloadController::class);
54-
54+
$app->redirect('/{page}', '/sample.php', 301);
5555
$app->run();

api/public/sample.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
require_once(__DIR__ . '/../../stack/questionlibrary.class.php');
2828
// Required to pass Moodle code check. Uses emulation stub.
2929
require_login();
30-
// It's cleaner to just show the contents of the question library directory.
31-
$files = stack_question_library::get_file_list('../../samplequestions/stackdemo/stacklibrary/*');
30+
$files = stack_question_library::get_file_list('../../samplequestions/stackdemo/*');
3231

3332
$questions = [];
3433
foreach ($files->children as $file) {
3534
if (!$file->isdirectory) {
3635
$question = new StdClass();
37-
$questiondata = file_get_contents('../../samplequestions/stacklibrary/' . $file->path);
36+
$questiondata = file_get_contents('../../samplequestions/' . $file->path);
3837
$questionobject = simplexml_load_string($questiondata)->question;
3938
$question->definition = $questiondata;
4039
$question->name = (string) $questionobject->name->text;
@@ -142,6 +141,9 @@ function toggleAnswer(button) {
142141
STACK is also available for direct integration in Moodle, ILIAS and through LTI.
143142
For more information visit <a href="https://stack-assessment.org/">the STACK community page</a>.
144143
</p>
144+
<p>
145+
There is also a <a href="/stack.php">library of STACK questions</a> on this demo site.
146+
</p>
145147
<hr>
146148
</div>
147149
<div>
@@ -181,17 +183,21 @@ function toggleAnswer(button) {
181183
</div>
182184
</div>
183185
</div>
186+
<div class="col-lg-9">
187+
<hr />
188+
<p style="font-size: 0.875em;color:gray;">
189+
The STACK source code, including this API, is Licensed under the GNU General Public, License Version 3.
190+
Documentation, sample questions and materials, are licensed under Creative Commons Attribution-ShareAlike 4.0 International.
191+
See the <a href="https://docs.stack-assessment.org/en/About/License/">STACK licence</a> page for full details.
192+
</p>
193+
<? readfile(__DIR__ . '/stackfooter.html') ?>
194+
</div>
184195
</div>
185196
</div>
186197
<br>
187198
</div>
188199
</div>
189-
<hr />
190-
<p><span style="font-size: 0.875em;color:gray;">
191-
The STACK source code, including this API, is Licensed under the GNU General Public, License Version 3.
192-
Documentation, sample questions and materials, are licensed under Creative Commons Attribution-ShareAlike 4.0 International.
193-
See the <a href="https://docs.stack-assessment.org/en/About/License/">STACK licence</a> page for full details.
194-
</span></p>
200+
195201
</body>
196202
<script type="text/javascript">
197203
<?php

api/public/stack.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function setQuestion(question) {
133133
</div>
134134
<?php echo stack_string('api_choose_q')?>:
135135
<?php
136-
$files = stack_question_library::get_file_list('../../samplequestions/*');
136+
$files = stack_question_library::get_file_list('../../samplequestions/stacklibrary/*');
137137
function render_directory($dirdetails) {
138138
echo '<div style="margin-left: 30px;">';
139139
foreach ($dirdetails as $file) {
@@ -193,7 +193,7 @@ function render_directory($dirdetails) {
193193
</div>
194194
</div>
195195
<br>
196-
196+
<? readfile(__DIR__ . '/stackfooter.html') ?>
197197
</body>
198198
<script>
199199
const yamlEditor = CodeMirror.fromTextArea(document.getElementById("xml"),

api/public/stackfooter.html

Whitespace-only changes.

api/public/stackshared.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ function send() {
9292
const inputs = json.questioninputs;
9393
let correctAnswers = '';
9494
// Show correct answers.
95-
for (const [name, input] of Object.entries(inputs)) {
95+
const placeholders = question.matchAll(/\[\[input:([a-zA-Z][a-zA-Z0-9_]*)\]\]/g);
96+
for (const holder of placeholders) {
97+
const name = holder[1];
98+
const input = inputs[name];
9699
question = question.replace(`[[input:${name}]]`, input.render);
97100
question = question.replace(`[[validation:${name}]]`, `<span name='${validationPrefix + name}'></span>`);
98101
if (input.samplesolutionrender && name !== 'remember') {

0 commit comments

Comments
 (0)