Skip to content

Commit

Permalink
Add the non_tex_preview flag to the cmp options for the
Browse files Browse the repository at this point in the history
parserGraphTool.pl macro so that its answers are not typeset by MathJax.
  • Loading branch information
drgrice1 committed Feb 27, 2021
1 parent 851410c commit f313c9c
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions macros/parserGraphTool.pl
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,9 @@ sub cmp_preprocess {
my $graphObjs = @{$self->{staticObjects}} ?
join(",", @{$self->{staticObjects}}, $ans->{student_ans}) : $ans->{student_ans};

# This first ends the attempts table MathJax math mode, then injects the jsxgraph div and javascript, and then
# starts another MathJax math mode that is ended by the atttempts table. Both of the MathJax elements are
# removed by the injected javascript.
$ans->{preview_latex_string} = <<"END_ANS";
\\]
<div id='${ans_name}_student_ans_graphbox' class='graphtool-answer-container'></div>
<script>
jQuery("#${ans_name}_student_ans_graphbox").parent().find('mjx-container').remove();
jQuery(function() {
graphTool("${ans_name}_student_ans_graphbox", {
staticObjects: "$graphObjs",
Expand All @@ -543,7 +538,6 @@ sub cmp_preprocess {
});
});
</script>
\\[
END_ANS
}
}
Expand All @@ -554,22 +548,17 @@ sub cmp_preprocess {
# displayed in the "Correct Answer" box of the results table.
sub cmp {
my $self = shift;
my $cmp = $self->SUPER::cmp(%{$self->{cmpOptions}}, @_);
my $cmp = $self->SUPER::cmp(non_tex_preview => 1, %{$self->{cmpOptions}}, @_);

if ($main::displayMode ne 'TeX') {
my $ans_name = $self->ANS_NAME;
$self->constructJSXGraphOptions;
my $graphObjs = @{$self->{staticObjects}} ?
join(",", @{$self->{staticObjects}}, $cmp->{rh_ans}{correct_ans}) : $cmp->{rh_ans}{correct_ans};

# This first ends the attempts table MathJax math mode, then injects the jsxgraph div and javascript, and then
# starts another MathJax math mode that is ended by the atttempts table. Both of the MathJax elements are
# removed by the injected javascript.
$cmp->{rh_ans}{correct_ans_latex_string} = << "END_ANS";
\\]
<div id='${ans_name}_correct_ans_graphbox' class='graphtool-answer-container'></div>
<script>
jQuery("#${ans_name}_correct_ans_graphbox").parent().find('mjx-container').remove();
jQuery(function() {
graphTool("${ans_name}_correct_ans_graphbox", {
staticObjects: "$graphObjs",
Expand All @@ -581,7 +570,6 @@ sub cmp {
});
});
</script>
\\[
END_ANS
}

Expand Down

0 comments on commit f313c9c

Please sign in to comment.