Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/emulation/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ function current_language() {
function get_string($identifier, $component, $a = null) {
$userlanguage = current_language();

static $string = [];
switch ($userlanguage)
{
case 'de':
static $string = [];
if (empty($string)) {
// Load en values as defaults.
include(__DIR__ .'/../../lang/en/qtype_stack.php');
include(__DIR__ .'/../../lang/de/qtype_stack.php');
}
break;
default:
static $string = [];
if (empty($string)) {
include(__DIR__ .'/../../lang/en/qtype_stack.php');
}
Expand Down
61 changes: 60 additions & 1 deletion api/public/api.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,63 @@ a.nav-link:link, a.nav-link:visited, a.nav-link:hover, a.nav-link:active {
.sidebar {width: 100%; height: auto; position: relative; border-style: solid; border-width: 0px 0px 1px 0px; border-color: #e0dfdf}
.sidebar a {text-align: center; float: none;}
.main-content {margin-left: 0; padding: 0px;}
}
}
.container-footer {
width: 100%;
padding-right: 1rem;
padding-left: 1rem;
max-width: 97.75rem;
margin-right: auto;
margin-left: auto
}
@media (min-width: 768px) {
.container-footer {
padding-right:2rem;
padding-left: 2rem
}
}
.footer-discover {
background: #252525
}
.footer-discover-heading {
width: 100%;
padding-right: 1rem;
padding-left: 1rem;
max-width: 97.75rem;
margin-right: auto;
margin-left: auto;
font-size: calc(1.34375rem + .65625vw);
padding-top: 1.5rem;
padding-bottom: 1.3rem;
margin-bottom: 0;
font-family: "Crimson Text",serif;
font-weight: 400;
line-height: 1;
color: #b0b0b0;
text-transform: uppercase
}
@media (min-width: 768px) {
.footer-discover-heading {
padding-right:2rem;
padding-left: 2rem
}
}
@media (min-width: 1600px) {
.footer-discover-heading {
font-size:2rem
}
}
.footer {
padding: 1rem 0;
color: #d4d4d4;
background: linear-gradient(to bottom,#3a3a3a 0,#252525 100%) repeat scroll 0 0;
background-color: #3a3a3a;
}
footer a {
color: white;
text-decoration: none
}
footer a:hover {
--edgel-link-color-rgb: var(--edgel-link-hover-color-rgb);
text-decoration: underline
}
Binary file added api/public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion api/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
$app->post('/grade', GradingController::class);
$app->post('/validate', ValidationController::class);
$app->post('/download', DownloadController::class);

$app->redirect('/{page}', '/sample.php', 301);
$app->run();
24 changes: 15 additions & 9 deletions api/public/sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
require_once(__DIR__ . '/../../stack/questionlibrary.class.php');
// Required to pass Moodle code check. Uses emulation stub.
require_login();
// It's cleaner to just show the contents of the question library directory.
$files = stack_question_library::get_file_list('../../samplequestions/stackdemo/stacklibrary/*');
$files = stack_question_library::get_file_list('../../samplequestions/stackdemo/*');

$questions = [];
foreach ($files->children as $file) {
if (!$file->isdirectory) {
$question = new StdClass();
$questiondata = file_get_contents('../../samplequestions/stacklibrary/' . $file->path);
$questiondata = file_get_contents('../../samplequestions/' . $file->path);
$questionobject = simplexml_load_string($questiondata)->question;
$question->definition = $questiondata;
$question->name = (string) $questionobject->name->text;
Expand Down Expand Up @@ -142,6 +141,9 @@ function toggleAnswer(button) {
STACK is also available for direct integration in Moodle, ILIAS and through LTI.
For more information visit <a href="https://stack-assessment.org/">the STACK community page</a>.
</p>
<p>
There is also a <a href="/stack.php">library of STACK questions</a> on this demo site.
</p>
<hr>
</div>
<div>
Expand Down Expand Up @@ -181,17 +183,21 @@ function toggleAnswer(button) {
</div>
</div>
</div>
<div class="col-lg-9">
<hr />
<p style="font-size: 0.875em;color:gray;">
The STACK source code, including this API, is Licensed under the GNU General Public, License Version 3.
Documentation, sample questions and materials, are licensed under Creative Commons Attribution-ShareAlike 4.0 International.
See the <a href="https://docs.stack-assessment.org/en/About/License/">STACK licence</a> page for full details.
</p>
<? readfile(__DIR__ . '/stackfooter.html') ?>
</div>
</div>
</div>
<br>
</div>
</div>
<hr />
<p><span style="font-size: 0.875em;color:gray;">
The STACK source code, including this API, is Licensed under the GNU General Public, License Version 3.
Documentation, sample questions and materials, are licensed under Creative Commons Attribution-ShareAlike 4.0 International.
See the <a href="https://docs.stack-assessment.org/en/About/License/">STACK licence</a> page for full details.
</span></p>

</body>
<script type="text/javascript">
<?php
Expand Down
4 changes: 2 additions & 2 deletions api/public/stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function setQuestion(question) {
</div>
<?php echo stack_string('api_choose_q')?>:
<?php
$files = stack_question_library::get_file_list('../../samplequestions/*');
$files = stack_question_library::get_file_list('../../samplequestions/stacklibrary/*');
function render_directory($dirdetails) {
echo '<div style="margin-left: 30px;">';
foreach ($dirdetails as $file) {
Expand Down Expand Up @@ -193,7 +193,7 @@ function render_directory($dirdetails) {
</div>
</div>
<br>

<? readfile(__DIR__ . '/stackfooter.html') ?>
</body>
<script>
const yamlEditor = CodeMirror.fromTextArea(document.getElementById("xml"),
Expand Down
Empty file added api/public/stackfooter.html
Empty file.
5 changes: 4 additions & 1 deletion api/public/stackshared.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ function send() {
const inputs = json.questioninputs;
let correctAnswers = '';
// Show correct answers.
for (const [name, input] of Object.entries(inputs)) {
const placeholders = question.matchAll(/\[\[input:([a-zA-Z][a-zA-Z0-9_]*)\]\]/g);
for (const holder of placeholders) {
const name = holder[1];
const input = inputs[name];
question = question.replace(`[[input:${name}]]`, input.render);
question = question.replace(`[[validation:${name}]]`, `<span name='${validationPrefix + name}'></span>`);
if (input.samplesolutionrender && name !== 'remember') {
Expand Down
Loading