[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm outputtags.pm /homework/caparesponse caparesponse.c

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 01 Jul 2003 21:10:43 -0000


albertel		Tue Jul  1 17:10:43 2003 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm outputtags.pm 
    /loncom/homework/caparesponse	caparesponse.c 
  Log:
  - changed a misnmomer variable
  - actually restores last response in editor window
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.10 loncom/homework/chemresponse.pm:1.11
--- loncom/homework/chemresponse.pm:1.10	Tue Jul  1 17:04:48 2003
+++ loncom/homework/chemresponse.pm	Tue Jul  1 17:10:43 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.10 2003/07/01 21:04:48 albertel Exp $
+# $Id: chemresponse.pm,v 1.11 2003/07/01 21:10:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -228,16 +228,16 @@
 }
 
 sub edit_reaction_button {
-    my ($id,$field,$molecule)=@_;
+    my ($id,$field,$reaction)=@_;
     my $id_es=&Apache::lonnet::escape($id);
     my $field_es=&Apache::lonnet::escape($field);
-    my $molecule_es=&Apache::lonnet::escape($molecule);
+    my $reaction_es=&Apache::lonnet::escape($reaction);
     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.document.open('text/html','replace');
-	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" name="viewer" scrolling="no" />  <frame src="/res/adm/pages/reactionresponse/reaction_editor.html?molecule=$molecule_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" name="viewer" scrolling="no" />  <frame src="/res/adm/pages/reactionresponse/reaction_editor.html?reaction=$reaction_es&id=$id_es&field=$field_es" name="editor" scrolling="no" /> </frameset> </html>');
     }
 </script>
 <input type='button' value='Edit Reaction' onClick="javascript:create_reaction_window_${id}_${field}();void(0);" />
