Diff for /loncom/homework/chemresponse.pm between versions 1.99 and 1.102

version 1.99, 2017/01/04 20:09:08 version 1.102, 2023/06/26 14:24:15
Line 199  RESIZEJS Line 199  RESIZEJS
 function jsmeOnLoad() {  function jsmeOnLoad() {
     document.getElementById('JMErefresh').style.display="none";      document.getElementById('JMErefresh').style.display="none";
     document.getElementById('JMEcredits').style.display="inline";      document.getElementById('JMEcredits').style.display="inline";
     jsmeApplet = new JSApplet.JSME("jme", "420px", "330px");      jsmeApplet = new JSApplet.JSME("jme", "420px", "330px", {"options" : "$options"});
     document.JME = jsmeApplet;      document.JME = jsmeApplet;
     $molecule;      $molecule;
     document.getElementById('JMEbuttons').style.display="block";      document.getElementById('JMEbuttons').style.display="block";
Line 217  function submitSmiles() { Line 217  function submitSmiles() {
     }      }
 }  }
 function openHelpWindow() {  function openHelpWindow() {
     window.open("http://peter-ertl.com/jsme/2013_03/help.html","","scrollbars=yes,resizable=yes,width=500,height=600");      window.open("https://jsme-editor.github.io/help.html","","scrollbars=yes,resizable=yes,width=500,height=600");
 }  }
   
 </script>  </script>
Line 630  sub end_organicstructure { Line 630  sub end_organicstructure {
     return $result;      return $result;
 }  }
   
   sub edit_reaction_button {
       my ($id,$field,$reaction)=@_;
       my $id_es=&escape($id);
       my $field_es=&escape($field);
       my $reaction_es=&escape($reaction);
       my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
       my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
       my $display=&mt('Edit Answer');
       my $start_page =
           &Apache::loncommon::start_page('LON-CAPA Reaction Editor',undef,
                                          {'frameset'    => 1,
                                           'js_ready'    => 1,
                                           'add_entries' => {
                                               'rows'   => "30%,*",
                                               'border' => "0",}},);
       my $end_page =
           &Apache::loncommon::end_page({'frameset' => 1,
                                         'js_ready' => 1});
       my $result=<<EDITREACTION;
   <script type="text/javascript">
   // <!--
       function create_reaction_window_${id}_${field} () {
           editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes');
           editor.$docopen;
           editor.document.writeln('$start_page <frame src="/adm/reactionresponse/reaction_viewer.html?inhibitmenu=yes" name="viewer" scrolling="no" />  <frame src="/adm/reactionresponse/reaction_editor.html?inhibitmenu=yes&reaction=$reaction_es&id=$id_es&field=$field_es" name="editor" scrolling="no" /> $end_page');
           editor.document.close();
       }
   // -->
   </script>
   <a href="javascript:create_reaction_window_${id}_${field}();void(0);"><img class="stift" src='$iconpath/stift.gif' alt='$display' title='$display' /></a>
   EDITREACTION
       return $result;
   }
   
 sub reaction_preview {  sub reaction_preview {
     my ($field, $reaction) = @_;      my ($field, $reaction) = @_;
           
Line 682  sub start_reactionresponse { Line 716  sub start_reactionresponse {
  $safeeval);   $safeeval);
  $result .='<span class="LC_nobreak">'.   $result .='<span class="LC_nobreak">'.
     &Apache::edit::text_arg('Answer:','answer',$token,40);      &Apache::edit::text_arg('Answer:','answer',$token,40);
  $result .= &reaction_preview(&Apache::edit::html_element_name('answer'), $answer).'</span>';          my $inline_chem = &use_inline_chem();
           if ($inline_chem) {
       $result .= &reaction_preview(&Apache::edit::html_element_name('answer'), $answer).'</span>';
           } else {
               $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'</span>';
           }
  my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval);   my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval);
  $result.='<span class="LC_nobreak">'.   $result.='<span class="LC_nobreak">'.
     &Apache::edit::text_arg('Initial Reaction:','initial',$token,40);      &Apache::edit::text_arg('Initial Reaction:','initial',$token,40);
         $result .= &reaction_preview(&Apache::edit::html_element_name('initial'), $initial).'</span>';          if ($inline_chem) { 
               $result .= &reaction_preview(&Apache::edit::html_element_name('initial'), $initial).'</span>';
           } else {
               $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'</span>';
           }
  $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,
Line 774  sub end_reactionresponse { Line 817  sub end_reactionresponse {
     if  (($target eq 'web') && ($Apache::lonhomework::type ne 'exam') && ($status eq 'CAN_ANSWER')) {      if  (($target eq 'web') && ($Apache::lonhomework::type ne 'exam') && ($status eq 'CAN_ANSWER')) {
         my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"};          my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"};
         if ($reaction eq '') {  $reaction=&Apache::lonxml::get_param('initial',$parstack,$safeeval); }          if ($reaction eq '') {  $reaction=&Apache::lonxml::get_param('initial',$parstack,$safeeval); }
         $result .= &reaction_preview("HWVAL_$id", $reaction);          if (&use_inline_chem()) {
               $result .= &reaction_preview("HWVAL_$id", $reaction);
           } else {
               $result.=&edit_reaction_button($id,"HWVAL_$id",$reaction);
           }
     }      }
     &Apache::response::end_response();      &Apache::response::end_response();
     return $result;      return $result;
 }  }
   
   sub use_inline_chem {
       my $inline_chem = 1;
       if (($env{'request.course.id'}) && ($env{'request.state'} ne 'construct')) {
           if (exists($env{'course.'.$env{'request.course.id'}.'.inline_chem'})) {
               if ($env{'course.'.$env{'request.course.id'}.'.inline_chem'} eq '0') {
                   $inline_chem = 0;
               }
           } else {
               my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
               if ($domdefs{'inline_chem'} eq '0') {
                   $inline_chem = 0;
               }
           }
       } else {
           my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
           if ($domdefs{'inline_chem'} eq '0') {
               $inline_chem = 0;
           }
       }
       return $inline_chem;
   }
   
 sub format_prior_response_reaction {  sub format_prior_response_reaction {
     my ($mode,$answer) =@_;      my ($mode,$answer) =@_;
     return '<span class="LC_prior_reaction">'.      return '<span class="LC_prior_reaction">'.

Removed from v.1.99  
changed lines
  Added in v.1.102


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>