[LON-CAPA-cvs] cvs: loncom(loncapaMITrelate_1) /interface lonparmset.pm

raeburn raeburn at source.lon-capa.org
Mon Apr 30 09:26:37 EDT 2012


raeburn		Mon Apr 30 13:26:37 2012 EDT

  Modified files:              (Branch: loncapaMITrelate_1)
    /loncom/interface	lonparmset.pm 
  Log:
  - Customization for MITrelate
    - Backport 1.514 (part), 1.521.
  
  
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.505.2.1 loncom/interface/lonparmset.pm:1.505.2.1.2.1
--- loncom/interface/lonparmset.pm:1.505.2.1	Fri Oct  7 15:25:40 2011
+++ loncom/interface/lonparmset.pm	Mon Apr 30 13:26:37 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.505.2.1 2011/10/07 15:25:40 raeburn Exp $
+# $Id: lonparmset.pm,v 1.505.2.1.2.1 2012/04/30 13:26:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1265,6 +1265,7 @@
     function checkdisset() {
     checkthis('discussend','pscat');
      checkthis('discusshide','pscat');
+     checkthis('discussvote','pscat');
     }
 
     function checkcontdates() {
@@ -1403,6 +1404,7 @@
         'acc' => 'misc',
         'maxcollaborators' => 'misc',
         'scoreformat' => 'misc',
+        'discussvote'  => 'misc',
 
     );    
 }
@@ -1958,8 +1960,9 @@
         'parameter_0_tol' => 16,
         'parameter_0_sig' => 17,
         'parameter_0_turnoffunit' => 18,
-            'parameter_0_discussend' => 19,
-            'parameter_0_discusshide' => 20);
+        'parameter_0_discussend' => 19,
+        'parameter_0_discusshide' => 20,
+        'parameter_0_discussvote' => 21);
 }
 
 
@@ -2122,7 +2125,7 @@
         my ($got_chostname,$chostname,$cmajor,$cminor);
         my $totalstored = 0;
         for (my $i=0;$i<=$#markers;$i++) {
-            my ($needsrelease,$needsnewer);
+            my ($needsrelease,$needsnewer,$name);
             if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
                 my (@ok_slots, at fail_slots, at del_slots);
                 my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
@@ -2153,22 +2156,23 @@
                         }
                     }
                 }
-            } elsif ($markers[$i] =~ /_type\&\d+$/) {
+            } elsif ($markers[$i] =~ /_(type|discussvote)\&\d+$/) {
+                $name = $1;
                 $needsrelease =
-                    $Apache::lonnet::needsrelease{'parameter:type:'.$values[$i]};
+                    $Apache::lonnet::needsrelease{"parameter:$name:$values[$i]"};
                 if ($needsrelease) {
                     unless ($got_chostname) {
-                        ($chostname,$cmajor,$cminor) = &questiontype_release_vars();
+                        ($chostname,$cmajor,$cminor) = &parameter_release_vars();
                         $got_chostname = 1;
                     }
-                    $needsnewer = &questiontype_releasecheck($values[$i],
-                                                             $needsrelease,
-                                                             $chostname,
-                                                             $cmajor,$cminor);
+                    $needsnewer = &parameter_releasecheck($name,$values[$i],
+                                                          $needsrelease,
+                                                          $chostname,
+                                                          $cmajor,$cminor);
                 }
             }
             if ($needsnewer) {
-                $message .= &oldversion_warning($values[$i],$chostname,$cmajor,
+                $message .= &oldversion_warning($name,$values[$i],$chostname,$cmajor,
                                                 $cminor,$needsrelease);
             } else {
                 $message.=&storeparm(split(/\&/,$markers[$i]),
@@ -2793,25 +2797,32 @@
         $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
         }
         if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
-        my ($data, $typeof, $text);
+        my ($data, $typeof, $text, $name);
         if ($cmd eq 'set') {
             $data=$env{$key};
             $typeof=$env{'form.typeof_'.$thiskey};
             $text = &mt('Saved modified parameter for');
             if ($typeof eq 'string_questiontype') {
+                $name = $type;    
+            } elsif ($typeof eq 'string_discussvote') {
+                $name = 'discussvote';
+            }
+            if ($name ne '') {
                 my ($needsrelease,$needsnewer);
                 $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$data};
                 if ($needsrelease) {
                     unless ($got_chostname) {
-                        ($chostname,$cmajor,$cminor)=&questiontype_release_vars();
+                        ($chostname,$cmajor,$cminor)=&parameter_release_vars();
                         $got_chostname = 1;
                     }
-                    $needsnewer = &questiontype_releasecheck($data,$needsrelease,
-                                                             $chostname,$cmajor,
-                                                             $cminor);
+                    $needsnewer = &parameter_releasecheck($name,$data,
+                                                          $needsrelease,
+                                                          $chostname,$cmajor,
+                                                          $cminor);
                 }
                 if ($needsnewer) {
-                    $r->print('<br />'.&oldversion_warning($data,$chostname,$cmajor,
+                    $r->print('<br />'.&oldversion_warning($name,$data,
+                                                           $chostname,$cmajor,
                                                            $cminor,$needsrelease));
                     next;
                 }
@@ -3046,7 +3057,7 @@
                           $$resourcedata{$thiskey}));
         } elsif ($thistype =~ m/^string/) {
         $r->print(&string_selector($thistype,$thiskey,
-                       $$resourcedata{$thiskey}));
+                       $$resourcedata{$thiskey},$name));
         } else {
         $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
         }