@@ -251,7 +251,10 @@
     my $id = &Apache::response::start_response($parstack,$safeeval);
     if ($target eq 'meta') {
     } elsif ($target eq 'web') {
-	$result.=&edit_reaction_button($id,"HWVAL_$id");
+	my $partid = $Apache::inputtags::part;
+	my $id = $Apache::inputtags::response['-1'];
+	my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"};
+	$result.=&edit_reaction_button($id,"HWVAL_$id",$reaction);
     } elsif ($target eq "edit") {
 	$result .=&Apache::edit::tag_start($target,$token);
 	my $answer=&Apache::lonxml::get_param('answer',$parstack,
Index: loncom/homework/outputtags.pm
diff -u loncom/homework/outputtags.pm:1.29 loncom/homework/outputtags.pm:1.30
--- loncom/homework/outputtags.pm:1.29	Sat May  3 17:09:03 2003
+++ loncom/homework/outputtags.pm	Tue Jul  1 17:10:43 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # tags that create controlled output
 #
-# $Id: outputtags.pm,v 1.29 2003/05/03 21:09:03 albertel Exp $
+# $Id: outputtags.pm,v 1.30 2003/07/01 21:10:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -144,10 +144,15 @@
 	} else {
 	    my @parts=&multipart($ENV{'request.uri'});
 	    my $weight;
-	    foreach my $part (@parts) {
-		my $pweight=&Apache::lonnet::EXT("resource.$part.weight");
-		if (!defined($pweight) || ($pweight eq '')) { $pweight=1; }
-		$weight+=$pweight;
+	    if (@parts) {
+	        foreach my $part (@parts) {
+		    my $pweight=&Apache::lonnet::EXT("resource.$part.weight");
+		    if (!defined($pweight) || ($pweight eq '')) { $pweight=1; }
+		    $weight+=$pweight;
+	        }
+	    } else {
+		$weight = &Apache::lonnet::EXT("resource.$id.weight");
+                if (!defined($weight) || ($weight eq '')) { $weight=1; }
 	    }
 	    $result=$weight;
 	}
Index: loncom/homework/caparesponse/caparesponse.c
diff -u loncom/homework/caparesponse/caparesponse.c:1.9 loncom/homework/caparesponse/caparesponse.c:1.10
--- loncom/homework/caparesponse/caparesponse.c:1.9	Tue May 27 13:01:36 2003
+++ loncom/homework/caparesponse/caparesponse.c	Tue Jul  1 17:10:43 2003
@@ -1,6 +1,6 @@
 /* The LearningOnline Network with CAPA 
  * CAPA wrapper code
- * $Id: caparesponse.c,v 1.9 2003/05/27 17:01:36 bowersj2 Exp $
+ * $Id: caparesponse.c,v 1.10 2003/07/01 21:10:43 albertel Exp $
  *
  * Copyright Michigan State University Board of Trustees
  *
@@ -32,11 +32,11 @@
   PointsList_t *new=NULL, *end=NULL, *beforeend=NULL, *rlist=NULL;
   char *idx_pts=pts_list;
   int done=0;
-  /*fprintf(stderr,"ids %s\n",id_list);
-    fprintf(stderr,"pts %s\n",pts_list);*/
+  /*fprintf(stderr,"ids %s\n",id_list);*/
+    fprintf(stderr,"pts %s\n",pts_list);
   while (!done) {
     int idx;
-    /*fprintf(stderr,"pts; %s\n",idx_pts);*/
+      fprintf(stderr,"pts; %s\n",idx_pts);
     new=gen_ptslist_str(idx_pts);
     if (!new) break;
     if (!rlist) { rlist=new; }
@@ -50,8 +50,8 @@
     while (end) {
       idx++;
       end->pts_idx=idx;
-      /*fprintf(stderr,"end is:%d:%d:%s:%d\n",idx,end->pts_idx,end->pts_str,
-	end->pts_next);*/
+        fprintf(stderr,"end is:%d:%d:%s:%d\n",idx,end->pts_idx,end->pts_str,
+	end->pts_next);
       beforeend=end;
       end=end->pts_next;
     }
@@ -75,48 +75,64 @@
   Problem_t p;
   char *error=NULL,filename[FILE_NAME_LENGTH];
   FILE *fp;
-
+fprintf(stderr,"1\n");
   /* need to initialize unit parser*/
   sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units");
   if ((fp=fopen(filename,"r"))==NULL) {
     /* printf("Error: can't open %s\n",filename);*/
       return (-1); 
   }
+fprintf(stderr,"2\n");
   u_getunit(fp);
+fprintf(stderr,"3\n");
   fclose(fp);
+fprintf(stderr,"4\n");
   /* need to setup random generator (FIXME) should only do this if 
      it hasn't been yet*/
   phrtsd(rndseed,&seed1,&seed2);
   setall(seed1,seed2);
+fprintf(stderr,"5\n");
 
   /* assign_id_list and assign_pts_list exist in capaGrammerDef.y */
   p.id_list=NULL;
   p.pts_list=NULL;
-
+fprintf(stderr,"6 -%s-\n",id_list);
   if (type == ANSWER_IS_FORMULA) {
     p.id_list=id_list;
     p.pts_list=parse_pts_list(pts_list);
   }
+fprintf(stderr,"6\n");
   p.ans_type   = type;
   p.answer     = correct;
   p.tol_type   = tol_type;
   p.tolerance  = tolerance;
   p.sig_lbound = sig_lbound;
   p.sig_ubound = sig_ubound;
+fprintf(stderr,"7\n");
   
   if (ans_fmt != NULL ) {
+fprintf(stderr,"8\n");
     strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1);
   }
+fprintf(stderr,"9\n");
   if (unit_str != NULL && unit_str[0]!='\0') {
+fprintf(stderr,"10\n");
     strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);
+fprintf(stderr,"11\n");
     p.ans_unit   = u_parse_unit(unit_str);
+fprintf(stderr,"12\n");
   } else {
+fprintf(stderr,"13\n");
     p.unit_str[0]='\0';
+fprintf(stderr,"14\n");
     p.ans_unit=NULL;
+fprintf(stderr,"15\n");
   }
   p.calc       = calc;
 
+fprintf(stderr,"16 -p.asnwer %s- -response %s-\n",p.answer,response);
   result=capa_check_answer(&p,response,&error);
+fprintf(stderr,"17\n");
 
   if (error!=NULL) {free(error);}