Skip to content

Commit

Permalink
Fix an issue with the graphtool default number line interval checker.
Browse files Browse the repository at this point in the history
The checker for intervals compares the interval graphed by the student
to the correct interval as MathObjects.  However, the context of the
graphtool is a modified `Point` context.  This generally is fine.  A
half open or half closed interval or an unbounded interval is still an
interval and the comparison works.  However, a bounded open interval or
a bounded closed interval both end up being points. As a result if the
correct answer is a bounded open interval and the student graphs an
interval with the same endpoints, but closed, the current checker counts
that as correct.

To fix this, this sets the '[' paren to always be an interval the same
as in the `Interval` context.  The graphtool answers given by javascript
will never need that to be anything else, so this works.

A minimal working example that demonstrates the issue is the following
problem:

```perl
DOCUMENT();
loadMacros(qw{PGstandard.pl PGML.pl parserGraphTool.pl});

$graph = GraphTool("{interval, (1, 5)}")->with(
    availableTools => [ 'IntervalTool', 'IncludeExcludePointTool' ],
    numberLine     => 1
);

BEGIN_PGML
Graph the interval [`(1, 5)`].

[_]{$graph}
END_PGML

ENDDOCUMENT();
```

For the develop or main branch if you graph the closed interval from 1
to 5, it is counted correct. Of course, with this pull request it is
incorrect.

Note that for all branches and this pull request the open interval from
1 to 5 is counted correct.  Of course a half open (or half closed)
interval from 1 to 5 and all other incorrect answers are counted
incorrect.

You can also experiment with other correct answers, and they all should
work with this pull request.
  • Loading branch information
drgrice1 committed Jan 26, 2025
1 parent aa205a1 commit 36a94ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions macros/graph/parserGraphTool.pl
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,12 @@ sub new {
my ($self, @options) = @_;
my $class = ref($self) || $self;
my $context = Parser::Context->getCopy('Point');
$context->parens->set('{' => { close => '}', type => 'List', formList => 1, formMatrix => 0, removable => 0 });
$context->parens->set(
'{' => { close => '}', type => 'List', formList => 1, formMatrix => 0, removable => 0 },
'[' => { type => 'Interval' }
);
$context->lists->set(
'GraphTool' => {
GraphTool => {
class => 'Parser::List::List',
open => '',
close => '',
Expand Down

0 comments on commit 36a94ff

Please sign in to comment.