@@ -3120,6 +3131,10 @@
                  [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
                  [ 'practice', 'Practice'],
                  [ 'surveycred', 'Survey (credit for submission)']],
+     'string_discussvote'
+             => [['yes','Yes'],
+                 ['notended','Yes, unless discussion ended'],
+                 ['no','No']],
      );
 
 sub standard_string_options {
@@ -3131,29 +3146,30 @@
 }
 
 sub string_selector {
-    my ($thistype, $thiskey, $showval) = @_;
+    my ($thistype, $thiskey, $showval, $name) = @_;
 
     if (!exists($strings{$thistype})) {
     return &default_selector($thiskey,$showval);
     }
 
     my %skiptype;
-    if ($thistype eq 'string_questiontype') {
+    if (($thistype eq 'string_questiontype') ||
+        ($thistype eq 'string_discussvote')) {
         my ($got_chostname,$chostname,$cmajor,$cminor); 
         foreach my $possibilities (@{ $strings{$thistype} }) {
             next unless (ref($possibilities) eq 'ARRAY');
-            my ($name, $description) = @{ $possibilities };
-            my $needsrelease=$Apache::lonnet::needsrelease{'parameter:type:'.$name};
+            my ($parmval, $description) = @{ $possibilities };
+            my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
             if ($needsrelease) {
                 unless ($got_chostname) {
-                    ($chostname,$cmajor,$cminor)=&questiontype_release_vars();
+                    ($chostname,$cmajor,$cminor)=&parameter_release_vars();
                     $got_chostname = 1;
                 }
-                my $needsnewer=&questiontype_releasecheck($name,$needsrelease,
-                                                          $chostname,$cmajor,
-                                                          $cminor);
+                my $needsnewer=&parameter_releasecheck($name,$parmval,$needsrelease,
+                                                       $chostname,$cmajor,
+                                                       $cminor);
                 if ($needsnewer) {
-                    $skiptype{$name} = 1;
+                    $skiptype{$parmval} = 1;
                 }
             }
         }
@@ -4555,7 +4571,7 @@
     return 0;
 }
 
-sub questiontype_release_vars { 
+sub parameter_release_vars { 
    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
    my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
    my $chostname = &Apache::lonnet::hostname($chome);
@@ -4564,35 +4580,42 @@
    return ($chostname,$cmajor,$cminor);
 }
 
-sub questiontype_releasecheck {
-    my ($questiontype,$needsrelease,$chostname,$cmajor,$cminor) = @_;
+sub parameter_releasecheck {
+    my ($name,$value,$needsrelease,$chostname,$cmajor,$cminor) = @_;
     my $needsnewer;
     my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
     if (($cmajor < $needsmajor) || 
         ($cmajor == $needsmajor && $cminor < $needsminor)) {
         $needsnewer = 1;
     } else {
-        &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:type:'.$questiontype});
+        &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
     }
     return $needsnewer;
 }
 
 sub oldversion_warning {
-    my ($questiontype,$chostname,$cmajor,$cminor,$needsrelease) = @_;
+    my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
     my $desc;
-    if (ref($strings{'string_questiontype'}) eq 'ARRAY') {
-        foreach my $possibilities (@{ $strings{'string_questiontype'} }) {
-            next unless (ref($possibilities) eq 'ARRAY');
-            my ($name, $description) = @{ $possibilities };
-            if ($name eq $questiontype) {
-                $desc = $description;
-                last;
+    my %stringtypes = (
+                        type         => 'string_questiontype',
+                        discussvote  => 'string_discussvote',
+                      );
+    if (exists($stringtypes{$name})) {
+        if (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
+            foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
+                next unless (ref($possibilities) eq 'ARRAY');
+                my ($parmval, $description) = @{ $possibilities };
+                if ($parmval eq $value) {
+                    $desc = $description;
+                    last;
+                }
             }
         }
     }
+    my $standard_name = &standard_parameter_names($name);
     return '<p class="LC_warning">'.
-           &mt('Question Type was [_1]not[_2] set to [_3].',
-           '<b>','</b>','"'.$desc.'"').'<br />'.
+           &mt('[_1] was [_2]not[_3] set to [_4].',
+               $standard_name,'<b>','</b>','"'.$desc.'"').'<br />'.
            &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
            $cmajor.'.'.$cminor,$chostname,
            $needsrelease).


More information about the LON-CAPA-cvs mailing list