Skip to content

Commit

Permalink
First draft fix to issue maths#1231, add tags to [[todo]] blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangwinc committed Aug 19, 2024
1 parent 2ae3aa1 commit 0f344c0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions adminui/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
['link' => (string) new moodle_url('/question/type/stack/adminui/caschat.php')]),
get_string('bulktestindexintro_desc', 'qtype_stack',
['link' => (string) new moodle_url('/question/type/stack/adminui/bulktestindex.php')]),
get_string('todo_desc', 'qtype_stack',
['link' => (string) new moodle_url('/question/type/stack/adminui/todo.php')]),
get_string('dependenciesintro_desc', 'qtype_stack',
['link' => (string) new moodle_url('/question/type/stack/adminui/dependencies.php')]),
get_string('stackInstall_replace_dollars_desc', 'qtype_stack',
Expand Down
3 changes: 2 additions & 1 deletion adminui/todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
require_once(__DIR__ . '/../stack/bulktester.class.php');

// Get the parameters from the URL.
$contextid = required_param('contextid', PARAM_INT);
$context = context_system::instance();
$contextid = optional_param('contextid', $context->__get('id'), PARAM_INT);
$context = context::instance_by_id($contextid);

// Login and check permissions.
Expand Down
16 changes: 10 additions & 6 deletions doc/en/Authoring/Question_blocks/Static_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ Read more about this in the [languages](../Languages.md) documentation.

## Comment blocks ##

Comment blocks allow you to put content into CASText which will not be seen by students.
Comment blocks allow you to put content into a CASText field which will not be seen by students.

[[ comment ]] Place comments here which will not appear to students. [[/ comment ]]
[[comment]] Place comments here which will not appear to students. [[/comment]]

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" blocks allow you to put items into a main question CASText field (not feedback in the PRTs) 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 ]]
[[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. These blocks can also be found by the dependency checker.
Any question with a todo will flag an error in the bulk tester. This will _not_ throw an error in the editing form.

You can access a page listing all questions with `[[todo]]` blocks which you can edit, in every course on which you are a teacher, by accessing the STACK question dashboard, or from the page `question/type/stack/adminui/index.php` on your local server.

The todo block is similar to the comments block. A different block is provided to facilitate searching for questions with specific "todo" items remaining. The contents must be valid castext (unlike the comments block which can be anything) because in the future we may extend the functionality to display todo items in a teacher preview. If you need to include invalid content either use the comment block, or escape block inside the todo, e.g.

Expand All @@ -34,7 +36,9 @@ The contents of this block are replaced by the static

<!--- stack_todo --->

to provide a searchable tag in instantiated text which is not visible in regular html, e.g. in the dependency checker.
to stop these being read by a user (student), and to provide a searchable tag in instantiated text which is not visible in regular html.

The `[[todo]]` can contain optional `tags` which are described in the [workflow](../Workflow.md) documentation.

## The debug block ##

Expand Down
2 changes: 1 addition & 1 deletion doc/en/Authoring/Workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ By design, "todo" tags are _not_ tied to userid fields in the moodle site. Inst

Any logged-in user can navigate to the URL

../moodle/question/type/stack/adminui/stack-todo.php
../moodle/question/type/stack/adminui/todo.php

on the moodle site. This page will list

Expand Down
1 change: 1 addition & 0 deletions doc/en/Developer/Development_track.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ We use the [github issue tracker](https://github.com/maths/moodle-qtype_stack/is
DONE.

1. Add in the ability to insert stars for "unknown functions" in inputs. E.g. `x(t+1)` becomes `x*(t+1)`. This only affects "unknown" functions, not core functions such as `sin(x)`.
2. Add in tags to the `[[todo]]` blocks to help with multi-authoring [workflow](../Authoring/Workflow.md).

Issues with [github milestone 4.8.0](https://github.com/maths/moodle-qtype_stack/issues?q=is%3Aissue+milestone%3A4.8.0) include

Expand Down
9 changes: 7 additions & 2 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,14 @@ public function get_question_todos() {
$tags = [];
$fields = [$this->questiontext, $this->questionnote, $this->generalfeedback,
$this->specificfeedback, $this->questiondescription];
$pat = '/\[\[todo/';
foreach ($fields as $field) {
$hastodos = $hastodos || castext2_parser_utils::has_todoblocks($field);
$tags = array_merge($tags, castext2_parser_utils::get_todoblocks($field));
// We _should_ use castext2_parser_utils::has_todoblocks($field) really, but this
// involves parsing the castext which is too slow.
if (preg_match($pat, $field ?? '')) {
$hastodos = true;
$tags = array_merge($tags, castext2_parser_utils::get_todoblocks($field));
}
}
// Unique tags, sorted.
$tags = array_unique($tags);
Expand Down

0 comments on commit 0f344c0

Please sign in to comment.