--- loncom/homework/chemresponse.pm 2008/12/23 18:51:44 1.86 +++ loncom/homework/chemresponse.pm 2014/02/13 18:13:22 1.93 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # chemical equation style response # -# $Id: chemresponse.pm,v 1.86 2008/12/23 18:51:44 raeburn Exp $ +# $Id: chemresponse.pm,v 1.93 2014/02/13 18:13:22 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -87,7 +87,7 @@ JMESECTION my $insert_answer; if ($shown_text eq '') { $insert_answer= - ''; + ''; } my $js = < '#FFFFFF',}); my $end_page = &Apache::loncommon::end_page({'js_ready' => 1,}); - + my $java_not_enabled=&Apache::lonhtmlcommon::java_not_enabled(); + my %lt = &Apache::lonlocal::texthash( + 'seltext' => 'Select substituent...', + 'close' => 'Close', + 'help' => 'Help', + ); my $body=< -
+
-You have to enable Java and JavaScript on your machine. +$java_not_enabled $molecule
@@ -151,9 +156,9 @@ $molecule
$insert_answer
- +    - +
CHEMPAGE @@ -165,7 +170,7 @@ CHEMPAGE if (defined($shown_text)) { $display=&mt($shown_text); } my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; my $function = - 'LONCAPA_draw_molecule_'.&Apache::lonhtmlcommon::get_uniq_name(); + 'LONCAPA_draw_molecule_'.&get_uniq_name(); my $result=< function $function() { @@ -304,9 +309,17 @@ sub end_organicresponse { $ad='INCORRECT'; } } - if ($ad && $Apache::lonhomework::type eq 'survey') { - $ad='SUBMITTED'; - } + if ($ad) { + if ($Apache::lonhomework::type eq 'survey') { + $ad='SUBMITTED'; + } elsif ($Apache::lonhomework::type eq 'surveycred') { + $ad='SUBMITTED_CREDIT'; + } elsif ($Apache::lonhomework::type eq 'anonsurvey') { + $ad='ANONYMOUS'; + } elsif ($Apache::lonhomework::type eq 'anonsurveycred') { + $ad='ANONYMOUS_CREDIT'; + } + } &Apache::response::handle_previous(\%previous,$ad); $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; $Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$env{"form.MOLECULE_$id"}; @@ -329,8 +342,8 @@ sub end_organicresponse { if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') { - &Apache::lonxml::increment_counter(&Apache::response::repetition(), - "$partid.$id"); # part.response + my $repetition = &Apache::response::repetition(); + &Apache::lonxml::increment_counter($repetition,"$partid.$id"); # part.response if ($target eq 'analyze') { $Apache::lonhomework::analyze{"$partid.$id.type"} = 'organicresponse'; push (@{ $Apache::lonhomework::analyze{"parts"} },"$partid.$id"); @@ -369,7 +382,7 @@ sub end_organicresponse { sub format_prior_answer_organic { my ($mode,$answer,$other_data) = @_; - my $result=&mt('Smile representation: "[_1]"',''.$answer.''); + my $result=&mt('Smile representation: [_1]','"'.$answer.'"'); my $jme=$other_data->[0]; $result.=&jme_img($jme,$answer,400); return $result; @@ -409,7 +422,8 @@ sub start_organicstructure { $id=&escape($id); &Apache::lonxml::register_ssi("/cgi-bin/convertjme.pl?$id"); if ($options =~ /border/) { $result.= '\fbox{'; } - $result .= '\graphicspath{{/home/httpd/perl/tmp/}}\includegraphics[width='.$texwidth.' mm]{'.$filename.'.eps}'; + $result .= '\graphicspath{{'.LONCAPA::tempdir(). + '}}\includegraphics[width='.$texwidth.' mm]{'.$filename.'.eps}'; if ($options =~ /border/) { $result.= '} '; } } elsif ($target eq 'edit') { $result .=&Apache::edit::tag_start($target,$token); @@ -558,9 +572,17 @@ sub end_reactionresponse { $ad='INCORRECT'; } } - if ($ad && $Apache::lonhomework::type eq 'survey') { - $ad='SUBMITTED'; - } + if ($ad) { + if ($Apache::lonhomework::type eq 'survey') { + $ad='SUBMITTED'; + } elsif ($ad && $Apache::lonhomework::type eq 'surveycred') { + $ad='SUBMITTED_CREDIT'; + } elsif ($ad && $Apache::lonhomework::type eq 'anonsurvey') { + $ad='ANONYMOUS'; + } elsif ($ad && $Apache::lonhomework::type eq 'anonsurveycred') { + $ad='ANONYMOUS_CREDIT'; + } + } &Apache::response::handle_previous(\%previous,$ad); $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; } @@ -582,7 +604,8 @@ sub end_reactionresponse { if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') { - &Apache::lonxml::increment_counter(&Apache::response::repetition(), "$partid.$id"); + my $repetition = &Apache::response::repetition(); + &Apache::lonxml::increment_counter($repetition,"$partid.$id"); if ($target eq 'analyze') { $Apache::lonhomework::analyze{"$partid.$id.type"} = 'reactionresponse'; push (@{ $Apache::lonhomework::analyze{"parts"} },"$partid.$id"); @@ -626,5 +649,11 @@ sub end_chem { return $result; } +my $uniq=0; +sub get_uniq_name { + $uniq++; + return 'uniquename'.$uniq; +} + 1; __END__