Skip to content

Fixing Common Errors

Steven Clontz edited this page Jul 25, 2025 · 2 revisions

error: * PTX:BUG: Exercise component mis-labeled

This usually means that you have placed an <answer> within a <statement>. Unfortunately, this error doesn't tell you where the problem occurs, so it can be hard to find. You can use the following command in the terminal to list all of the places where <answer>s are neither a child of an <activity> or of a <task>:

xpath -e '//answer[not(parent::activity or parent::task)]' source/*/source/*/*.ptx

or

for filename in source/*/source/*/*.ptx; do
    echo $filename
    python -c "from lxml import etree ; from sys import stdin; print('\n'.join([etree.tostring(e).decode('utf-8') for e in etree.parse(stdin).xpath('//answer[not(parent::activity or parent::task)]')]))" < $filename
    echo
done

Clone this wiki locally