--- loncom/interface/lonparmset.pm 2010/01/30 17:35:10 1.492
+++ loncom/interface/lonparmset.pm 2012/05/01 15:54:49 1.505.2.1.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.492 2010/01/30 17:35:10 raeburn Exp $
+# $Id: lonparmset.pm,v 1.505.2.1.2.2 2012/05/01 15:54:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -248,37 +248,6 @@ Variables used (guessed by Jeremy):
=item parse_key()
-=item check_cloners() :
-
-Checks if new users included in list of allowed cloners
-are valid users. Replaces supplied list with
-cleaned list containing only users with valid usernames
-and domains.
-
-Inputs: $clonelist, $oldcloner
-where $clonelist is ref to array of requested cloners,
-and $oldcloner is ref to array of currently allowed
-cloners.
-
-Returns: string - comma separated list of requested
-cloners (username:domain) who do not exist in system.
-
-=item change_clone() :
-
-Modifies the list of courses a user can clone (stored
-in the user's environment.db file), called when a
-change is made to the list of users allowed to clone
-a course.
-
-Inputs: $action,$cloner
-where $action is add or drop, and $cloner is identity of
-user for whom cloning ability is to be changed in course.
-
-
-=item check_cloners()
-
-=item change_clone()
-
=item header()
Output html header for page
@@ -1245,8 +1214,9 @@ sub isdateparm {
}
#
-# This function prints a list of parameters, which were selected. It also display a link from which you can
-# hide or show the complete parameter list, from which you can choose your parameters.
+# parmmenu displays a list of the selected parameters.
+# It also offers a link to show/hide the complete parameter list
+# from which you can select all desired parameters.
#
sub parmmenu {
my ($r,$allparms,$pscat,$keyorder)=@_;
@@ -1295,6 +1265,7 @@ sub parmmenu {
function checkdisset() {
checkthis('discussend','pscat');
checkthis('discusshide','pscat');
+ checkthis('discussvote','pscat');
}
function checkcontdates() {
@@ -1321,6 +1292,8 @@ sub parmmenu {
checkdates();
checkthis('weight','pscat');
checkthis('maxtries','pscat');
+ checkthis('type','pscat');
+ checkthis('problemstatus','pscat');
}
function hideParms() {
@@ -1350,7 +1323,7 @@ ENDSCRIPT
$r->print(&mt('Selected Parameters:').' ');
#print out all possible parms and hide them by default
- $r->print('
'grading',
'maxtries' => 'tries',
'hinttries' => 'tries',
+ 'randomizeontries' => 'tries',
'type' => 'problem_appearance',
'problemstatus' => 'problem_appearance',
'display' => 'problem_appearance',
@@ -1430,6 +1404,7 @@ sub lookUpTableParameter {
'acc' => 'misc',
'maxcollaborators' => 'misc',
'scoreformat' => 'misc',
+ 'discussvote' => 'misc',
);
}
@@ -1716,13 +1691,13 @@ sub displaymenu {
}
sub mapmenu {
- my ($r,$allmaps,$pschp,$maptitles, $symbp)=@_;
+ my ($r,$allmaps,$pschp,$maptitles,$symbp)=@_;
my %allmaps_inverted = reverse %$allmaps;
my $navmap = Apache::lonnavmaps::navmap->new();
my $tree=[];
my $treeinfo={};
if (defined($navmap)) {
- my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
+ my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
my $curRes;
my $depth = 0;
my %parent = ();
@@ -1767,35 +1742,57 @@ sub mapmenu {
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"'));
if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {
my $icon = '';
- $r->print(&Apache::loncommon::start_data_table()
- .&Apache::loncommon::start_data_table_row()
- .'
'.$icon
- .'
'
- .&Apache::loncommon::end_data_table_row()
+ my $whitespace =
+ '';
+
+ # Info about selectable folders/maps
+ $r->print(
+ '
'
+ .&mt('You can only select maps and folders which have modifiable settings.')
+ .' '.&Apache::loncommon::help_open_topic('Parameter_Set_Folder')
+ .'
'
);
- my $whitespace = '';
+
+ $r->print(&Apache::loncommon::start_data_table());
+
+ # Display row: "All Maps or Folders"
+ $r->print(
+ &Apache::loncommon::start_data_table_row()
+ .'
';
}
return $result;
}
@@ -3503,123 +3645,6 @@ sub parse_key {
}
-
-sub extract_cloners {
- my ($clonelist,$allowclone) = @_;
- if ($clonelist =~ /,/) {
- @{$allowclone} = split(/,/,$clonelist);
- } else {
- $$allowclone[0] = $clonelist;
- }
-}
-
-sub check_cloners {
- my ($clonelist,$oldcloner) = @_;
- my ($clean_clonelist,%disallowed);
- my @allowclone = ();
- &extract_cloners($$clonelist,\@allowclone);
- foreach my $currclone (@allowclone) {
- if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
- if ($currclone eq '*') {
- $clean_clonelist .= $currclone.',';
- } else {
- my ($uname,$udom) = split(/:/,$currclone);
- if ($uname eq '*') {
- if ($udom =~ /^$match_domain$/) {
- if (!&Apache::lonnet::domain($udom)) {
- $disallowed{'domain'} .= $currclone.',';
- } else {
- $clean_clonelist .= $currclone.',';
- }
- } else {
- $disallowed{'format'} .= $currclone.',';
- }
- } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
- $disallowed{'format'} .= $currclone.',';
- } else {
- if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
- $disallowed{'newuser'} .= $currclone.',';
- } else {
- $clean_clonelist .= $currclone.',';
- }
- }
- }
- } else {
- $clean_clonelist .= $currclone.',';
- }
- }
- foreach my $key (keys(%disallowed)) {
- $disallowed{$key} =~ s/,$//;
- }
- if ($clean_clonelist) {
- $clean_clonelist =~ s/,$//;
- }
- $$clonelist = $clean_clonelist;
- return %disallowed;
-}
-
-sub change_clone {
- my ($clonelist,$oldcloner) = @_;
- my ($uname,$udom);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $clone_crs = $cnum.':'.$cdom;
-
- if ($cnum && $cdom) {
- my @allowclone;
- &extract_cloners($clonelist,\@allowclone);
- foreach my $currclone (@allowclone) {
- if (!grep(/^$currclone$/,@$oldcloner)) {
- if ($currclone ne '*') {
- ($uname,$udom) = split(/:/,$currclone);
- if ($uname && $udom && $uname ne '*') {
- if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
- my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
- if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
- if ($currclonecrs{'cloneable'} eq '') {
- $currclonecrs{'cloneable'} = $clone_crs;
- } else {
- $currclonecrs{'cloneable'} .= ','.$clone_crs;
- }
- &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
- }
- }
- }
- }
- }
- }
- foreach my $oldclone (@$oldcloner) {
- if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
- if ($oldclone ne '*') {
- ($uname,$udom) = split(/:/,$oldclone);
- if ($uname && $udom && $uname ne '*' ) {
- if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
- my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
- my %newclonecrs = ();
- if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
- if ($currclonecrs{'cloneable'} =~ /,/) {
- my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
- foreach my $crs (@currclonecrs) {
- if ($crs ne $clone_crs) {
- $newclonecrs{'cloneable'} .= $crs.',';
- }
- }
- $newclonecrs{'cloneable'} =~ s/,$//;
- } else {
- $newclonecrs{'cloneable'} = '';
- }
- &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
- }
- }
- }
- }
- }
- }
- }
-}
-
-
-
sub header {
return &Apache::loncommon::start_page('Parameter Manager');
}
@@ -3647,25 +3672,12 @@ ENDMAINFORMHEAD
my @menu =
( { categorytitle=>"Settings for this $crstype",
items => [
- { linktext => "$crstype Configuration",
- url => '/adm/courseprefs?origin=params',
- permission => $parm_permission,
- linktitle => "Edit $lc_crstype configuration." ,
- icon => 'preferences-desktop-remote-desktop.png' ,
- #help => 'Course_Environment',
- },
{ linktext => 'Portfolio Metadata',
url => '/adm/parmset?action=setrestrictmeta',
permission => $parm_permission,
linktitle => "Restrict metadata for this $lc_crstype." ,
icon =>'contact-new.png' ,
},
- { linktext => "Manage $crstype Slots",
- url => '/adm/slotrequest?command=showslots',
- permission => $vgr,
- linktitle => "Manage slots for this $lc_crstype." ,
- icon => 'rsrv.png' ,
- },
{ linktext => 'Reset Student Access Times',
url => '/adm/helper/resettimes.helper',
permission => $mgr,
@@ -4559,6 +4571,56 @@ sub check_for_course_info {
return 0;
}
+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);
+ my ($cmajor,$cminor) =
+ split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
+ return ($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:'.$name.':'.$value});
+ }
+ return $needsnewer;
+}
+
+sub oldversion_warning {
+ my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
+ my $desc;
+ 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 '
'.
+ &mt('[_1] was [_2]not[_3] set to [_4].',
+ $standard_name,'','','"'.$desc.'"').' '.
+ &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
+ $cmajor.'.'.$cminor,$chostname,
+ $needsrelease).
+ '