');
+ $r->print('');
my $displayed = 0;
my $totalboxes = 0;
@@ -533,14 +770,15 @@ sub display_actions_box {
$totalboxes ++;
}
}
- my $halfway = 4;
+ my $currcolumn = 'left';
# my $halfway = int($totalboxes/2) + $totalboxes%2;
foreach my $actionitem (@actionorder) {
- if ($$checkallowed{$actionitem}) {
- if ($displayed == $halfway) {
+ if ($checkallowed->{$actionitem}) {
+ if (($actioncolumn{$actionitem} eq 'right') && ($currcolumn eq 'left')) {
$r->print(' ');
+ $currcolumn = 'right';
}
- &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror);
+ &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror,\%loggedin,$logincount,\%sessions,$sessioncount,$classlist);
$displayed ++;
}
}
@@ -548,6 +786,7 @@ sub display_actions_box {
+
');
}
@@ -586,16 +825,21 @@ 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".
' '.$threshold_titles{$type}.' '."\n".
''.&Apache::lonhtmlcommon::textbox($parameter.'_value',
$threshold{$type},
- 10,$onchange).' '."\n".
+ 10,$onchange.$aria_textbox).''."\n".
''.
- &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
+ &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval',
+ '','',$aria_checkbox).
' '."\n".
&Apache::loncommon::end_data_table_row());
}
@@ -620,6 +864,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'},
@@ -628,6 +874,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.').' ');
}
@@ -643,12 +893,19 @@ sub display_interval_config {
'.
&mt('Display:').'
-
+
'.&mt('Select').'
');
if (ref($interval_titles) eq 'HASH') {
if (ref($interval_titles->{$context}) eq 'HASH') {
- foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})))) {
+ my @sorted;
+ if ($context eq 'sessions') {
+ @sorted = sort { $a <=> $b } (keys(%{$interval_titles->{$context}}));
+ push(@sorted,shift(@sorted));
+ } else {
+ @sorted = reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})));
+ }
+ foreach my $key (@sorted) {
$r->print(''.&mt($interval_titles->{$context}->{$key}).
' '."\n");
}
@@ -691,7 +948,7 @@ function toggle_countunread(choice) {
.' '
.&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'',' ')
.' '
- .&mt('Currently set to [_1].',''.$current.' .')
+ .&mt('Currently set to [_1].',''.$current.' ')
);
$r->print('
');
return;
}
@@ -793,10 +1053,11 @@ sub display_launcher {
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
$interval,$countunread,$expired,$expirecount,$activated,$activecount,
- $crstype,$itemserror) = @_;
+ $crstype,$itemserror,$loggedin,$logincount,$sessions,$sessioncount,
+ $classlist) = @_;
if ($$checkallowed{$action}) {
- &start_box($r,$show,$headings,$action,$refpage,$action);
+ &start_box($r,$show,$headings,$action,$refpage);
if ($$show{$action}) {
if ($action eq 'handgrading') { # UNGRADED ITEMS
&display_handgrade($r,$tograde,$ungraded,$itemserror);
@@ -806,7 +1067,7 @@ sub display_launcher {
&display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
} elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
&display_abovethreshold($r,$refpage,$warnings,$triggered,
- $res_title,$itemserror);
+ $res_title,$itemserror,$checkallowed);
} elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
&display_coursediscussion($r,$newdiscussions,$unread,
$countunread,$res_title,$itemserror);
@@ -816,10 +1077,16 @@ sub display_launcher {
&display_coursecritmail($r,$critmsgcount,$critmsgs);
} elsif ($action eq 'newroles') { # ACTIVATED ROLES
&display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
- $crstype);
+ $crstype,$classlist);
} elsif ($action eq 'oldroles') { # EXPIRED ROLES
&display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
- $crstype);
+ $crstype,$classlist);
+ } elsif ($action eq 'crslogin') { #LAST LOGIN
+ &display_activity($r,'logins',$logincount,$loggedin,$interval->{'crslogin'},
+ $crstype,$classlist);
+ } elsif ($action eq 'sessions') { #ACTIVE SESSIONS
+ &display_activity($r,'sessions',$sessioncount,$sessions,$interval->{'sessions'},
+ $crstype,$classlist);
}
}
&end_box($r);
@@ -830,7 +1097,7 @@ sub display_launcher {
sub getitems {
my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
$tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
- $starttime,$countunread) = @_;
+ $starttime,$countunread,$checkallowed) = @_;
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
my $itemserror = ''.&mt('An error occurred retrieving information about the course.').' '.&mt('It is recommended that you [_1]re-select the course[_2].','',' ').' ';
@@ -890,9 +1157,9 @@ sub getitems {
# Maxtries and degree of difficulty for problem parts, unless handgradeable
if ($$show{'abovethreshold'}) {
&check_thresholds($resource,$symb,\%resourcetracker,
- $triggered,$threshold,$warnings);
+ $triggered,$threshold,$warnings,
+ $checkallowed);
}
-
}
return;
}
@@ -923,12 +1190,28 @@ sub check_discussions {
sub check_handgraded {
my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
if ($resource->is_problem()) {
- my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
+ my ($handgradeable,$is_task);
my $partlist=$resource->parts();
- my $handgradeable;
- foreach my $part (@$partlist) {
- if ($resource->handgrade($part) eq 'yes') {
- $handgradeable=1; last;
+ if ($resource->is_task()) {
+ $is_task = 1;
+ foreach my $part (@$partlist) {
+ if ($resource->handgrade($part) eq 'yes') {
+ $handgradeable=1;
+ last;
+ }
+ }
+ } else {
+ foreach my $part (@$partlist) {
+ my @types = $resource->responseType($part);
+ if (grep(/^essay$/,@types)) {
+ $handgradeable=1;
+ last;
+ } elsif (grep(/^custom$/,@types)) {
+ if ($resource->handgrade($part) eq 'yes') {
+ $handgradeable=1;
+ last;
+ }
+ }
}
}
if ($handgradeable) {
@@ -937,6 +1220,7 @@ sub check_handgraded {
if (@ungraded > 0) {
$$ungraded{$symb}{count} = scalar(@ungraded);
$$ungraded{$symb}{title} = $title;
+ $$ungraded{$symb}{is_task} = $is_task;
if ($resource->encrypted()) {
$$ungraded{$symb}{'enclink'} = $resource->link();
$$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
@@ -964,7 +1248,8 @@ sub check_bombed {
}
sub check_thresholds {
- my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_;
+ my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
+ $checkallowed) = @_;
# Compile maxtries and degree of difficulty for problem parts, unless handgradeable
my @parts = @{$resource->parts()};
my %stats;
@@ -999,6 +1284,7 @@ sub check_thresholds {
$av_attempts = $attempts/$users;
$av_attempts = sprintf("%.2f",$av_attempts);
}
+ &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff);
if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
$stats{$part}{degdiff} = $degdiff;
$stats{$part}{attempts} = $av_attempts;
@@ -1029,8 +1315,14 @@ sub check_thresholds {
'.$stats{$part}{users}.'
'.$stats{$part}{attempts}.'
'.$stats{$part}{degdiff}.'
- '.$lastreset{$part}.'
- ';
+ '.$lastreset{$part}.' ';
+ if ($checkallowed->{'resetcounters'}) {
+ my $aria = ' aria-label="'.&mt('Reset counter for [_1] (part [_2])',
+ $$triggered{$symb}{title},$part).'"';
+ $$triggered{$symb}{text}[$partcount] .=
+ ' '.
+ ' ';
+ }
$partcount ++;
}
$$triggered{$symb}{numparts} = $partcount;
@@ -1052,7 +1344,7 @@ sub get_curr_thresholds {
my $thresholdcount = 0;
my ($tmp) = %thresholdsettings;
unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
- foreach my $item (keys %{$threshold}) {
+ foreach my $item (keys(%{$threshold})) {
if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
$$threshold{$item} =
$thresholdsettings{$cid.':threshold_'.$item};
@@ -1067,7 +1359,7 @@ sub get_curr_thresholds {
$cdom,$crs,'internal.threshold');
my ($temp) = %coursesettings;
unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
- foreach my $item (keys %{$threshold}) {
+ foreach my $item (keys(%{$threshold})) {
unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
if (exists($coursesettings{'internal.threshold_'.$item})) {
$$threshold{$item} =
@@ -1092,7 +1384,11 @@ sub get_current {
}
sub process_reset {
- my ($dom,$crs) = @_;
+ my ($dom,$crs,$checkallowed) = @_;
+ if (!$checkallowed->{'resetcounters'}) {
+ return ''.&mt('You do not have the required privileges to reset counters').
+ ' ';
+ }
my $result = ''.&mt('Counters reset for following problems (and parts):').
' ';
my @agg_types = ('attempts','users','correct');
@@ -1134,9 +1430,13 @@ sub process_reset {
sub process_update {
my ($uname,$udom,$threshold_titles) = @_;
my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').' ';
- foreach (keys %env) {
- next if ($_!~/^form\.(.+)\_setparmval$/);
- my $name = $1;
+ foreach my $key (keys(%env)) {
+ my $name;
+ if ($key =~/^form\.(.+)\_setparmval$/) {
+ $name = $1;
+ } else {
+ next;
+ }
my $value = $env{'form.'.$name.'_value'};
if ($name && defined($value) && ($value ne '')) {
my $put_result = &Apache::lonnet::put('nohist_whatsnew',
@@ -1159,29 +1459,37 @@ sub process_update {
sub getnormalmail {
my ($newmsgs) = @_;
-# Check for unread mail in course
+# Check for unread messages in user's INBOX (which were sent in context of current course).
my $msgcount = 0;
-
- my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
- foreach my $message (@messages) {
- my $msgid=&escape($message);
- my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
- &Apache::lonmsg::unpackmsgid($msgid);
- if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
- if (defined($sendtime) && $sendtime!~/error/) {
- if ($status eq 'new') {
- $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
- $msgcount ++;
- if ($shortsubj eq '') {
- $shortsubj = &mt('No subject');
+ my @messages = &Apache::lonnet::getkeys('nohist_email');
+ return $msgcount if (!@messages);
+ my %emailstatus = &Apache::lonnet::dump('email_status');
+ foreach my $msgid (sort(@messages)) {
+ if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) {
+ my $skipstatus;
+ if ($emailstatus{$msgid} eq 'new') {
+ $skipstatus = 1;
+ }
+ my $esc_msgid = &escape($msgid);
+ my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
+ &Apache::lonmsg::unpackmsgid($esc_msgid,undef,$skipstatus,undef,
+ $env{'request.course.id'});
+ if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
+ if (defined($sendtime) && $sendtime!~/error/) {
+ if (($emailstatus{$msgid} eq 'new') || ($status eq 'new')) {
+ $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
+ $msgcount ++;
+ if ($shortsubj eq '') {
+ $shortsubj = &mt('No subject');
+ }
+ push(@{$newmsgs}, {
+ msgid => $esc_msgid,
+ sendtime => $sendtime,
+ shortsub => $shortsubj,
+ from => $fromname,
+ fromdom => $fromdom
+ });
}
- push(@{$newmsgs}, {
- msgid => $msgid,
- sendtime => $sendtime,
- shortsub => $shortsubj,
- from => $fromname,
- fromdom => $fromdom
- });
}
}
}
@@ -1191,13 +1499,15 @@ sub getnormalmail {
sub getcritmail {
my ($critmsgs) = @_;
-# Check for critical messages in course
+# Check for critical messages which were sent in context of current course.
my %what=&Apache::lonnet::dump('critical');
my $result = '';
my $critmsgcount = 0;
foreach my $msgid (sort(keys(%what))) {
+ my $esc_msgid = &escape($msgid);
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
- &Apache::lonmsg::unpackmsgid($msgid);
+ &Apache::lonmsg::unpackmsgid($esc_msgid,undef,1,undef,
+ $env{'request.course.id'});
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
if (defined($sendtime) && $sendtime!~/error/) {
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
@@ -1206,7 +1516,7 @@ sub getcritmail {
$shortsubj = &mt('No subject');
}
push(@{$critmsgs}, {
- msgid => $msgid,
+ msgid => $esc_msgid,
sendtime => $sendtime,
shortsub => $shortsubj,
from => $fromname,
@@ -1219,13 +1529,13 @@ sub getcritmail {
}
sub getexpired {
- my ($rolechgs,$rolechgtime,$status) = @_;
- my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
+ my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
+ my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist);
return $expirecount;
}
sub getactivated {
- my ($rolechgs,$rolechgtime,$status) = @_;
+ my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $now = time();
@@ -1237,28 +1547,26 @@ sub getactivated {
my (%stucounted,%advcounted);
my $activatedcount = 0;
if (keys(%changes) > 0) {
- foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
+ foreach my $chg (keys(%changes)) {
if (ref($changes{$chg}) eq 'HASH') {
- my $timestamp = $changes{$chg}{'exe_time'};
- if ($timestamp) {
- if ($rolechgtime > 0) {
- if ($timestamp < $rolechgtime) {
- last;
- }
- }
+ next if ($changes{$chg}{'delflag'});
+ if ($rolechgtime > 0) {
+ next if ($changes{$chg}{'exe_time'} < $rolechgtime);
+ }
+ if ($changes{$chg}{'exe_time'}) {
+ my $timestamp = $changes{$chg}{'exe_time'};
if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
- next if ($changes{$chg}{'delflag'});
- my $start = $changes{$chg}{'logentry'}{'start'};
my $end = $changes{$chg}{'logentry'}{'end'};
- my $section = $changes{$chg}{'logentry'}{'section'};
- my $role = $changes{$chg}{'logentry'}{'role'};
- my $uname = $changes{$chg}{'uname'};
- my $udom = $changes{$chg}{'udom'};
next if ($end && $end <= $now);
+ my $start = $changes{$chg}{'logentry'}{'start'};
+ next if ($start >= $timestamp);
+ my $section = $changes{$chg}{'logentry'}{'section'};
if (($viewablesec ne '') && ($section ne '')) {
next if ($viewablesec ne $section);
}
- next if ($start >= $timestamp);
+ my $role = $changes{$chg}{'logentry'}{'role'};
+ my $uname = $changes{$chg}{'uname'};
+ my $udom = $changes{$chg}{'udom'};
if ($role eq 'st') {
$stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
} else {
@@ -1278,12 +1586,13 @@ sub getactivated {
}
}
}
- $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
+ $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted,
+ \%advcounted);
return $activatedcount;
}
sub getrolechanges {
- my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
+ my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_;
my (%stucounted,%advcounted);
if (ref($stucountref) eq 'HASH') {
%stucounted = %{$stucountref};
@@ -1301,63 +1610,64 @@ sub getrolechanges {
my ($permission,$allowed) =
&Apache::lonuserutils::get_permission($context);
my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
- my $classlist = &Apache::loncoursedata::get_classlist();
my $secidx = &Apache::loncoursedata::CL_SECTION();
my $startidx = &Apache::loncoursedata::CL_START();
my $endidx = &Apache::loncoursedata::CL_END();
my $rolechgcount = 0;
- foreach my $key (keys(%{$classlist})) {
- my ($userstatus,$eventtime);
- my $student = $classlist->{$key};
- if (ref($student) eq 'ARRAY') {
- my $start = $student->[$startidx];
- my $end = $student->[$endidx];
- my $sec = $student->[$secidx];
- my ($stuname,$studom) = split(/:/,$key);
- if ($status eq 'active') {
- if (exists($stucounted{$key.':'.$sec})) {
- next;
+ if (ref($classlist) eq 'HASH') {
+ foreach my $key (keys(%{$classlist})) {
+ my ($userstatus,$eventtime);
+ my $student = $classlist->{$key};
+ if (ref($student) eq 'ARRAY') {
+ my $start = $student->[$startidx];
+ my $end = $student->[$endidx];
+ my $sec = $student->[$secidx];
+ my ($stuname,$studom) = split(/:/,$key);
+ if ($status eq 'active') {
+ if (exists($stucounted{$key.':'.$sec})) {
+ next;
+ }
}
- }
- if (($end == 0) || ($end > $start)) {
- if ($start <= $now) {
- if ($end && $end < $now) {
- if ($rolechgtime > 0) {
- if ($end > $rolechgtime) {
+ if (($end == 0) || ($end > $start)) {
+ if ($start <= $now) {
+ if ($end && $end < $now) {
+ if ($rolechgtime > 0) {
+ if ($end > $rolechgtime) {
+ $userstatus = 'previous';
+ }
+ } else {
$userstatus = 'previous';
}
} else {
- $userstatus = 'previous';
- }
- } else {
- if ($rolechgtime > 0) {
- if ($start >= $rolechgtime) {
+ if ($rolechgtime > 0) {
+ if ($start >= $rolechgtime) {
+ $userstatus = 'active';
+ }
+ } else {
$userstatus = 'active';
}
- } else {
- $userstatus = 'active';
}
}
}
+ next if ($userstatus ne $status);
+ if ($status eq 'active') {
+ $eventtime = $start;
+ } else {
+ $eventtime = $end;
+ }
+ if (($viewablesec ne '') && ($sec ne '')) {
+ next if ($viewablesec ne $sec);
+ }
+ my %chginfo = (
+ 'section' => $sec,
+ 'uname' => $stuname,
+ 'udom' => $studom,
+ 'role' => 'st',
+ 'status' => $userstatus,
+ );
+ $rolechgcount ++;
+ push(@{$rolechgs->{$eventtime}},\%chginfo);
}
- next if ($userstatus ne $status);
- if ($status eq 'active') {
- $eventtime = $start;
- } else {
- $eventtime = $end;
- }
- if (($viewablesec ne '') && ($sec ne '')) {
- next if ($viewablesec ne $sec);
- }
- my %chginfo = (
- 'section' => $sec,
- 'uname' => $stuname,
- 'udom' => $studom,
- 'role' => 'st',
- 'status' => $userstatus,
- );
- $rolechgcount ++;
- push (@{$rolechgs->{$eventtime}},\%chginfo);
}
}
my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
@@ -1418,6 +1728,111 @@ sub getrolechanges {
return $rolechgcount;
}
+sub getloggedin {
+ my ($cdom,$crs,$lastlogins,$starttime) = @_;
+ my $context = 'course';
+ my ($permission,$allowed) =
+ &Apache::lonuserutils::get_permission($context);
+ my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
+ my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs);
+ my $logincount = 0;
+ my ($tmp) = keys(%crslogins);
+ unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
+ if (keys(%crslogins) > 0) {
+ foreach my $key (keys(%crslogins)) {
+ my ($uname,$udom,$section,$role) = split(/:/,$key);
+ my $eventtime = $crslogins{$key};
+ if ($eventtime > $starttime) {
+ if (($viewablesec ne '') && ($section ne '')) {
+ next if ($viewablesec ne $section);
+ }
+ my %chginfo = (
+ 'section' => $section,
+ 'uname' => $uname,
+ 'udom' => $udom,
+ 'role' => $role,
+ );
+ $logincount ++;
+ push (@{$lastlogins->{$eventtime}},\%chginfo);
+ }
+ }
+ }
+ }
+ return $logincount;
+}
+
+sub getsessions {
+ my ($cdom,$cnum,$sessions,$lastactive,$classlist) = @_;
+ my $context = 'course';
+ my ($permission,$allowed) =
+ &Apache::lonuserutils::get_permission($context);
+ my %crs_sessions = &Apache::lonnet::get_course_sessions($cnum,$cdom,$lastactive);
+ my $sessioncount = 0;
+ if (keys(%crs_sessions) > 0) {
+ if (ref($classlist) eq 'HASH') {
+ my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
+ my $secidx = &Apache::loncoursedata::CL_SECTION();
+ my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'_'.$cnum,1);
+ my %personnel;
+ foreach my $role (sort(keys(%coursepersonnel))) {
+ my ($rolecode,$section);
+ if ($role =~ /:/) {
+ ($rolecode,$section) = split(/:/,$role);
+ } else {
+ $rolecode = $role;
+ }
+ if ($viewablesec ne '') {
+ next if ($viewablesec ne $section);
+ }
+ foreach my $user (split(/\,/,$coursepersonnel{$role})) {
+ push(@{$personnel{$user}{$rolecode}},$section);
+ }
+ }
+ foreach my $key (keys(%crs_sessions)) {
+ if (exists($classlist->{$key})) {
+ my $student = $classlist->{$key};
+ my $section = $student->[$secidx];
+ my $lastaccess = $crs_sessions{$key};
+ if ($viewablesec ne '') {
+ next if ($viewablesec ne $section);
+ }
+ my ($stuname,$studom) = split(/:/,$key);
+ my %info = (
+ 'section' => $section,
+ 'role' => 'st',
+ 'uname' => $stuname,
+ 'udom' => $studom,
+ );
+ $sessioncount ++;
+ push(@{$sessions->{$lastaccess}},\%info);
+ } elsif (exists($personnel{$key})) {
+ my $lastaccess = $crs_sessions{$key};
+ my ($uname,$udom) = split(/:/,$key);
+ if (ref($personnel{$key}) eq 'HASH') {
+ my ($showrole,$showsec);
+ foreach my $possrole ('cc','co','in','ta','ep','ad','st') {
+ if (exists($personnel{$key}{$possrole})) {
+ $showrole = $possrole;
+ $showsec = join(', ',@{$personnel{$key}{$possrole}});
+ last;
+ }
+ }
+ my %info = (
+ 'section' => $showsec,
+ 'role' => $showrole,
+ 'uname' => $uname,
+ 'udom' => $udom,
+ );
+ $sessioncount ++;
+ push(@{$sessions->{$lastaccess}},\%info);
+ }
+ }
+ }
+ }
+ }
+ return $sessioncount;
+}
+
sub checkversions {
my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
@@ -1473,13 +1888,24 @@ sub display_handgrade {
foreach my $res (@{$tograde}) {
$rowNum ++;
my $css_class = $rowNum%2?' class="LC_odd_row"':'';
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
- my $linkurl=&Apache::lonnet::clutter($url);
- $linkurl .= '?symb='.&escape($res);
- if ($$ungraded{$res}{'enclink'}) {
- $linkurl =
- $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
- }
+ my $linkurl;
+ if ($$ungraded{$res}{'is_task'}) {
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
+ $linkurl=&Apache::lonnet::clutter($url);
+ $linkurl .= '?symb='.&escape($res);
+ if ($$ungraded{$res}{'enclink'}) {
+ $linkurl =
+ $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
+ }
+ } else {
+ $linkurl='/adm/grades';
+ if ($$ungraded{$res}{'enclink'}) {
+ $linkurl.='?symb='.$$ungraded{$res}{'encsymb'};
+ } else {
+ $linkurl.='?symb='.&escape($res);
+ }
+ $linkurl.='&command=ungraded';
+ }
$r->print(''.$$ungraded{$res}{title}.' '.$$ungraded{$res}{count}.' ');
}
} elsif ($itemserror) {
@@ -1518,7 +1944,7 @@ sub display_haserrors {
}
sub display_abovethreshold {
- my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_;
+ my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$checkallowed) = @_;
my %lt = &Apache::lonlocal::texthash(
reso => 'Resource',
part => 'Part',
@@ -1532,16 +1958,16 @@ sub display_abovethreshold {
);
if (@{$warnings} > 0) {
@{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
- $r->print(' ');
my $row;
foreach my $res (@{$warnings}) {
$row++;
@@ -1560,20 +1986,22 @@ sub display_abovethreshold {
$r->print('