From f8558033608f96dc9dac1c1f806fe46a47904e68 Mon Sep 17 00:00:00 2001 From: Geoff Goehle Date: Mon, 11 Mar 2013 09:17:16 -0500 Subject: [PATCH 1/5] Backticks are picky about variables so they shouldn't be advertised to students in textovers. --- macros/PGessaymacros.pl | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/macros/PGessaymacros.pl b/macros/PGessaymacros.pl index 2abf3bc2d7..15d65e794f 100644 --- a/macros/PGessaymacros.pl +++ b/macros/PGessaymacros.pl @@ -98,19 +98,20 @@ sub essay_cmp { sub NAMED_ESSAY_BOX { my($name,$row,$col) = @_; - $row = 10 unless defined($row); - $col = 80 unless defined($col); + $row = 8 unless defined($row); + $col = 75 unless defined($col); my $height = .07*$row; my $answer_value = ''; $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} ); $name = RECORD_ANS_NAME($name, $answer_value); - $answer_value =~ tr/$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3 + $answer_value =~ tr/$@//d; #`## make sure student answers can not be interpolated by e.g. EV3 - #### Answer Value needs to be sanitized, it could contain badness! + #### Answer Value needs to have special characters replaced by the html codes $answer_value =~ s/\\/\&\#92;/g; $answer_value =~ s//\>/g; + $answer_value =~ s/`/`/g; # Get rid of tabs since they mess up the past answer db $answer_value =~ s/\t/\ \ \ \ \ /; @@ -121,7 +122,7 @@ sub essay_cmp { Latex2HTML => qq!\\begin{rawhtml}\\end{rawhtml}!, HTML => qq! + WRAP="VIRTUAL" title="Enclose LaTeX expressions with \[ and \].">$answer_value ! ); @@ -129,11 +130,31 @@ sub essay_cmp { $out; } +sub essay_help { + + my $out = MODES( + TeX => '', + Latex2HTML => '', + HTML => qq! +

This is an essay answer text box. You can type your answer in here and, after you hit submit, + it will be saved so that your instructor can grade it at a later date. If your instructor makes + any comments on your answer those comments will appear on this page after the question has been + graded. You can use LaTeX to make your math equations look pretty. + LaTeX expressions should be enclosed with \[ + and \] like so, \[\frac{1}{x+2}\]. +

