version 1.38, 2004/08/12 04:33:22
|
version 1.53, 2005/05/25 21:45:07
|
Line 32 use Apache::lonxml;
|
Line 32 use Apache::lonxml;
|
use Apache::lonnet; |
use Apache::lonnet; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse')); |
&Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem')); |
} |
} |
|
|
sub chem_standard_order { |
sub chem_standard_order { |
Line 84 JMESECTION
|
Line 84 JMESECTION
|
<html> |
<html> |
<head> |
<head> |
<title>Molecule Editor</title> |
<title>Molecule Editor</title> |
<script language="JavaScript"> |
<script type="text/javascript"> |
function submitSmiles() { |
function submitSmiles() { |
jmeFile = document.applets.JME.jmeFile(); |
jmeFile = document.applets.JME.jmeFile(); |
if (jmeFile == "") { |
if (jmeFile == "") { |
Line 107 You have to enable Java and JavaScript o
|
Line 107 You have to enable Java and JavaScript o
|
$molecule |
$molecule |
<param name="options" value="$options" /> |
<param name="options" value="$options" /> |
</applet><br /> |
</applet><br /> |
<font face="arial,helvetica,sans-serif" size=-1><a href="http://www.molinspiration.com/jme/index.html">JME Editor</a> courtesy of Peter Ertl, Novartis</font> |
<font face="arial,helvetica,sans-serif" size="-1"><a href="http://www.molinspiration.com/jme/index.html">JME Editor</a> courtesy of Peter Ertl, Novartis</font> |
<form> |
<form> |
<input type="button" name="submit" value="Insert Answer" onClick = "submitSmiles();" /> |
<input type="button" name="submit" value="Insert Answer" onclick = "submitSmiles();" /> |
<br /> |
<br /> |
<input type="button" value=" Close " onClick = "window.close()" /> |
<input type="button" value=" Close " onclick = "window.close()" /> |
|
|
<input type="button" value=" Help " onClick = "openHelpWindow()" /> |
<input type="button" value=" Help " onclick = "openHelpWindow()" /> |
</form> |
</form> |
</center> |
</center> |
</body> |
</body> |
Line 121 $molecule
|
Line 121 $molecule
|
CHEMPAGE |
CHEMPAGE |
$body=&HTML::Entities::encode($body,'<>&"'); |
$body=&HTML::Entities::encode($body,'<>&"'); |
$body=~s/\n/ /g; |
$body=~s/\n/ /g; |
|
my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); |
|
my $docopen=&Apache::lonhtmlcommon::javascript_docopen(); |
my $result=<<CHEMINPUT; |
my $result=<<CHEMINPUT; |
<input type="button" value="Draw Molecule" onClick="javascript:editor=window.open('','','width=500,height=500,scrollbars=no,resizable=yes');editor.document.open('text/html','replace');editor.document.writeln('$body')" /> |
<input type="button" value="Draw Molecule" onclick="javascript:editor=window.open('$nothing','jmeedit','width=500,height=500,menubar=yes,scrollbars=no,resizable=yes');editor.$docopen;editor.document.write('$body');editor.document.close();editor.focus()" /> |
CHEMINPUT |
CHEMINPUT |
return $result; |
return $result; |
} |
} |
Line 135 sub start_organicresponse {
|
Line 137 sub start_organicresponse {
|
if ($target eq 'meta') { |
if ($target eq 'meta') { |
$result=&Apache::response::meta_package_write('organicresponse'); |
$result=&Apache::response::meta_package_write('organicresponse'); |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
my $molecule; |
if ( &Apache::response::show_answer() ) { |
if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) { |
my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack, |
$molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"}; |
$safeeval); |
|
my $options=&Apache::lonxml::get_param('options',$parstack, |
|
$safeeval); |
|
my $width=&Apache::lonxml::get_param('width',$parstack, |
|
$safeeval); |
|
my $id=&Apache::loncommon::get_cgi_id(); |
|
$result="<img src='/cgi-bin/convertjme.pl?$id'"; |
|
if ($options =~ /border/) { $result.= ' border="1"'; } |
|
$result.=' />'; |
|
&Apache::lonnet::appenv('cgi.'.$id.'.JME' => |
|
&Apache::lonnet::escape($jmeanswer), |
|
'cgi.'.$id.'.PNG' => 1, |
|
'cgi.'.$id.'.WIDTH' => $width); |
} else { |
} else { |
$molecule=&Apache::lonxml::get_param('molecule',$parstack, |
my $molecule; |
$safeeval); |
if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) { |
|
$molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"}; |
|
} else { |
|
$molecule=&Apache::lonxml::get_param('molecule',$parstack, |
|
$safeeval); |
|
} |
|
my $options=&Apache::lonxml::get_param('options',$parstack, |
|
$safeeval); |
|
$result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options); |
|
$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />'; |
} |
} |
my $options=&Apache::lonxml::get_param('options',$parstack, |
|
$safeeval); |
|
$result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options); |
|
$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />'; |
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result .=&Apache::edit::tag_start($target,$token); |
$result .=&Apache::edit::tag_start($target,$token); |
my $options=&Apache::lonxml::get_param('options',$parstack, |
my $options=&Apache::lonxml::get_param('options',$parstack, |
Line 177 sub start_organicresponse {
|
Line 196 sub start_organicresponse {
|
['reaction','Is a reaction'], |
['reaction','Is a reaction'], |
['number','Able to number atoms'] ], |
['number','Able to number atoms'] ], |
,$token); |
,$token); |
|
$result .=&Apache::edit::text_arg('Width of correct answer image:', |
|
'width',$token,10); |
$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=&Apache::edit::get_new_args($token,$parstack, |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'molecule', |
$safeeval,'molecule', |
'answer','jmeanswer', |
'answer','jmeanswer', |
'options'); |
'options','width'); |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
} |
} |
return $result; |
return $result; |
Line 191 sub start_organicresponse {
|
Line 212 sub start_organicresponse {
|
sub end_organicresponse { |
sub end_organicresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result; |
my $result; |
if ($target eq 'grade' && defined($ENV{'form.submitted'})) { |
if ($target eq 'grade' && &Apache::response::submitted()) { |
&Apache::response::setup_params($$tagstack[-1],$safeeval); |
&Apache::response::setup_params($$tagstack[-1],$safeeval); |
my $response = &Apache::response::getresponse(); |
my $response = &Apache::response::getresponse(); |
if ( $response =~ /[^\s]/) { |
if ( $response =~ /[^\s]/) { |
Line 210 sub end_organicresponse {
|
Line 231 sub end_organicresponse {
|
$ad='INCORRECT'; |
$ad='INCORRECT'; |
} |
} |
} |
} |
|
if ($ad && $Apache::lonhomework::type eq 'survey') { |
|
$ad='SUBMITTED'; |
|
} |
&Apache::response::handle_previous(\%previous,$ad); |
&Apache::response::handle_previous(\%previous,$ad); |
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; |
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; |
$Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$ENV{"form.MOLECULE_$id"}; |
$Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$env{"form.MOLECULE_$id"}; |
} |
} |
} elsif ($target eq "edit") { |
} elsif ($target eq "edit") { |
$result.= &Apache::edit::tag_end($target,$token,''); |
$result.= &Apache::edit::tag_end($target,$token,''); |
Line 249 sub start_organicstructure {
|
Line 273 sub start_organicstructure {
|
if (!$texwidth) { $texwidth='90'; } |
if (!$texwidth) { $texwidth='90'; } |
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval); |
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval); |
my $options=&Apache::lonxml::get_param('options',$parstack,$safeeval); |
my $options=&Apache::lonxml::get_param('options',$parstack,$safeeval); |
my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
my $filename = $env{'user.name'}.'_'.$env{'user.domain'}. |
'_'.time.'_'.$$.int(rand(1000)).'_organicstructure'; |
'_'.time.'_'.$$.int(rand(1000)).'_organicstructure'; |
my $id=$filename; |
my $id=$filename; |
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
Line 308 sub edit_reaction_button {
|
Line 332 sub edit_reaction_button {
|
my $id_es=&Apache::lonnet::escape($id); |
my $id_es=&Apache::lonnet::escape($id); |
my $field_es=&Apache::lonnet::escape($field); |
my $field_es=&Apache::lonnet::escape($field); |
my $reaction_es=&Apache::lonnet::escape($reaction); |
my $reaction_es=&Apache::lonnet::escape($reaction); |
|
my $docopen=&Apache::lonhtmlcommon::javascript_docopen(); |
my $result=<<EDITREACTION; |
my $result=<<EDITREACTION; |
<script type="text/javascript"> |
<script type="text/javascript"> |
|
// <!-- |
function create_reaction_window_${id}_${field} () { |
function create_reaction_window_${id}_${field} () { |
editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes'); |
editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes'); |
editor.document.open('text/html','replace'); |
editor.$docopen; |
editor.document.writeln('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><html> <head><title>LON-CAPA Reaction Editor</title></head><frameset rows="30%,*" border="0"> <frame src="/res/adm/pages/reactionresponse/reaction_viewer.html?inhibitmenu=yes" name="viewer" scrolling="no" /> <frame src="/res/adm/pages/reactionresponse/reaction_editor.html?inhibitmenu=yes&reaction=$reaction_es&id=$id_es&field=$field_es" name="editor" scrolling="no" /> </frameset> </html>'); |
editor.document.writeln('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><html> <head><title>LON-CAPA Reaction Editor</title></head><frameset rows="30%,*" border="0"> <frame src="/res/adm/pages/reactionresponse/reaction_viewer.html?inhibitmenu=yes" name="viewer" scrolling="no" /> <frame src="/res/adm/pages/reactionresponse/reaction_editor.html?inhibitmenu=yes&reaction=$reaction_es&id=$id_es&field=$field_es" name="editor" scrolling="no" /> </frameset> </html>'); |
} |
} |
|
// --> |
</script> |
</script> |
<input type='button' value='Edit Answer' onClick="javascript:create_reaction_window_${id}_${field}();void(0);" /> |
<input type='button' value='Edit Answer' onclick="javascript:create_reaction_window_${id}_${field}();void(0);" /> |
EDITREACTION |
EDITREACTION |
return $result; |
return $result; |
} |
} |
Line 338 sub start_reactionresponse {
|
Line 365 sub start_reactionresponse {
|
} |
} |
if ( &Apache::response::show_answer() ) { |
if ( &Apache::response::show_answer() ) { |
my $ans=&Apache::lonxml::get_param('answer',$parstack,$safeeval); |
my $ans=&Apache::lonxml::get_param('answer',$parstack,$safeeval); |
$ans=~s/(\\|\')/\\$1/g; |
if (!$Apache::lonxml::default_homework_loaded) { |
$Apache::inputtags::answertxt{$id}=&Apache::run::run("return &chemparse('$ans');",$safeeval); |
&Apache::lonxml::default_homework_load($safeeval); |
|
} |
|
@Apache::scripttag::parser_env = @_; |
|
$Apache::inputtags::answertxt{$id}=&Apache::run::run("return &chemparse(q\0$ans\0);",$safeeval); |
} |
} |
} elsif ($target eq "edit") { |
} elsif ($target eq "edit") { |
$result .=&Apache::edit::tag_start($target,$token); |
$result .=&Apache::edit::tag_start($target,$token); |
Line 350 sub start_reactionresponse {
|
Line 380 sub start_reactionresponse {
|
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'</nobr>'; |
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'</nobr>'; |
my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval); |
my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval); |
$result.='<nobr>'. |
$result.='<nobr>'. |
&Apache::edit::text_arg('Initial Reation:','initial',$token,40); |
&Apache::edit::text_arg('Initial Reaction:','initial',$token,40); |
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'</nobr>'; |
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'</nobr>'; |
|
|
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
Line 366 sub start_reactionresponse {
|
Line 396 sub start_reactionresponse {
|
sub end_reactionresponse { |
sub end_reactionresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result; |
my $result; |
if ($target eq 'grade' && defined($ENV{'form.submitted'})) { |
if ($target eq 'grade' && &Apache::response::submitted()) { |
&Apache::response::setup_params($$tagstack[-1],$safeeval); |
&Apache::response::setup_params($$tagstack[-1],$safeeval); |
my $response = &Apache::response::getresponse(); |
my $response = &Apache::response::getresponse(); |
if ( $response =~ /[^\s]/) { |
if ( $response =~ /[^\s]/) { |
Line 385 sub end_reactionresponse {
|
Line 415 sub end_reactionresponse {
|
$ad='INCORRECT'; |
$ad='INCORRECT'; |
} |
} |
} |
} |
|
if ($ad && $Apache::lonhomework::type eq 'survey') { |
|
$ad='SUBMITTED'; |
|
} |
&Apache::response::handle_previous(\%previous,$ad); |
&Apache::response::handle_previous(\%previous,$ad); |
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; |
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad; |
} |
} |
Line 404 sub end_reactionresponse {
|
Line 437 sub end_reactionresponse {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub start_chem { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; |
|
my $result = ''; |
|
my $inside = &Apache::lonxml::get_all_text_unbalanced("/chem",$parser); |
|
if ($target eq 'tex' || $target eq 'web') { |
|
$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]); |
|
if (!$Apache::lonxml::default_homework_loaded) { |
|
&Apache::lonxml::default_homework_load($safeeval); |
|
} |
|
@Apache::scripttag::parser_env = @_; |
|
$result=&Apache::run::run("return &chemparse(q\0$inside\0);",$safeeval); |
|
} |
|
return $result; |
|
} |
|
|
|
sub end_chem { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; |
|
my $result = ''; |
|
return $result; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |