DOCUMENT();
loadMacros(
    'PGstandard.pl',        'PGML.pl',
    'parserVectorUtils.pl', 'parserMultiAnswer.pl',
    'PGcourse.pl'
);

Context('Vector2D');
# Context('Vector'); # use for 3D vectors
Context()->variables->are(t => 'Real');

$a = random(2, 5);

Context()->variables->set(t => { limits => [ 0, $a ] });

$Q = Point($a, $a**2);

$multians = MultiAnswer(Vector("<t,t**2>"), 0, $a)->with(
    singleResult => 1,

    checker => sub {
        my ($correct, $student, $self) = @_;           # get the parameters
        my ($f,       $x1,      $x2)   = @$student;    # extract student answers

        if (($f . i)**2 == $f . j
            && $f->eval(t => $x1) == Vector("<0,0>")
            && $f->eval(t => $x2) == Vector("<$a,$a**2>"))
        {
            return 1;
        } elsif (($f . i)**2 == $f . j
            && $f->eval(t => $x1) == Vector("<0,0>"))
        {
            $self->setMessage(3, 'Your right endpoint is not correct.');
            return 0;
        } elsif (($f . i)**2 == $f . j
            && $f->eval(t => $x2) == Vector("<$a,$a**2>"))
        {
            $self->setMessage(2, 'Your left endpoint is not correct.');
            return 0;
        } elsif (($f . i)**2 == $f . j) {
            $self->setMessage(2, 'Your left endpoint is not correct.');
            $self->setMessage(3, 'Your right endpoint is not correct.');
            return 0;
        } else {
            return 0;
        }
    }
);

BEGIN_PGML
Find a vector parametric equation for the parabola [`y = x^2`] from the origin
to the point [`[$Q]`] using [`t`] as a parameter.

[`\vec{r}(t) =`] [_]{$multians}{10}
for [___]{$multians} [`\leq t \leq`] [___]{$multians}.
END_PGML

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();