+ ! + ); + + $out; +} + + sub essay_box { my $row = shift; my $col =shift; - $row = 12 unless $row; - $col = 120 unless $col; + $row = 8 unless $row; + $col = 75 unless $col; my $name = NEW_ANS_NAME(); NAMED_ESSAY_BOX($name ,$row,$col); From 3bf742ccca5f19c63cadc8ddaee5180528579b2d Mon Sep 17 00:00:00 2001 From: Geoff Goehle Date: Mon, 11 Mar 2013 09:30:43 -0500 Subject: [PATCH 2/5] Fixed poor formatting for essay_help --- macros/PGessaymacros.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/macros/PGessaymacros.pl b/macros/PGessaymacros.pl index 15d65e794f..5cfac628e1 100644 --- a/macros/PGessaymacros.pl +++ b/macros/PGessaymacros.pl @@ -122,7 +122,7 @@ sub essay_cmp { Latex2HTML => qq!\\begin{rawhtml}\\end{rawhtml}!, HTML => qq! + WRAP="VIRTUAL" title="Enclose LaTeX expressions with \( and \).">$answer_value ! ); @@ -140,8 +140,7 @@ sub essay_cmp { it will be saved so that your instructor can grade it at a later date. If your instructor makes any comments on your answer those comments will appear on this page after the question has been graded. You can use LaTeX to make your math equations look pretty. - LaTeX expressions should be enclosed with \[ - and \] like so, \[\frac{1}{x+2}\]. + LaTeX expressions should be enclosed using the parenthesis notation and not dollar signs.

! ); From 0cd25e096a4a60388d9b705cbee7c9fc78f98986 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 19 Mar 2013 09:30:17 -0400 Subject: [PATCH 3/5] Fix a problem with Fractions and Infinity (promote Infinity to Fraction rather than the other way around) --- macros/contextFraction.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/macros/contextFraction.pl b/macros/contextFraction.pl index bc5d71f731..2e2528a0c4 100644 --- a/macros/contextFraction.pl +++ b/macros/contextFraction.pl @@ -256,6 +256,7 @@ sub Init { $context->{value}{Real} = "context::Fraction::Real"; $context->{parser}{Value} = "context::Fraction::Value"; $context->{parser}{Number} = "Parser::Legacy::LimitedNumeric::Number"; + $context->{precedence}{Fraction} = $context->{precedence}{Infinity} + .5; # Fractions are above Infinity $context = $main::context{'Fraction-NoDecimals'} = $context->copy; $context->{name} = "Fraction-NoDecimals"; @@ -643,6 +644,7 @@ sub promote { return (bless {data => [$x->value,1], context => $context}, $class) if Value::isReal($x); return (bless {data => [$x,1], context => $context}, $class) if Value::matchNumber($x); } + return $x if Value::isValue($x) && $x->classMatch("Infinity"); return $self->new($context,$x,@_); } From 9b73bd821949eca3c235c22758865896dbaca1bd Mon Sep 17 00:00:00 2001 From: Michael Gage Date: Thu, 21 Mar 2013 09:17:23 -0400 Subject: [PATCH 4/5] Correct bug in printing solutionsand hints in TeX mode --- macros/PGbasicmacros.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/macros/PGbasicmacros.pl b/macros/PGbasicmacros.pl index 2e61b41360..cf4b40e11b 100644 --- a/macros/PGbasicmacros.pl +++ b/macros/PGbasicmacros.pl @@ -1081,8 +1081,8 @@ sub solution { sub SOLUTION { - if ($envir->{use_knowls_for_solutions}) { - TEXT( knowlLink("$PAR SOLUTION: ", value => escapeSolutionHTML($BR . solution(@_) . $PAR ), + if ($displayMode =~/HTML/ and $envir->{use_knowls_for_solutions}) { + TEXT( $PAR, knowlLink("SOLUTION: ", value => escapeSolutionHTML($BR . solution(@_) . $PAR ), base64 =>1 ) ) if solution(@_); } else { TEXT( "$PAR SOLUTION: ".$BR.solution(@_).$PAR) if solution(@_) ; @@ -1123,8 +1123,8 @@ sub hint { sub HINT { - if ($envir->{use_knowls_for_hints}) { - TEXT( knowlLink("$PAR HINT: ", value=>escapeSolutionHTML($BR . hint(@_) . $PAR ), + if ($displayMode =~/HTML/ and $envir->{use_knowls_for_hints}) { + TEXT($PAR, knowlLink("HINT: ", value=>escapeSolutionHTML($BR . hint(@_) . $PAR ), base64 => 1) ) if hint(@_); } else { From 5ac1704e7ebff41ffa2ae70a7cdc47bfa5e79124 Mon Sep 17 00:00:00 2001 From: wwadmin Date: Fri, 5 Apr 2013 18:47:03 -0400 Subject: [PATCH 5/5] Made Essay questions work with backticks for easy formatting. (Added typsetting context). Removed TinyMCE since nobody used it and it kept giving errors. --- macros/PGessaymacros.pl | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/macros/PGessaymacros.pl b/macros/PGessaymacros.pl index 5cfac628e1..e0f5b4dd67 100644 --- a/macros/PGessaymacros.pl +++ b/macros/PGessaymacros.pl @@ -40,18 +40,6 @@ sub _PGessaymacros_init { } -HEADER_TEXT(< - -EOT - - sub essay_cmp { my $self = shift; @@ -74,7 +62,11 @@ sub essay_cmp { $student->{original_student_ans} = $scrubber->scrub($student->{original_student_ans}); # always returns false but stuff should check for the essay flag and avoid the red highlighting + loadMacros("contextTypeset.pl"); + my $oldContext = Context(); + Context("Typeset"); my $answer_value = EV3P({processCommands=>0,processVariables=>0},$student->{original_student_ans}); + Context($oldContext); my $ans_hash = new AnswerHash( 'score'=>"0", 'correct_ans'=>"Undefined", @@ -122,7 +114,7 @@ sub essay_cmp { Latex2HTML => qq!\\begin{rawhtml}\\end{rawhtml}!, HTML => qq! + WRAP="VIRTUAL" title="Enclose math expressions with backticks ` or use LaTeX.">$answer_value ! );