[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonhtmlcommon.pm lonparmset.pm
raeburn
raeburn at source.lon-capa.org
Sun Aug 16 16:45:42 EDT 2015
raeburn Sun Aug 16 20:45:42 2015 EDT
Modified files:
/loncom/interface lonparmset.pm loncommon.pm lonhtmlcommon.pm
Log:
- Bug 5349: Parameter management by users with a section-specific role ...
- User can only modify parameters at a section level (for user's own section)
a group level, or at a user-level (for students in own section).
- When displaying the parameter log changes for students in other
sections, and for other sections are not shown.
- In overview mode, input elements for parameter-settings for "All students"
are disabled; parameters set for other sections and students in other
sections are not shown.
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.551 loncom/interface/lonparmset.pm:1.552
--- loncom/interface/lonparmset.pm:1.551 Sun May 10 01:02:35 2015
+++ loncom/interface/lonparmset.pm Sun Aug 16 20:45:41 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.551 2015/05/10 01:02:35 raeburn Exp $
+# $Id: lonparmset.pm,v 1.552 2015/08/16 20:45:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1269,6 +1269,8 @@
my $nolink = 0;
if ($which == 11 || $which == 12) {
$nolink = 1;
+ } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) {
+ $nolink = 1;
} elsif ($mprefix =~ /availablestudent\&$/) {
if ($which > 3) {
$nolink = 1;
@@ -1768,7 +1770,13 @@
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')" |;
@@ -1782,7 +1790,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">
@@ -1801,7 +1809,7 @@
// ]]>
</script>
|;
- } else {
+ } elsif ($currsec eq '') {
$sections .= qq|
<script type="text/javascript">
// <![CDATA[
@@ -1815,7 +1823,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 .= '>';
@@ -2044,8 +2052,16 @@
my %sectionhash = &Apache::loncommon::get_sections();
return if (!%sectionhash);
- $r->print('<select name="Section" multiple="multiple" size="8">');
- foreach my $s ('all',sort(keys(%sectionhash))) {
+ 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('<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) {
@@ -2197,6 +2213,10 @@
my $message='';
$csec=$env{'form.csec'};
+ if ($env{'request.course.sec'} ne '') {
+ $csec = $env{'request.course.sec'};
+ }
+
$cgroup=$env{'form.cgroup'};
if ($udom=$env{'form.udom'}) {
@@ -2323,6 +2343,9 @@
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] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
my (@ok_slots, at fail_slots, at del_slots);
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
@@ -2961,12 +2984,19 @@
my $tableopen;
sub tablestart {
+ my ($readonly) = @_;
if ($tableopen) {
- return '';
+ return '';
} else {
- $tableopen=1;
- return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
- &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
+ $tableopen=1;
+ my $output = &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th>';
+ if ($readonly) {
+ $output .= '<th>'.&mt('Current value').'</th>';
+ } else {
+ $output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>';
+ }
+ $output .= '</tr>';
+ return $output;
}
}
@@ -2999,7 +3029,11 @@
}
}
}
- return $resourcedata;
+ if (wantarray) {
+ return ($resourcedata,$classlist);
+ } else {
+ return $resourcedata;
+ }
}
@@ -3195,7 +3229,8 @@
}
sub listdata {
- my ($r,$resourcedata,$listdata,$sortorder)=@_;
+ my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist)=@_;
+
# Start list output
my $oldsection='';
@@ -3206,6 +3241,12 @@
my $foundkeys=0;
my %keyorder=&standardkeyorder();
+ my ($secidx,%grouphash);
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $secidx = &Apache::loncoursedata::CL_SECTION();
+ %grouphash = &Apache::longroup::coursegroups();
+ }
+
foreach my $thiskey (sort {
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
@@ -3247,22 +3288,43 @@
$result;
} keys(%{$listdata})) {
+ my $readonly;
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($stuname,$studom);
+ } 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/^\.+//;
@@ -3305,36 +3367,49 @@
# Ready to print
#
my $parmitem = &standard_parameter_names($name);
- $r->print(&tablestart().
+ $r->print(&tablestart($readonly).
&Apache::loncommon::start_data_table_row().
'<td><b>'.&mt($parmitem).
- '</b></td><td><input type="checkbox" name="del_'.
- $thiskey.'" /></td><td>');
+ '</b></td>');
+ unless ($readonly) {
+ $r->print('<td><input type="checkbox" name="del_'.
+ $thiskey.'" /></td>');
+ }
+ $r->print('<td>');
$foundkeys++;
if (&isdateparm($thistype)) {
- my $jskey='key_'.$pointer;
- $pointer++;
- $r->print(
- &Apache::lonhtmlcommon::date_setter('parmform',
- $jskey,
- $$resourcedata{$thiskey},
- '',1,'','').
+ my $jskey='key_'.$pointer;
+ my $state;
+ $pointer++;
+ if ($readonly) {
+ $state = 'disabled';
+ }
+ $r->print(
+ &Apache::lonhtmlcommon::date_setter('parmform',
+ $jskey,
+ $$resourcedata{$thiskey},
+ '',1,$state));
+ unless ($readonly) {
+ $r->print(
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
(($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
&mt('Shift all dates based on this date').'</a></span>':'').
&date_sanity_info($$resourcedata{$thiskey})
- );
+ );
+ }
} elsif ($thistype eq 'date_interval') {
- $r->print(&date_interval_selector($thiskey,
- $$resourcedata{$thiskey}));
+ $r->print(&date_interval_selector($thiskey,
+ $$resourcedata{$thiskey},$readonly));
} elsif ($thistype =~ m/^string/) {
- $r->print(&string_selector($thistype,$thiskey,
- $$resourcedata{$thiskey},$name));
+ $r->print(&string_selector($thistype,$thiskey,
+ $$resourcedata{$thiskey},$name,$readonly));
} else {
- $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
+ $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
+ }
+ unless ($readonly) {
+ $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
+ $thistype.'" />');
}
- $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
- $thistype.'" />');
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
}
}
@@ -3343,7 +3418,7 @@
sub date_interval_selector {
- my ($thiskey, $showval) = @_;
+ my ($thiskey, $showval, $readonly) = @_;
my $result;
foreach my $which (['days', 86400, 31],
['hours', 3600, 23],
@@ -3355,10 +3430,12 @@
my %select = ((map {$_ => $_} (0..$max)),
'select_form_order' => [0..$max]);
$result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
- \%select);
+ \%select,'',$readonly);
$result .= ' '.&mt($name);
}
- $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
+ unless ($readonly) {
+ $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
+ }
return $result;
}
@@ -3380,12 +3457,16 @@
sub default_selector {
- my ($thiskey, $showval) = @_;
- return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
+ my ($thiskey, $showval, $readonly) = @_;
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'"'.$disabled.' />';
}
sub string_ip_selector {
- my ($thiskey, $showval) = @_;
+ my ($thiskey, $showval, $readonly) = @_;
my %access = (
allow => [],
deny => [],
@@ -3411,6 +3492,12 @@
if (!@{$access{'deny'}}) {
@{$access{'deny'}} = ('');
}
+ my ($disabled,$addmore);
+ if ($disabled) {
+ $disabled=' disabled="disabled"';
+ } else {
+ $addmore = "\n".'<button class="LC_add_ipacc_button">'.&mt('Add more').'</button>';
+ }
my $output = '<input type="hidden" name="set_'.$thiskey.'" />
<table><tr><th>'.&mt('Allow from').'</th><th>'.&mt('Deny from').'</th></tr><tr>';
foreach my $acctype ('allow','deny') {
@@ -3420,7 +3507,7 @@
<div class="LC_string_ipacc_inner">'."\n";
my $num = 0;
foreach my $curr (@{$access{$acctype}}) {
- $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'" />';
+ $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'"'.$disabled.' />';
if ($num > 0) {
$output .= '<a href="#" class="LC_remove_ipacc">'.&mt('Remove').'</a>';
}
@@ -3428,8 +3515,7 @@
$num ++;
}
$output .= '
- </div>
-<button class="LC_add_ipacc_button">'.&mt('Add more').'</button>
+ </div>'.$addmore.'
</div>
</td>';
}
@@ -3515,10 +3601,10 @@
}
sub string_selector {
- my ($thistype, $thiskey, $showval, $name) = @_;
+ my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
if (!exists($strings{$thistype})) {
- return &default_selector($thiskey,$showval);
+ return &default_selector($thiskey,$showval,$readonly);
}
my %skiptype;
@@ -3563,10 +3649,14 @@
}
if ($thistype eq 'string_ip') {
- return &string_ip_selector($thiskey,$showval);
+ return &string_ip_selector($thiskey,$showval,$readonly);
}
- my $result;
+ my ($result,$disabled);
+
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
my $numinrow = 3;
if ($thistype eq 'string_problemstatus') {
$numinrow = 2;
@@ -3631,7 +3721,7 @@
foreach my $reltype ('corrchkd','corrunchkd','incorrchkd','incorrunchkd') {
$add .= '<tr><td> </td><td>'.$relatives{$reltype}.'</td>'."\n".
'<td><input type="text" name="settext_'.$thiskey.'"'.
- ' value="'.$textval{$reltype}.'" size="3" />'.
+ ' value="'.$textval{$reltype}.'" size="3"'.$disabled.' />'.
'</td></tr>';
}
$add .= '</table></div>'."\n";
@@ -3642,7 +3732,7 @@
$result .= '<td class="LC_left_item"'.$colspan.'>'.
'<span class="LC_nobreak"><label>'.
'<input type="radio" name="set_'.$thiskey.
- '" value="'.$name.'"'.$onchange.$css_class;
+ '" value="'.$name.'"'.$onchange.$css_class.$disabled;
if ($showval eq $name) {
$result .= ' checked="checked"';
}
@@ -3818,6 +3908,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');
@@ -3900,7 +3993,7 @@
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder);
+ &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview');
}
$r->print(&tableend().
((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
@@ -3974,7 +4067,7 @@
# Read modified data
- my $resourcedata=&readdata($crs,$dom);
+ my ($resourcedata,$classlist)=&readdata($crs,$dom);
my $sortorder=$env{'form.sortorder'};
@@ -3983,7 +4076,7 @@
# List data
- my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
+ my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist);
$r->print(&tableend().'<p>'.
($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':'<span class="LC_info">'.&mt('There are no parameters.').'</span>').'</p></form>'.
&Apache::loncommon::end_page());
@@ -4937,6 +5030,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; }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1227 loncom/interface/loncommon.pm:1.1228
--- loncom/interface/loncommon.pm:1.1227 Sun Aug 9 21:43:18 2015
+++ loncom/interface/loncommon.pm Sun Aug 16 20:45:41 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1227 2015/08/09 21:43:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.1228 2015/08/16 20:45:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2271,12 +2271,16 @@
#-------------------------------------------
sub select_form {
- my ($def,$name,$hashref,$onchange) = @_;
+ my ($def,$name,$hashref,$onchange,$readonly) = @_;
return unless (ref($hashref) eq 'HASH');
if ($onchange) {
$onchange = ' onchange="'.$onchange.'"';
}
- my $selectform = "<select name=\"$name\" size=\"1\"$onchange>\n";
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ my $selectform = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n";
my @keys;
if (exists($hashref->{'select_form_order'})) {
@keys=@{$hashref->{'select_form_order'}};
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.368 loncom/interface/lonhtmlcommon.pm:1.369
--- loncom/interface/lonhtmlcommon.pm:1.368 Fri Jul 17 19:11:06 2015
+++ loncom/interface/lonhtmlcommon.pm Sun Aug 16 20:45:41 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.368 2015/07/17 19:11:06 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.369 2015/08/16 20:45:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -673,7 +673,7 @@
my $minuteselector = qq{<input type="text" name="$dname\_minute" $special $state value="$min" size="3" />};
my $secondselector= qq{<input type="text" name="$dname\_second" $special $state value="$sec" size="3" />};
my $cal_link;
- if (!$nolink) {
+ unless (($nolink) || ($state eq 'disabled')) {
$cal_link = qq{<a href="javascript:$dname\_opencalendar()">};
}
#
@@ -700,7 +700,7 @@
$hourselector,$minuteselector,$secondselector).
$tzone;
}
- if (!$nolink) {
+ unless (($nolink) || ($state eq 'disabled')) {
$result .= &mt('[_1]Select Date[_2]',$cal_link,'</a>');
}
$result .= "</span>\n<!-- end $dname date setting form -->\n";
More information about the LON-CAPA-cvs
mailing list