[LON-CAPA-cvs] cvs: loncom /html/adm/helper parameter.helper /interface lonhelper.pm lonparmset.pm
raeburn
raeburn at source.lon-capa.org
Fri Aug 28 18:45:12 EDT 2015
raeburn Fri Aug 28 22:45:12 2015 EDT
Modified files:
/loncom/interface lonparmset.pm lonhelper.pm
/loncom/html/adm/helper parameter.helper
Log:
- Bug 5349
- Users with mdg priv (i.e., Course Coordinators) can set/delete/display
any group-level parameters in the course.
- Users without mdg priv (i.e., Instructors) can only set/delete/display
group-level parameters for groups to which they belong.
- Can also display group-level parameters for a specific resource or
map (from Content Settings in Functions menu when viewing resource)
for any group in the course, but can only set/modify/delete those
for groups to which they belong.
- When parameter helper is used by a user without mdg priv in course
(i.e., Instructor) changes may only be made for groups to which user
belongs.
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.552 loncom/interface/lonparmset.pm:1.553
--- loncom/interface/lonparmset.pm:1.552 Sun Aug 16 20:45:41 2015
+++ loncom/interface/lonparmset.pm Fri Aug 28 22:44:59 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.552 2015/08/16 20:45:41 raeburn Exp $
+# $Id: lonparmset.pm,v 1.553 2015/08/28 22:44:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1138,10 +1138,11 @@
sub print_row {
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
- $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
+ $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp)=@_;
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
+
# get the values for the parameter in cascading order
# empty levels will remain empty
my ($result, at outpar)=&parmval($$part{$which}.'.'.$$name{$which},
@@ -1184,7 +1185,7 @@
if ($uname) {
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
} elsif ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
} elsif ($csec) {
&print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
} else {
@@ -1195,7 +1196,7 @@
if ($uname) {
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
} elsif ($cgroup) {
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
} elsif ($csec) {
&print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
} else {
@@ -1232,9 +1233,9 @@
}
if ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
}
if ($uname) {
@@ -1263,7 +1264,7 @@
}
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp)=@_;
$r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
';" align="center">');
my $nolink = 0;
@@ -1271,6 +1272,10 @@
$nolink = 1;
} elsif (($env{'request.course.sec'} ne '') && ($which > 9)) {
$nolink = 1;
+ } elsif ($which == 4 || $which == 5 || $which == 6) {
+ if ($noeditgrp) {
+ $nolink = 1;
+ }
} elsif ($mprefix =~ /availablestudent\&$/) {
if ($which > 3) {
$nolink = 1;
@@ -1756,7 +1761,7 @@
}
sub usermenu {
- my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
+ my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_;
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
&Apache::loncommon::selectstudent_link('parmform','uname','udom');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
@@ -1765,7 +1770,12 @@
my %sectionhash = &Apache::loncommon::get_sections();
my $groups;
- my %grouphash = &Apache::longroup::coursegroups();
+ my %grouphash;
+ if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
+ }
my $g_s_header='';
my $g_s_footer='';
@@ -2048,9 +2058,9 @@
sub sectionmenu {
- my ($r,$selectedsections)=@_;
+ my ($selectedsections)=@_;
my %sectionhash = &Apache::loncommon::get_sections();
- return if (!%sectionhash);
+ return '' if (!%sectionhash);
my (@possibles,$disabled);
if ($env{'request.course.sec'} ne '') {
@@ -2060,40 +2070,40 @@
} else {
@possibles = ('all',sort(keys(%sectionhash)));
}
- $r->print('<select name="Section" multiple="multiple" size="8"'.$disabled.'>');
+ my $output = '<select name="Section" multiple="multiple" size="8"'.$disabled.'>';
foreach my $s (@possibles) {
- $r->print(' <option value="'.$s.'"');
- foreach my $sec (@{$selectedsections}) {
- if ($s eq $sec) {
- $r->print(' selected="selected"');
- last;
- }
+ $output .= ' <option value="'.$s.'"';
+ if ((@{$selectedsections}) && (grep(/^\Q$s\E$/,@{$selectedsections}))) {
+ $output .= ' selected="selected"';
}
- $r->print('>'.$s."</option>\n");
+ $output .= '>'."$s</option>\n";
}
- $r->print("</select>\n");
+ $output .= "</select>\n";
+ return $output;
}
sub groupmenu {
- my ($r,$selectedgroups)=@_;
- my %grouphash = &Apache::longroup::coursegroups();
- return if (!%grouphash);
+ my ($selectedgroups)=@_;
+ my %grouphash;
+ if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
+ }
+ return '' if (!%grouphash);
- $r->print('<select name="Group" multiple="multiple" size="8">');
+ my $output = '<select name="Group" multiple="multiple" size="8">';
foreach my $group (sort(keys(%grouphash))) {
- $r->print(' <option value="'.$group.'"');
- foreach my $grp (@{$selectedgroups}) {
- if ($group eq $grp) {
- $r->print(' selected="selected"');
- last;
- }
+ $output .= ' <option value="'.$group.'"';
+ if ((@{$selectedgroups}) && (grep(/^\Q$group\E$/,\@{$selectedgroups}))) {
+ $output .= ' selected="selected"';
}
- $r->print('>'.$group."</option>\n");
+ $output .= '>'."$group</option>\n";
}
- $r->print("</select>\n");
+ $output .= "</select>\n";
+ return $output;
}
-
sub keysplit {
my $keyp=shift;
return (split(/\,/,$keyp));
@@ -2217,7 +2227,17 @@
$csec = $env{'request.course.sec'};
}
+# Check group privs.
$cgroup=$env{'form.cgroup'};
+ my $noeditgrp;
+ if ($cgroup ne '') {
+ unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ if (($env{'request.course.groups'} eq '') ||
+ (!grep(/^\Q$cgroup\E$/,split(/,/,$env{'request.course.groups'})))) {
+ $noeditgrp = 1;
+ }
+ }
+ }
if ($udom=$env{'form.udom'}) {
} elsif ($udom=$env{'request.role.domain'}) {
@@ -2346,6 +2366,9 @@
if (($env{'request.course.sec'} ne '') && ($markers[$i] =~ /\&(7|8|9)$/)) {
next if ($csec ne $env{'request.course.sec'});
}
+ if ($markers[$i] =~ /\&(6|5|4)$/) {
+ next if ($noeditgrp);
+ }
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);
@@ -2509,7 +2532,7 @@
# Step 3
$r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
$r->print(&Apache::lonhtmlcommon::start_pick_box());
- &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
+ &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
@@ -2541,7 +2564,7 @@
'<br />');
$r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
$r->print(&Apache::lonhtmlcommon::start_pick_box());
- &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
+ &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print('<p>'
@@ -2753,7 +2776,7 @@
&print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$defbgthree,$parmlev,$uname,$udom,$csec,
- $cgroup,\@usersgroups);
+ $cgroup,\@usersgroups,$noeditgrp);
}
}
}
@@ -2875,7 +2898,7 @@
$r->print(&Apache::loncommon::start_data_table_row());
&print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,$defbgthree,
- $parmlev,$uname,$udom,$csec,$cgroup);
+ $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp);
}
$r->print(&Apache::loncommon::end_data_table().'</p>'
.'</div>'
@@ -2965,7 +2988,7 @@
$r->print(&Apache::loncommon::start_data_table_row());
&print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,$defbgthree,
- $parmlev,$uname,$udom,$csec,$cgroup);
+ $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp);
}
$r->print(&Apache::loncommon::end_data_table()
.'</p>'
@@ -3244,7 +3267,11 @@
my ($secidx,%grouphash);
if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
$secidx = &Apache::loncoursedata::CL_SECTION();
- %grouphash = &Apache::longroup::coursegroups();
+ if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
+ }
}
foreach my $thiskey (sort {
@@ -3950,16 +3977,26 @@
&displaymenu($r,\%allparms,\@pscat,\%keyorder);
$r->print(&Apache::lonhtmlcommon::start_pick_box());
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
+ my $sectionselector = §ionmenu(\@selected_sections);
+ my $groupselector = &groupmenu(\@selected_groups);
$r->print('<table>'.
- '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
- '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
+ '<tr><th>'.&mt('Parts').'</th>');
+ if ($sectionselector) {
+ $r->print('<th>'.&mt('Section(s)').'</th>');
+ }
+ if ($groupselector) {
+ $r->print('<th>'.&mt('Group(s)').'</th>');
+ }
+ $r->print('</tr><tr><td>');
&partmenu($r,\%allparts,\@psprt);
- $r->print('</td><td>');
- §ionmenu($r,\@selected_sections);
- $r->print('</td><td>');
- &groupmenu($r,\@selected_groups);
- $r->print('</td></tr></table>');
- #$r->print('</td></tr></table>');
+ $r->print('</td>');
+ if ($sectionselector) {
+ $r->print('<td>'.$sectionselector.'</td>');
+ }
+ if ($groupselector) {
+ $r->print('<td>'.$groupselector.'</td>');
+ }
+ $r->print('</tr></table>');
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print('</div></div>');
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.196 loncom/interface/lonhelper.pm:1.197
--- loncom/interface/lonhelper.pm:1.196 Sun Aug 16 00:21:21 2015
+++ loncom/interface/lonhelper.pm Fri Aug 28 22:44:59 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.196 2015/08/16 00:21:21 raeburn Exp $
+# $Id: lonhelper.pm,v 1.197 2015/08/28 22:44:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3183,7 +3183,7 @@
"allowempty" and "nextstate", meaning what they do for most other
elements.
-also takes a boolean 'onlysections' whcih will restrict this to only
+also takes a boolean 'onlysections' which will restrict this to only
have sections and not include groups
=cut
@@ -3277,6 +3277,10 @@
"allowempty" and "nextstate", meaning what they do for most other
elements.
+also takes a boolean grouponly, which if true, will restrict choice to
+groups in which user is a member, unless user has the mdg priv in the course,
+in which case all groups will be possible choices. Defaults to false.
+
=cut
no strict;
@@ -3306,6 +3310,7 @@
$helper->declareVar($paramHash->{'variable'});
$paramHash->{'multichoice'} = $token->[2]{'multichoice'};
$paramHash->{'allowempty'} = $token->[2]{'allowempty'};
+ $paramHash->{'grouponly'} = $token->[2]{'grouponly'};
if (defined($token->[2]{'nextstate'})) {
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
}
@@ -3313,7 +3318,12 @@
# Populate the CHOICES element
my %choices;
- my %curr_groups = &Apache::longroup::coursegroups();
+ my %curr_groups;
+ if ((!$paramHash->{'grouponly'}) || (&Apache::lonnet::allowed('mdg',$Apache::lonnet::env{'request.course.id'}))) {
+ %curr_groups = &Apache::longroup::coursegroups();
+ } elsif ($Apache::lonnet::env{'request.course.groups'} ne '') {
+ map { $curr_groups{$_} = 1; } split(/,/,$Apache::lonnet::env{'request.course.groups'});
+ }
foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) {
push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
}
Index: loncom/html/adm/helper/parameter.helper
diff -u loncom/html/adm/helper/parameter.helper:1.21 loncom/html/adm/helper/parameter.helper:1.22
--- loncom/html/adm/helper/parameter.helper:1.21 Sun Aug 16 00:21:28 2015
+++ loncom/html/adm/helper/parameter.helper Fri Aug 28 22:45:11 2015
@@ -152,7 +152,7 @@
<choice computer="section" nextstate="CHOOSE_SECTION">
. . . for a particular <b>section</b></choice>
<condition>
- <clause>return 1 if (&Apache::longroup::coursegroups())</clause>
+ <clause>return 1 if (($env{'request.course.groups'} ne '') || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}) && (&Apache::longroup::coursegroups())))</clause>
<choice computer="group" nextstate="CHOOSE_GROUP">
. . . for a particular <b>group</b></choice>
</condition>
@@ -174,7 +174,7 @@
return &mt('Please select the group you wish to set the ' .
&{$helper->{DATA}->{'dateType'}}() .
' for:').'<br />';</eval>
- <group variable="GROUP_NAME" nextstate="FINISH" />
+ <group variable="GROUP_NAME" nextstate="FINISH" grouponly="1" />
</state>
More information about the LON-CAPA-cvs
mailing list