Skip to content
Snippets Groups Projects
Commit a605ec3d authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Add in the "todo" block.

parent 3cf10dd8
Branches
No related tags found
No related merge requests found
...@@ -106,6 +106,7 @@ echo $OUTPUT->single_button( ...@@ -106,6 +106,7 @@ echo $OUTPUT->single_button(
echo $OUTPUT->single_button( echo $OUTPUT->single_button(
new moodle_url($PAGE->url, array('langs' => 1, 'sesskey' => sesskey())), new moodle_url($PAGE->url, array('langs' => 1, 'sesskey' => sesskey())),
'Find "langs"'); 'Find "langs"');
// Note, we can't easily add checks for "todo" here because these blocks have been stripped out of the cache.
if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) { if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) {
/* /*
...@@ -262,7 +263,7 @@ if (data_submitted() && optional_param('langs', false, PARAM_BOOL)) { ...@@ -262,7 +263,7 @@ if (data_submitted() && optional_param('langs', false, PARAM_BOOL)) {
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' . $qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND ' . $DB->sql_like('o.compiledcache', ':trg') . ' AND NOT ' . 'q.id = o.questionid AND ' . $DB->sql_like('o.compiledcache', ':trg') . ' AND NOT ' .
$DB->sql_like('o.compiledcache', ':other') . ';', ['trg' => '%"langs":[%', 'other' => '%"langs":[]%']); $DB->sql_like('o.compiledcache', ':other') . ';', ['trg' => '%"langs":[%', 'other' => '%"langs":[]%']);
echo '<h4>Questions containing that have localisation using means we understand.</h4>'; echo '<h4>Questions containing localisation using means we understand.</h4>';
echo '<table><thead><tr><th>Question</th><th>Langs</th></thead><tbody>'; echo '<table><thead><tr><th>Question</th><th>Langs</th></thead><tbody>';
// Load the whole question, simpler to get the contexts correct that way. // Load the whole question, simpler to get the contexts correct that way.
foreach ($qs as $item) { foreach ($qs as $item) {
......
...@@ -18,6 +18,16 @@ Comment blocks allow you to put content into CASText which will not be seen by s ...@@ -18,6 +18,16 @@ Comment blocks allow you to put content into CASText which will not be seen by s
Before 4.4 the contents of the block needed to be syntactically correct CASText. That is no longer the case and you can much more easily use this block to comment our unfinished stuff. Before 4.4 the contents of the block needed to be syntactically correct CASText. That is no longer the case and you can much more easily use this block to comment our unfinished stuff.
## Todo blocks ##
"todo" blocks allow you to put items into CASText which indicate future work needed. This will not be seen by students.
[[ todo ]] Place requests to collaborators here. This will not appear to students. [[/ todo ]]
Any question with a todo will flag an error in the bulk tester. This will _not_ throw an error in the editing form.
The todo block is functionally identical to the comments block. A different block is provided to facilitate searching for questions with specific "todo" items remaining. In the future, the functionality may change (e.g. displaying todo items in a teacher preview).
## The debug block ## ## The debug block ##
The special "debug" block allows question authors to see all the values of variables created during a session in a table. Do not leave this block in a live question! The special "debug" block allows question authors to see all the values of variables created during a session in a table. Do not leave this block in a live question!
......
# Development track for STACK # Development track for STACK
Requests for features and ideas for developing STACK are all recorded in [Future plans](Future_plans.md). The Requests for features and ideas for developing STACK are all recorded in [Future plans](Future_plans.md). The
...@@ -10,6 +11,7 @@ DONE ...@@ -10,6 +11,7 @@ DONE
1. Add in the `s_assert` function to allow teachers to unit-test individual question variable values. 1. Add in the `s_assert` function to allow teachers to unit-test individual question variable values.
2. Add in the `hint` [question block](../Authoring/Question_blocks/Dynamic_blocks.md). Fixes issue #968, thanks to Michael Kallweit. 2. Add in the `hint` [question block](../Authoring/Question_blocks/Dynamic_blocks.md). Fixes issue #968, thanks to Michael Kallweit.
3. Add in the `stack_include_contrib()` for easier inclusion of libraries. 3. Add in the `stack_include_contrib()` for easier inclusion of libraries.
4. Add in the `[[todo]]` [question block](../Authoring/Question_blocks/Static_blocks.md).
TODO: List of long lasting issues dealt with, that might need to be notified/closed, note that some of these have connecting issues: TODO: List of long lasting issues dealt with, that might need to be notified/closed, note that some of these have connecting issues:
#671, #420 #671, #420
......
...@@ -411,6 +411,7 @@ $string['languageproblemsmissing'] = 'The language tag {$a->lang} is missing fro ...@@ -411,6 +411,7 @@ $string['languageproblemsmissing'] = 'The language tag {$a->lang} is missing fro
$string['languageproblemsextra'] = 'The field {$a->field} has the following languages not in the question text: {$a->langs}.'; $string['languageproblemsextra'] = 'The field {$a->field} has the following languages not in the question text: {$a->langs}.';
$string['alttextmissing'] = 'One or more images appears to have a missing or empty \'alt\' tag in "{$a->field}" ({$a->num}).'; $string['alttextmissing'] = 'One or more images appears to have a missing or empty \'alt\' tag in "{$a->field}" ({$a->num}).';
$string['todowarning'] = 'You have un-resolved todo blocks in "{$a->field}".';
// Admin settings. // Admin settings.
$string['settingajaxvalidation'] = 'Instant validation'; $string['settingajaxvalidation'] = 'Instant validation';
......
...@@ -1555,7 +1555,6 @@ class qtype_stack_question extends question_graded_automatically_with_countback ...@@ -1555,7 +1555,6 @@ class qtype_stack_question extends question_graded_automatically_with_countback
// 2. Check alt-text exists. // 2. Check alt-text exists.
// Reminder: previous approach in Oct 2021 tried to use libxml_use_internal_errors, but this was a dead end. // Reminder: previous approach in Oct 2021 tried to use libxml_use_internal_errors, but this was a dead end.
$tocheck = array(); $tocheck = array();
$text = ''; $text = '';
if ($this->questiontextinstantiated !== null) { if ($this->questiontextinstantiated !== null) {
...@@ -1587,7 +1586,26 @@ class qtype_stack_question extends question_graded_automatically_with_countback ...@@ -1587,7 +1586,26 @@ class qtype_stack_question extends question_graded_automatically_with_countback
} }
} }
// 3. Language warning checks. // 3. Check for todo blocks.
$tocheck = array();
$fields = array('questiontext', 'specificfeedback', 'generalfeedback', 'questiondescription');
foreach ($fields as $field) {
$tocheck[stack_string($field)] = $this->$field;
}
foreach ($this->prts as $prt) {
$text = trim($prt->get_feedback_test());
if ($text !== '') {
$tocheck[$prt->get_name()] = $text;
}
}
$pat = '/\[\[todo/';
foreach ($tocheck as $field => $text) {
if (preg_match($pat, $text)) {
$warnings[] = stack_string_error('todowarning', array('field' => $field));
}
}
// 4. Language warning checks.
// Put language warning checks last (see guard clause below). // Put language warning checks last (see guard clause below).
// Check multi-language versions all have the same languages. // Check multi-language versions all have the same languages.
$ml = new stack_multilang(); $ml = new stack_multilang();
......
<?php
// This file is part of Stateful
//
// Stateful is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Stateful is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Stateful. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../block.interface.php');
class stack_cas_castext2_todo extends stack_cas_castext2_block {
public function compile($format, $options): ?MP_Node {
// Todo items do not get anywhere ever.
return null;
}
public function is_flat(): bool {
return true;
}
public function validate_extract_attributes(): array {
return array();
}
}
...@@ -474,6 +474,19 @@ class castext2_test extends qtype_stack_testcase { ...@@ -474,6 +474,19 @@ class castext2_test extends qtype_stack_testcase {
$this->assertEquals($output, $this->evaluate($input)); $this->assertEquals($output, $this->evaluate($input));
} }
/**
* Block-system "todo"-block, functional requirements:
* 1. Comments out itself and contents.
* 2. Even if contents are invalid or incomplete.
*
* @covers \qtype_stack\stack_cas_castext2_comment
*/
public function test_blocks_todo() {
$input = '1[[ todo]] [[ foreach bar="foo"]] {#y@} [[/todo]]2';
$output = '12';
$this->assertEquals($output, $this->evaluate($input));
}
/** /**
* Block-system "escape"-block, functional requirements: * Block-system "escape"-block, functional requirements:
* 1. Escapes the contents so that they will not be processed. * 1. Escapes the contents so that they will not be processed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment