[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /homework structuretags.pm

raeburn raeburn at source.lon-capa.org
Wed Oct 5 23:23:44 EDT 2011


raeburn		Thu Oct  6 03:23:44 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/homework	structuretags.pm 
  Log:
  - Backport 1.486, 1.487, 1.491, 1.492, 1.494.
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.465.2.13 loncom/homework/structuretags.pm:1.465.2.14
--- loncom/homework/structuretags.pm:1.465.2.13	Thu Jan 13 18:41:48 2011
+++ loncom/homework/structuretags.pm	Thu Oct  6 03:23:44 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.465.2.13 2011/01/13 18:41:48 raeburn Exp $
+# $Id: structuretags.pm,v 1.465.2.14 2011/10/06 03:23:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -129,8 +129,16 @@
 	<<'JS';
 <script type="text/javascript">
 // <![CDATA[
-function setSubmittedPart (part) {
-   this.document.lonhomework.submitted.value="part_"+part;
+function setSubmittedPart (part,prefix) {
+    if (typeof(prefix) == 'undefined') {
+        this.document.lonhomework.submitted.value="part_"+part;
+    } else {
+        for (var i=0;i<this.document.lonhomework.elements.length;i++) {
+            if (this.document.lonhomework.elements[i].name == prefix+'submitted') {
+                this.document.lonhomework.elements[i].value="part_"+part;
+            }
+        }
+    }
 }
 
 function image_response_click (which, e) {
@@ -468,27 +476,48 @@
        <input type="hidden" name="problemstatus" value="'.$env{'form.problemstatus'}.'" />';
 }
 
+sub problem_edit_action_button {
+    my ($name,$action,$accesskey,$text,$flag)=@_;
+    my $actionscript="setmode(this.form,'$action')";
+    return "\n<input type='button' name='$name' accesskey='$accesskey' value='".&mt($text)."'".
+           ($flag?&Apache::edit::submit_ask_anyway($actionscript):&Apache::edit::submit_dont_ask($actionscript))." />";
+}
+
 sub problem_edit_buttons {
-   return  '
-<div class="LC_edit_problem_discards">
-       <input type="button" name="submitmode" accesskey="d" value="'.&mt('Discard Edits and View').'" '.
-       ' onclick="javscript:setmode(this.form,'."'discard'".')"  />
-       <input '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'editxml'".')').' type="button" name="submitmode" accesskey="x" value="'.&mt('EditXML').'" />
-       <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" />
-</div>
-<div class="LC_edit_problem_saves">
-       <input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save and Edit').'" />
-       <input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" />
-</div>';
+    my ($mode)=@_;
+# Buttons that do not save
+    my $result='<div class="LC_edit_problem_discards">'.
+              &problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1);
+    if ($mode eq 'editxml') {
+        $result.=&problem_edit_action_button('subedit','edit','e','Edit',1);
+        $result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1);
+        $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
+    } else {
+        $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1);
+        $result.=&problem_edit_action_button('subundo','undo','u','Undo',1);
+    }
+    $result.="\n</div>";
+# Buttons that save
+    $result.='<div class="LC_edit_problem_saves">';
+    if ($mode eq 'editxml') {
+        $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML');
+        $result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View');
+    } else {
+        $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit');
+        $result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View');
+    }
+    $result.="\n</div>\n";
+    return $result;
 }
 
 sub problem_edit_header {
-    return '<input type="hidden" name="submitted" value="edit" /><input type="hidden" name="problemmode" value="edit" />'.
-	&Apache::structuretags::remember_problem_state().'
+    return '<input type="hidden" name="submitted" value="edit" />'.
+	&remember_problem_state('edit').'
 <div class="LC_edit_problem_header">
 <div class="LC_edit_problem_header_title">
 '.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').'
 </div>'.
+'<input type="hidden" name="problemmode" value="saveedit" />'.
 &problem_edit_buttons().'
 <hr style="clear:both;" />
 '.&Apache::lonxml::message_location().'
@@ -1276,7 +1305,7 @@
 		} else {
 		    $frontmatter.= $begin_doc.$toc_line;
 		    if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { 
-			$frontmatter .= '\fbox{\textit{'.$weight.' pt}}';
+			$frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
 		    }
 		}
 	    } else {
@@ -1286,7 +1315,7 @@
 	    if (not $env{'request.symb'} =~ m/\.page_/) {
 		$frontmatter .= $begin_doc.$toc_line;
 		if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { 
-		    $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';
+		    $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
 		}
 	    } else {
 		$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage;
@@ -1310,7 +1339,7 @@
 	    }
 	} elsif ( ($target eq 'web' || $target eq 'tex') &&
 		  $Apache::inputtags::part eq '0' &&
-		  $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') {
+		  $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') { 
 	    # if part is zero, no <part>s existed, so we need show the current
 	    # grading status
 	    my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target);
@@ -1320,8 +1349,8 @@
 	    (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
 	    ($target eq 'answer') || ($target eq 'tex')
 	   ) {
-	    if ($target ne 'tex' &&
-		$env{'form.answer_output_mode'} ne 'tex') {
+	    if (($target ne 'tex') &&
+		($env{'form.answer_output_mode'} ne 'tex')) {
 		$result.="</form>";
 	    }
 	    if ($target eq 'web') {
@@ -1970,7 +1999,7 @@
 			$allow_print_points=0;
 		    }
 		    if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { 
-			$result .= '\vskip 10mm\fbox{\textit{'.$weight.' pt}}';
+			$result .= '\vskip 10mm\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
 
 		    }
 		} elsif ($target eq 'web') {
@@ -2280,11 +2309,12 @@
 #              .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.')
 #              .&Apache::loncommon::help_open_topic('Caching')
 #              .'</p>';
-        $result.=&Apache::lonhtmlcommon::start_funclist()
+        $result.=&Apache::loncommon::head_subbox(
+                 &Apache::lonhtmlcommon::start_funclist()
                 .&Apache::lonhtmlcommon::add_item_funclist(
                      '<a href="'.$url.'/smpedit?symb='.&escape($symb).'">'
                     .&mt('Edit').'</a>')
-                .&Apache::lonhtmlcommon::end_funclist();
+                .&Apache::lonhtmlcommon::end_funclist());
 
     }
     return $result;




More information about the LON-CAPA-cvs mailing list