[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 07 Jul 2005 03:56:54 -0000


albertel		Wed Jul  6 23:56:54 2005 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  - most of BUG#4194, needed to
     - modify the 'level' value passed to take in account the changed ordering
       of the res/map defaults
     - need to pass more data to parmset to get it to enter table mode and set
       the parameter
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.103 loncom/interface/lonhelper.pm:1.104
--- loncom/interface/lonhelper.pm:1.103	Mon Apr 11 14:19:23 2005
+++ loncom/interface/lonhelper.pm	Wed Jul  6 23:56:52 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.103 2005/04/11 18:19:23 albertel Exp $
+# $Id: lonhelper.pm,v 1.104 2005/07/07 03:56:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3279,7 +3279,13 @@
     # Print the granularity, depending on the action
     if ($vars->{GRANULARITY} eq 'whole_course') {
         $resourceString .= '<li>'.&mt('for <b>all resources in the course</b>').'</li>';
-        $level = 9; # general course, see lonparmset.pm perldoc
+	if ($vars->{TARGETS} eq 'course') {
+	    $level = 11; # general course, see lonparmset.pm perldoc
+	} elsif ($vars->{TARGETS} eq 'section') {
+	    $level = 6;
+	} else {
+	    $level = 3;
+	}
         $affectedResourceId = "0.0";
         $symb = 'a';
         $paramlevel = 'general';
@@ -3289,7 +3295,13 @@
         my $title = $res->compTitle();
         $symb = $res->symb();
         $resourceString .= '<li>'.&mt('for the map named [_1]',"<b>$title</b>").'</li>';
-        $level = 8;
+	if ($vars->{TARGETS} eq 'course') {
+	    $level = 10; # general course, see lonparmset.pm perldoc
+	} elsif ($vars->{TARGETS} eq 'section') {
+	    $level = 5;
+	} else {
+	    $level = 2;
+	}
         $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'map';
     } else {
@@ -3300,22 +3312,31 @@
         $symb = $res->symb();
         my $title = $res->compTitle();
         $resourceString .= '<li>'.&mt('for the resource named [_1] part [_2]',"<b>$title</b>","<b>$part</b>").'</li>';
-        $level = 7;
+	if ($vars->{TARGETS} eq 'course') {
+	    $level = 7; # general course, see lonparmset.pm perldoc
+	} elsif ($vars->{TARGETS} eq 'section') {
+	    $level = 4;
+	} else {
+	    $level = 1;
+	}
         $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'full';
     }
 
     my $result = "<form name='helpform' method='get' action='/adm/parmset#$affectedResourceId&$parm_name&$level'>\n";
+    $result .= "<input type='hidden' name='action' value='settable' />\n";
+    $result .= "<input type='hidden' name='dis' value='helper' />\n";
+    $result .= "<input type='hidden' name='pscat' value='".
+	HTML::Entities::encode($vars->{ACTION_TYPE},"'<>&\"") . "' />\n";
     if ($vars->{GRANULARITY} eq 'resource') {
 	$result .= "<input type='hidden' name='symb' value='".
 	    HTML::Entities::encode($symb,"'<>&\"") . "' />\n";
-	$result .= "<input type='hidden' name='pscat' value='".
-	    HTML::Entities::encode($vars->{ACTION_TYPE},"'<>&\"") . "' />\n";
-	my $part = $vars->{RESOURCE_ID_part};
-	if ($part eq 'All Parts' || !$part) { $part=0; }
-	$result .= "<input type='hidden' name='psprt' value='".
-	    HTML::Entities::encode($part,"'<>&\"") . "' />\n";
     }
+    my $part = $vars->{RESOURCE_ID_part};
+    if ($part eq 'All Parts' || !$part) { $part=0; }
+    $result .= "<input type='hidden' name='psprt' value='".
+	HTML::Entities::encode($part,"'<>&\"") . "' />\n";
+
     $result .= '<p>'.&mt('Confirm that this information is correct, then click &quot;Finish Helper&quot; to complete setting the parameter.').'<ul>';
     
     # Print the type of manipulation:
@@ -3353,6 +3374,8 @@
     } elsif ($vars->{ACTION_TYPE} eq 'tries') {
 	$result .= "<input type='hidden' name='pres_value' " .
 	    "value='" . $vars->{TRIES} . "' />\n";
+        $result .= "<input type='hidden' name='pres_type' " .
+            "value='int_pos' />\n";
     } elsif ($vars->{ACTION_TYPE} eq 'weight') {
 	$result .= "<input type='hidden' name='pres_value' " .
 	    "value='" . $vars->{WEIGHT} . "' />\n";
@@ -3366,8 +3389,7 @@
     } elsif ($vars->{TARGETS} eq 'section') {
         my $section = $vars->{SECTION_NAME};
         $result .= '<li>'.&mt('for section [_1]',"<b>$section</b>").'</li>';
-        $level -= 3;
-        $result .= "<input type='hidden' name='csec' value='" .
+	$result .= "<input type='hidden' name='csec' value='" .
             HTML::Entities::encode($section,"'<>&\"") . "' />\n";
     } else {
         # FIXME: This is probably wasteful! Store the name!
@@ -3377,8 +3399,7 @@
         $username = substr($username, 0, rindex($username, ':'));
         my $name = $classlist->{$username}->[6];
         $result .= '<li>'.&mt('for [_1]',"<b>$name</b>").'</li>';
-        $level -= 6;
-        my ($uname, $udom) = split /:/, $vars->{USER_NAME};
+	my ($uname, $udom) = split /:/, $vars->{USER_NAME};
         $result .= "<input type='hidden' name='uname' value='".
             HTML::Entities::encode($uname,"'<>&\"") . "' />\n";
         $result .= "<input type='hidden' name='udom' value='".