+
');
}
@@ -577,21 +766,26 @@ sub display_threshold_config {
foreach my $type (@thresholditems) {
my $parameter = $env{'request.course.id'}.':threshold_'.$type;
# onchange is javascript to automatically check the 'Set' button.
- my $onchange = 'onFocus="javascript:window.document.forms'.
+ my $onchange = 'onfocus="javascript:window.document.forms'.
"['thresholdform'].elements['".$parameter."_setparmval']".
'.checked=true;"';
+ my $aria_textbox = ' aria-label="'.&mt('Threshold value for [_1]',
+ $threshold_titles{$type}).'"';
+ my $aria_checkbox = ' aria-label="'.&mt('Change threshold value for [_1]',
+ $threshold_titles{$type}).'"';
$r->print(&Apache::loncommon::start_data_table_row()."\n".
'
'."\n".
&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table()."\n".
- '
+ '
');
@@ -611,6 +805,8 @@ sub display_interval_config {
$setting = 'oldroleinterval';
} elsif ($context eq 'newroles') {
$setting = 'newroleinterval';
+ } elsif ($context eq 'sessions') {
+ $setting = 'sessionactivity';
}
my $lctype = lc(&Apache::loncommon::course_type());
my $current = &get_current($env{'user.name'},$env{'user.domain'},
@@ -619,6 +815,10 @@ sub display_interval_config {
$r->print(' '.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').' ');
} elsif ($context eq 'newroles') {
$r->print(' '.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').' ');
+ } elsif ($context eq 'crslogin') {
+ $r->print(' '.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).' ');
+ } elsif ($context eq 'sessions') {
+ $r->print(' '.&mt('Choose the time limit to use to display active user sessions in the '.$lctype.'.').' ');
} else {
$r->print(' '.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').' ');
}
@@ -634,12 +834,19 @@ sub display_interval_config {
'.
&mt('Display:').'
-
');
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'.$lt{'noer'}.'
');
}
@@ -1493,7 +1882,7 @@ sub display_haserrors {
}
sub display_abovethreshold {
- my ($r,$refpage,$warnings,$triggered,$res_title) = @_;
+ my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$checkallowed) = @_;
my %lt = &Apache::lonlocal::texthash(
reso => 'Resource',
part => 'Part',
@@ -1507,16 +1896,16 @@ sub display_abovethreshold {
);
if (@{$warnings} > 0) {
@{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
- $r->print('');
+ if ($checkallowed->{'resetcounters'}) {
+ $r->print('
');
+ }
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'.$lt{'nopr'}.'
');
}
}
sub display_versionchanges {
- my ($r,$changed,$res_title,$interval) = @_;
+ my ($r,$changed,$res_title,$interval,$itemserror) = @_;
my %lt = &Apache::lonlocal::texthash(
'reso' => 'Resource',
'revd' => 'Last revised',
@@ -1582,6 +1975,8 @@ sub display_versionchanges {
$$changed{$item}{'current'}.'
'.
$$changed{$item}{'version'}.'
');
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'
.&mt('No '.$interval).'
');
@@ -1590,7 +1985,7 @@ sub display_versionchanges {
}
sub display_rolechanges {
- my ($r,$chgcount,$changed,$interval,$crstype) = @_;
+ my ($r,$chgcount,$changed,$interval,$crstype,$classlist) = @_;
my $now = time();
my %lt = &Apache::lonlocal::texthash(
'user' => 'User',
@@ -1609,6 +2004,7 @@ sub display_rolechanges {
if (ref($changed) eq 'HASH') {
my @changes = sort { $b <=> $a } (keys(%{$changed}));
my $changenum = 0;
+ my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
foreach my $item (@changes) {
if (ref($changed->{$item}) eq 'ARRAY') {
foreach my $chg (@{$changed->{$item}}) {
@@ -1626,8 +2022,14 @@ sub display_rolechanges {
my $udom = $chg->{'udom'};
$changenum ++;
my $css_class = $changenum%2?' class="LC_odd_row"':'';
+ my $fullname;
+ if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
+ $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
+ } else {
+ $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
+ }
my $link =
- &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
+ &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
$r->print('
'.
'
'.&Apache::lonlocal::locallocaltime($item).'
'.
'
'.$link.'
'.
@@ -1645,9 +2047,114 @@ sub display_rolechanges {
}
return;
}
-
+
+sub display_activity {
+ my ($r,$context,$count,$details,$interval,$crstype,$classlist) = @_;
+ return unless (ref($classlist) eq 'HASH');
+ my %lt = &Apache::lonlocal::texthash(
+ 'user' => 'User',
+ 'role' => 'Role',
+ 'sec' => 'Section',
+ 'number' => 'Total number of logins',
+ );
+ my $prefix = 'login';
+ if ($context eq 'sessions') {
+ $lt{'number'} = &mt('Total number of active user sessions');
+ $lt{'active'} = &mt('Last active');
+ $prefix = 'session';
+ }
+ if ($count) {
+
+ my $hdr = '
'.
+ '
'.$lt{'user'}.'
'.
+ '
'.$lt{'role'}.'
'.
+ '
'.$lt{'sec'}.'
';
+ if ($context eq 'sessions') {
+ $hdr .= '
'.$lt{'active'}.'
';
+ }
+ $hdr .= '
'."\n".
+ '
'.
+ '
'.$lt{'number'}.'
'.
+ '
'.$lt{'role'}.'
'.
+ '
'.$lt{'sec'};
+ my (%bylastname,%counts);
+ if (ref($details) eq 'HASH') {
+ my @items = sort { $b <=> $a } (keys(%{$details}));
+ my $num = 0;
+ my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
+ foreach my $item (@items) {
+ if (ref($details->{$item}) eq 'ARRAY') {
+ foreach my $user (@{$details->{$item}}) {
+ if (ref($user) eq 'HASH') {
+ my $section;
+ my $role =
+ &Apache::lonnet::plaintext($user->{'role'},$crstype);
+ if ($user->{'section'} eq '') {
+ $section = &mt('none');
+ } else {
+ $section = $user->{'section'};
+ }
+ $counts{$user->{'role'}}{$section} ++;
+ my $uname = $user->{'uname'};
+ my $udom = $user->{'udom'};
+ my $fullname;
+ if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
+ $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
+ } else {
+ $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
+ }
+ my $link =
+ &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
+ my $entry = '
'.$link.'
'.
+ '
'.$role.'
'.
+ '
'.$section.'
';
+ if ($context eq 'sessions') {
+ $entry .= '
'.&Apache::lonlocal::locallocaltime($item).'
';
+ }
+ push(@{$bylastname{$fullname}},$entry);
+ }
+ }
+ }
+ }
+ my $table;
+ foreach my $person (sort(keys(%bylastname))) {
+ if (ref($bylastname{$person}) eq 'ARRAY') {
+ foreach my $item (@{$bylastname{$person}}) {
+ $num ++;
+ my $css_class = $num%2?' class="LC_odd_row"':'';
+ $table .= '
'.$item.'
';
+ }
+ }
+ }
+ my $numrow = 0;
+ foreach my $role (sort(keys(%counts))) {
+ my $showrole = &Apache::lonnet::plaintext($role,$crstype);
+ if (ref($counts{$role}) eq 'HASH') {
+ foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) {
+ $numrow ++;
+ my $css_class = $numrow%2?' class="LC_odd_row"':'';
+ $table .= '
');
+ }
+ return;
+}
+
sub display_coursediscussion {
- my ($r,$newdiscussions,$unread,$countunread,$res_title) = @_;
+ my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
my $lctype = lc(&Apache::loncommon::course_type());
my %lt = &Apache::lonlocal::texthash(
'loca' => 'Location',
@@ -1675,9 +2182,9 @@ sub display_coursediscussion {
my $forum_title = $$unread{$ressymb}{'title'};
my $type = 'Resource';
my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
- my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb};
+ my $disclink = $feedurl.'?symb='. &escape($$unread{$ressymb}{symb});
if ($feedurl =~ /bulletinboard/) {
- $type = 'Bulletin Board';
+ $type = 'Discussion Board';
}
if ($$unread{$ressymb}{'enclink'}) {
$disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
@@ -1695,6 +2202,8 @@ sub display_coursediscussion {
}
$r->print("\n");
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'.$lt{'noun'}.'
');
}
@@ -1804,6 +2313,10 @@ sub store_interval_setting {
$interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
} elsif ($context eq 'newroles') {
$interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
+ } elsif ($context eq 'crslogin') {
+ $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
+ } elsif ($context eq 'sessions') {
+ $interval_settings{$cid.':sessionactivity'} = $env{'form.interval'};
} else {
$interval_settings{$cid.':interval'} = $env{'form.interval'};
}
@@ -1811,19 +2324,19 @@ sub store_interval_setting {
\%interval_settings,$udom,$uname);
if ($outcome eq 'ok') {
if (ref($interval_titles->{$context}) eq 'HASH') {
- $result = &mt('New filter setting: [_1].',''.
- $interval_titles->{$context}->{$env{'form.interval'}}.'').' ';
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].',''.
+ $interval_titles->{$context}->{$env{'form.interval'}}.'').' ');
}
} else {
my $lctype = lc(&Apache::loncommon::course_type());
&Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
- $result = &mt('Unable to set interval to [_1] due to [_2].',
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
''.$interval_titles->{$context}->{$env{'form.interval'}}.'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_discussion_setting {
@@ -1835,20 +2348,20 @@ sub store_discussion_setting {
my $outcome = &Apache::lonnet::put('nohist_whatsnew',
\%discussion_settings,$udom,$uname);
if ($outcome eq 'ok') {
- $result = &mt('Count unread posts in discussions display set to [_1]',
- ''.&mt($env{'form.countunread'}).'').' ';
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
+ ''.&mt($env{'form.countunread'}).'').' ');
} else {
my $lctype = lc(&Apache::loncommon::course_type());
&Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
- $result = &mt('Unable to set "number unread posts display" to [_1]'.
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
' due to [_2].',
''.&mt($env{'form.countunread'}).'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_courseinit_setting {
@@ -1873,27 +2386,29 @@ sub store_courseinit_setting {
\%courseinit_settings,$udom,$uname);
if ($outcome eq 'ok') {
if ($page_control eq 'global preferences') {
- $result = &mt("Page displayed after role selection in $lctype now set by user's global preferences.");
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'',''));
} else {
- $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_2]',$lctype,$$initpage{$env{'form.courseinit_page'}});
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
+ ,''.$$initpage{$env{'form.courseinit_page'}}.''));
}
} else {
&Apache::lonnet::logthis('Error saving whatsnew courseinit '.
'setting: '.$outcome.' for '.$uname.
':'.$udom.' in '.$lctype.' '.$cid);
if ($page_control eq 'global preferences') {
- $result = &mt('Unable to set control of page display to [_1]'.
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
' due to [_2].',
''.$page_control.'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
} else {
- $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_2] due to [_3]. ',
- $$initpage{$env{'form.courseinit_page'}},$outcome);
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
+ ,''.$$initpage{$env{'form.courseinit_page'}}.''
+ ,''.$outcome.''),1);
}
}
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub start_box {
@@ -1925,38 +2440,52 @@ sub start_box {
if ($$show{$caller}) {
$r->print('