[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonparmset.pm
raeburn
raeburn at source.lon-capa.org
Mon Sep 3 16:23:38 EDT 2018
raeburn Mon Sep 3 20:23:38 2018 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonparmset.pm
Log:
- For 2.11
Backport 1.552 (part), 1.553 (part), 1.585.
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.522.2.23 loncom/interface/lonparmset.pm:1.522.2.24
--- loncom/interface/lonparmset.pm:1.522.2.23 Sun Apr 2 13:39:05 2017
+++ loncom/interface/lonparmset.pm Mon Sep 3 20:23:37 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.522.2.23 2017/04/02 13:39:05 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522.2.24 2018/09/03 20:23:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1091,6 +1091,12 @@
} else {
if ($which == 11 || $which == 12) {
$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;
@@ -1584,7 +1590,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();
@@ -1593,12 +1599,23 @@
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='';
- if (%sectionhash) {
+ my $currsec = $env{'request.course.sec'};
+ if ($currsec) {
+ $sections=&mt('Section:').' '.$currsec;
+ if (%grouphash) {
+ $sections .= ';'.(' ' x2);
+ }
+ } elsif (%sectionhash && $currsec eq '') {
$sections=&mt('Section:').' <select name="csec"';
if (%grouphash && $parmlev ne 'full') {
$sections .= qq| onchange="group_or_section('csec')" |;
@@ -1612,7 +1629,7 @@
$sections.='</select>';
}
- if (%sectionhash && %grouphash && $parmlev ne 'full') {
+ if (%sectionhash && %grouphash && $parmlev ne 'full' && $currsec eq '') {
$sections .= ' '.&mt('or').' ';
$sections .= qq|
<script type="text/javascript">
@@ -1631,7 +1648,7 @@
// ]]>
</script>
|;
- } else {
+ } elsif ($currsec eq '') {
$sections .= qq|
<script type="text/javascript">
// <![CDATA[
@@ -1645,7 +1662,7 @@
if (%grouphash) {
$groups=&mt('Group:').' <select name="cgroup"';
- if (%sectionhash && $env{'form.action'} eq 'settable') {
+ if (%sectionhash && $env{'form.action'} eq 'settable' && $currsec eq '') {
$groups .= qq| onchange="group_or_section('cgroup')" |;
}
$groups .= '>';
@@ -1869,44 +1886,52 @@
sub sectionmenu {
- my ($r,$selectedsections)=@_;
+ my ($selectedsections)=@_;
my %sectionhash = &Apache::loncommon::get_sections();
- return if (!%sectionhash);
+ return '' if (!%sectionhash);
- $r->print('<select name="Section" multiple="multiple" size="8">');
- foreach my $s ('all',sort keys %sectionhash) {
- $r->print(' <option value="'.$s.'"');
- foreach (@{$selectedsections}) {
- if ($s eq $_) {
- $r->print(' selected="selected"');
- last;
- }
+ my (@possibles,$disabled);
+ if ($env{'request.course.sec'} ne '') {
+ @possibles = ($env{'request.course.sec'});
+ $selectedsections = [$env{'request.course.sec'}];
+ $disabled = ' disabled="disabled"';
+ } else {
+ @possibles = ('all',sort(keys(%sectionhash)));
}
- $r->print('>'.$s."</option>\n");
+ my $output = '<select name="Section" multiple="multiple" size="8"'.$disabled.'>';
+ foreach my $s (@possibles) {
+ $output .= ' <option value="'.$s.'"';
+ if ((@{$selectedsections}) && (grep(/^\Q$s\E$/,@{$selectedsections}))) {
+ $output .= ' selected="selected"';
+ }
+ $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 (@{$selectedgroups}) {
- if ($group eq $_) {
- $r->print(' selected="selected"');
- last;
+ $output .= ' <option value="'.$group.'"';
+ if ((@{$selectedgroups}) && (grep(/^\Q$group\E$/,\@{$selectedgroups}))) {
+ $output .= ' selected="selected"';
}
+ $output .= '>'.$group."</option>\n";
}
- $r->print('>'.$group."</option>\n");
- }
- $r->print("</select>\n");
+ $output .= "</select>\n";
+ return $output;
}
-
sub keysplit {
my $keyp=shift;
return (split(/\,/,$keyp));
@@ -2025,12 +2050,17 @@
my $message='';
$csec=$env{'form.csec'};
+ if ($env{'request.course.sec'} ne '') {
+ $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'})))) {
+ (!grep(/^\Q$cgroup\E$/,split(/:/,$env{'request.course.groups'})))) {
$noeditgrp = 1;
}
}
@@ -2152,9 +2182,14 @@
my ($got_chostname,$chostname,$cmajor,$cminor);
my $totalstored = 0;
my $now = time;
-
for (my $i=0;$i<=$#markers;$i++) {
my ($needsrelease,$needsnewer,$name);
+ 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);
@@ -2299,7 +2334,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());
@@ -2338,7 +2373,7 @@
($env{'form.psprt'}?' checked="checked"':'').' />'.
&mt('Show all parts').
'</label></td></tr>');
- &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>'
@@ -3029,6 +3064,16 @@
my $foundkeys=0;
my %keyorder=&standardkeyorder();
+ my ($secidx,%grouphash);
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $secidx = &Apache::loncoursedata::CL_SECTION();
+ 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 {
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
@@ -3071,25 +3116,46 @@
} keys %{$listdata}) {
if ($$listdata{$thiskey.'.type'}) {
- my $thistype=$$listdata{$thiskey.'.type'};
- if ($$resourcedata{$thiskey.'.type'}) {
- $thistype=$$resourcedata{$thiskey.'.type'};
+ my $thistype=$$listdata{$thiskey.'.type'};
+ if ($$resourcedata{$thiskey.'.type'}) {
+ $thistype=$$resourcedata{$thiskey.'.type'};
}
my ($middle,$part,$name)=
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
my $section=&mt('All Students');
if ($middle=~/^\[(.*)\]/) {
- my $issection=$1;
- if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
- $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
- } else {
- $section=&mt('Group/Section').': '.$issection;
- }
- $middle=~s/^\[(.*)\]//;
+ my $issection=$1;
+ if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
+ my ($stuname,$studom) = ($1,$2);
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ if (ref($classlist) eq 'HASH') {
+ if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') {
+ next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'});
+ }
+ }
+ }
+ $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
+ } else {
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ if (exists($grouphash{$issection})) {
+ $section=&mt('Group').': '.$issection;
+ } elsif ($issection eq $env{'request.course.sec'}) {
+ $section = &mt('Section').': '.$issection;
+ } else {
+ next;
+ }
+ } else {
+ $section=&mt('Group/Section').': '.$issection;
+ }
+ }
+ $middle=~s/^\[(.*)\]//;
+ } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $readonly = 1;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
+
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
$realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
} elsif ($middle) {
@@ -3448,6 +3514,9 @@
@selected_sections = ('all');
}
}
+ if ($env{'request.course.sec'} ne '') {
+ @selected_sections = ($env{'request.course.sec'});
+ }
my @selected_groups =
&Apache::loncommon::get_env_multiple('form.Group');
@@ -3487,16 +3556,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>');
@@ -4596,6 +4675,13 @@
!exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
+ if ($env{'request.course.sec'} ne '') {
+ next if (($issection ne '') && ($issection ne $env{'request.course.sec'}));
+ if ($uname ne '') {
+ my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'});
+ next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'}));
+ }
+ }
if ($env{'form.displayfilter'} eq 'currentfolder') {
if ($folder) {
if ($middle!~/^\Q$folder\E/) { next; }
More information about the LON-CAPA-cvs
mailing list