DOCUMENT();

loadMacros(
    'PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'parserPopUp.pl',
    'PGcourse.pl'
);

@all_plots = (
    {
        f      => 'x^2',
        form   => '\x*\x',
        domain => '-3:3',
        alt    =>
            'A graph of a curve with a minimum at the origin and opening '
            . 'upward.'
    },
    {
        f      => 'e^x',
        form   => 'exp(\x)',
        domain => '-6:3',
        alt    => 'A graph of a curve starting near the negative x axis and '
            . 'rising steeply toward the first quadrant.'
    },
    {
        f      => 'x^3',
        form   => '\x*\x*\x',
        domain => '-2:2',
        alt    => 'A graph of a curve from the third quadrant (where is it '
            . 'concave down) to the first quadrant (where it is concave up).'
    },
    {
        f      => 'ln(x)',
        form   => 'ln(\x)',
        domain => '0.1:6',
        alt    => 'A graph of a curve that approaches the negative y-axis '
            . 'and rises to the first quadrant and everywhere it is concave'
            . 'down.'
    },
    {
        f      => '3x+2',
        form   => '3*\x+2',
        domain => '-6:6',
        alt    =>
            'The graph of a line from the 3rd quadrant to the first quadrant'
    },
    {
        f      => 'sin(x)',
        form   => 'sin(\x r)',
        domain => '-6:6',
        alt    => 'A graph of a curve that oscillates and passes through the '
            . 'origin'
    },
);

@plots = random_subset(4, @all_plots);

for (@plots) {
    my $graph = createTikZImage();
    $graph->tikzLibraries('arrows.meta');
    $graph->BEGIN_TIKZ
    \tikzset{>={Stealth[scale = 1.5]}}
    \filldraw[
        draw = LightBlue,
        fill = white,
        rounded corners = 10pt,
        thick,
        use as bounding box
    ] (-6, -6) rectangle (6, 6);
    \draw[->, thick] (-6, 0) -- (6, 0)
        node[above left, outer sep = 3pt] {\(x\)};
    \foreach \x in {-5, ..., -1, 1, 2, ..., 5}
        \draw (\x, 5pt) -- (\x, -5pt) node[below] {\(\x\)};
    \draw[->, thick] (0, -6) -- (0, 6)
        node[below right, outer sep = 3pt] {\(y\)};
    \foreach \y in {-5, ..., -1, 1, 2, ..., 5}
        \draw (5pt, \y) -- (-5pt, \y) node[left] {\(\y\)};
    \draw[blue, ultra thick] plot[domain = $_->{domain}, smooth]
        (\x, {$_->{form}});
END_TIKZ
    $_->{graph} = $graph;
}

# sorted list of possible answers
$list = [ lex_sort(map { $_->{f} } @all_plots) ];

@dropdowns = map { DropDown($list, $_->{f}) } @plots;

$showPartialCorrectAnswers = 0;

BEGIN_PGML
Match the graph with the formula for the graph
(Click on image for a larger view.)

[#
    [.
        [![$plots[0]{alt}]!]{$plots[0]{graph}}{300}{
            image_options => { tex_size => 400 }
        }
    .]
    [.
        [![$plots[1]{alt}]!]{$plots[1]{graph}}{300}{
            image_options => { tex_size => 400 }
        }
    .]*

    [.[_]{$dropdowns[0]}.] [.[_]{$dropdowns[1]}.]*

    [.
        [![$plots[2]{alt}]!]{$plots[2]{graph}}{300}{
            image_options => { tex_size => 400 }
        }
    .]
    [.
        [![$plots[3]{alt}]!]{$plots[3]{graph}}{300}{
            image_options => { tex_size => 400 }
        }
    .]*

    [.[_]{$dropdowns[2]}.] [.[_]{$dropdowns[3]}.]*
#]*{ align => 'cc' }
END_PGML

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();