version 1.188, 2008/03/06 16:28:20
|
version 1.192, 2008/06/14 16:34:54
|
Line 486 sub start_mathresponse {
|
Line 486 sub start_mathresponse {
|
$safeeval); |
$safeeval); |
$Apache::inputtags::answertxt{$id}=[$answer]; |
$Apache::inputtags::answertxt{$id}=[$answer]; |
} |
} |
|
if ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER') { |
|
$result.=&edit_mathresponse_button($id,"HWVAL_$id"); |
|
} |
|
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::text_arg('String to display for answer:', |
$result.=&Apache::edit::text_arg('String to display for answer:', |
Line 496 sub start_mathresponse {
|
Line 500 sub start_mathresponse {
|
$token); |
$token); |
$result.=&Apache::edit::text_arg('Argument Array:', |
$result.=&Apache::edit::text_arg('Argument Array:', |
'args',$token); |
'args',$token); |
|
$result.=&Apache::edit::text_arg('Libraries:', |
|
'libraries',$token); |
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my $constructtag; |
my $constructtag; |
$constructtag=&Apache::edit::get_new_args($token,$parstack, |
$constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'answerdisplay','cas','args'); |
$safeeval,'answerdisplay','cas','args','libraries'); |
if ($constructtag) { |
if ($constructtag) { |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
} |
} |
Line 512 sub start_mathresponse {
|
Line 518 sub start_mathresponse {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub edit_mathresponse_button { |
|
my ($id,$field)=@_; |
|
my $button=&mt('Edit Answer'); |
|
return(<<ENDFORMULABUTTON); |
|
<script language="JavaScript"> |
|
function edit_${id}_${field} (textarea) { |
|
thenumber = textarea; |
|
thedata = document.forms['lonhomework'].elements[textarea].value; |
|
newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable"); |
|
} |
|
</script> |
|
<input type='button' value='$button' onclick="javascript:edit_${id}_${field}('${field}');void(0);" /> |
|
ENDFORMULABUTTON |
|
} |
|
|
sub end_mathresponse { |
sub end_mathresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $result; |
my $result; |
Line 532 sub end_mathresponse {
|
Line 553 sub end_mathresponse {
|
my $cas = &Apache::lonxml::get_param('cas',$parstack,$safeeval); |
my $cas = &Apache::lonxml::get_param('cas',$parstack,$safeeval); |
if ($cas eq 'maxima') { |
if ($cas eq 'maxima') { |
my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)]; |
my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)]; |
$award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args); |
$award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args, |
|
&Apache::lonxml::get_param('libraries',$parstack,$safeeval)); |
} |
} |
if (!&Apache::inputtags::valid_award($award)) { |
if (!&Apache::inputtags::valid_award($award)) { |
$error = $award; |
$error = $award; |
Line 790 sub next_answer {
|
Line 812 sub next_answer {
|
|
|
sub answer_part { |
sub answer_part { |
my ($type,$answer,$args) = @_; |
my ($type,$answer,$args) = @_; |
&Apache::lonxml::debug("In answerpart :$type:$answer:$args:"); |
|
|
|
my $result; |
my $result; |
if ($env{'form.answer_output_mode'} eq 'tex') { |
if ($env{'form.answer_output_mode'} eq 'tex') { |
if (!$args->{'no_verbatim'}) { |
if (!$args->{'no_verbatim'}) { |
Line 803 sub answer_part {
|
Line 823 sub answer_part {
|
last; |
last; |
} |
} |
} |
} |
my $answerelements=$answer; |
my $fullanswer=$answer; |
$answer=''; |
$answer=''; |
foreach my $element (split(/[\;\:]/,$answerelements)) { |
foreach my $element (split(/[\;]/,$fullanswer)) { |
if ($element ne '') { |
if ($element ne '') { |
$answer.= '\noindent\verb'.$to_use.$element.$to_use.'\newline'; |
$answer.= '\verb'.$to_use.$element.$to_use.' \newline'; |
} |
} |
} |
} |
} |
} |
if ($answer ne '') { |
if ($answer ne '') { |
Line 819 sub answer_part {
|
Line 839 sub answer_part {
|
$result .= '<tr>'; |
$result .= '<tr>'; |
$need_row_start = 0; |
$need_row_start = 0; |
} |
} |
$answer=~s/\; /\<\/nobr\>\<br \/\>\<nobr\>/gs; |
$result .= '<td>'.$answer.'</td>'; |
$result .= '<td><nobr>'.$answer.'</nobr></td>'; |
|
} |
} |
return $result; |
return $result; |
} |
} |
Line 829 sub answer_footer {
|
Line 848 sub answer_footer {
|
my ($type) = @_; |
my ($type) = @_; |
my $result; |
my $result; |
if ($env{'form.answer_output_mode'} eq 'tex') { |
if ($env{'form.answer_output_mode'} eq 'tex') { |
my $columns = scalar(@answer_bits)-1; |
$result = ' \vskip 0 mm \noindent \begin{tabular}{|p{1.5cm}|p{6.8cm}|}\hline '; |
$result = ' \vskip 0 mm \noindent \begin{tabular}{|p{1.5cm}|'.'p{3cm}|'x$columns.'}\hline '; |
$result .= $answer_bits[0].'&\vspace*{-4mm}\begin{itemize}'; |
$result .= join(' & ',@answer_bits); |
for (my $i=1;$i<=$#answer_bits;$i++) { |
$result .= ' \\\\ \\hline \end{tabular} \vskip 0 mm '; |
$result.='\item '.$answer_bits[$i].'\vspace*{-7mm}'; |
|
} |
|
$result .= ' \end{itemize} \\\\ \hline \end{tabular} \vskip 0 mm '; |
} else { |
} else { |
if (!$need_row_start) { |
if (!$need_row_start) { |
$result .= '</tr>'; |
$result .= '</tr>'; |