+
');
}
@@ -482,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".
- '
+ '
');
@@ -510,28 +799,62 @@ sub display_threshold_config {
#-------------------------------
sub display_interval_config {
- my ($r,$refpage,$interval_titles) = @_;
+ my ($r,$refpage,$interval_titles,$context) = @_;
+ my $setting = 'interval';
+ if ($context eq 'oldroles') {
+ $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'},
- $env{'request.course.id'},'interval');
- $r->print(' '.&mt('Choose the time window to use for display of version changes for resources in the '.$lctype.'.').' ');
+ $env{'request.course.id'},$setting);
+ if ($context eq 'oldroles') {
+ $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.').' ');
+ }
unless ($current eq '') {
- $r->print(' '.&mt('Current value is [_1].',''.
- $$interval_titles{$current}.''));
+ if (ref($interval_titles->{$context}) eq 'HASH') {
+ $r->print(' '.&mt('Current value is "[_1]".',''.
+ $interval_titles->{$context}->{$current}.'').' ');
+ }
}
- $r->print('
+ $r->print('
');
+ &mt('Save').'" />');
return;
}
@@ -561,7 +884,13 @@ function toggle_countunread(choice) {
document.discussionswitch.submit();
}
');
- $r->print(' '.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').' '.&mt("This can increase the time taken to gather data for the 'What's New?' page by a few seconds.").' '.&mt("Currently set to $current."));
+ $r->print(' '
+ .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.')
+ .' '
+ .&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.'')
+ );
$r->print('
');
@@ -600,7 +929,7 @@ sub courseinit_config {
'anis' => 'and is set to display',
'padc' => 'Page display controlled by',
'chce' => 'Choose '.$lctype.' entry',
- 'moce' => 'Modify '.$lctype.' entry',
+ 'moce' => 'Save',
);
$r->print(<<"END");
$lt{'chwp'}
@@ -661,27 +990,41 @@ sub display_launcher {
my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
- $interval,$countunread) = @_;
+ $interval,$countunread,$expired,$expirecount,$activated,$activecount,
+ $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);
+ &display_handgrade($r,$tograde,$ungraded,$itemserror);
} elsif ($action eq 'haserrors') { # BOMBS
- &display_haserrors($r,$bombs,$bombed,$res_title);
+ &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
} elsif ($action eq 'versionchanges') { # VERSION CHANGES
- &display_versionchanges($r,$changed,$res_title,$interval);
+ &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);
+ $res_title,$itemserror,$checkallowed);
} elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
&display_coursediscussion($r,$newdiscussions,$unread,
- $countunread,$res_title);
+ $countunread,$res_title,$itemserror);
} elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
&display_coursenormalmail($r,$msgcount,$newmsgs);
} elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
&display_coursecritmail($r,$critmsgcount,$critmsgs);
+ } elsif ($action eq 'newroles') { # ACTIVATED ROLES
+ &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
+ $crstype,$classlist);
+ } elsif ($action eq 'oldroles') { # EXPIRED ROLES
+ &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
+ $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);
@@ -692,8 +1035,12 @@ 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].','','').'';
+ return $itemserror;
+ }
# force retrieve Resource to seed the part id cache we'll need it later
my @allres=$navmap->retrieveResources(undef,
sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
@@ -748,10 +1095,11 @@ 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;
}
sub check_discussions {
@@ -780,12 +1128,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) {
@@ -794,6 +1158,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();
@@ -821,7 +1186,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;
@@ -831,6 +1197,9 @@ sub check_thresholds {
if ($resource->handgrade($part) eq 'yes') {
next;
}
+ if ($resource->is_anonsurvey($part)) {
+ next;
+ }
if ($resource->is_survey($part)) {
next;
}
@@ -853,6 +1222,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;
@@ -883,8 +1253,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;
@@ -906,7 +1282,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};
@@ -921,7 +1297,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} =
@@ -946,7 +1322,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');
@@ -987,10 +1367,14 @@ 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;
+ my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').'
';
+ 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',
@@ -998,45 +1382,52 @@ sub process_update {
my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
if ($put_result eq 'ok') {
- $setoutput.=&mt('Set threshold for [_1] to [_2]',
+ $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
''.$$threshold_titles{$shortname}.'',
- ''.$value.'').' ';
+ ''.$value.'').' ');
} else {
- $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
+ $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
''.$name.'',''.$value.'',
- ''.$put_result.'').' ';
+ ''.$put_result.'').' ',1);
}
}
}
- return $setoutput;
+ return &Apache::loncommon::confirmwrapper($setoutput);
}
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/) {
- my $numsendtime = $sendtime;
- $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
- if ($status eq 'new') {
- $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
- });
}
}
}
@@ -1046,23 +1437,24 @@ 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/) {
- my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
$critmsgcount ++;
if ($shortsubj eq '') {
$shortsubj = &mt('No subject');
}
push(@{$critmsgs}, {
- msgid => $msgid,
+ msgid => $esc_msgid,
sendtime => $sendtime,
shortsub => $shortsubj,
from => $fromname,
@@ -1074,6 +1466,310 @@ sub getcritmail {
return $critmsgcount;
}
+sub getexpired {
+ my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
+ my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist);
+ return $expirecount;
+}
+
+sub getactivated {
+ 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();
+ my $context = 'course';
+ my ($permission,$allowed) =
+ &Apache::lonuserutils::get_permission($context);
+ my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
+ my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
+ my (%stucounted,%advcounted);
+ my $activatedcount = 0;
+ if (keys(%changes) > 0) {
+ foreach my $chg (keys(%changes)) {
+ if (ref($changes{$chg}) eq 'HASH') {
+ 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') {
+ my $end = $changes{$chg}{'logentry'}{'end'};
+ 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);
+ }
+ 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 {
+ $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
+ }
+ my %chginfo = (
+ 'section' => $section,
+ 'uname' => $uname,
+ 'udom' => $udom,
+ 'role' => $role,
+ 'status' => $status,
+ );
+ $activatedcount ++;
+ push (@{$rolechgs->{$timestamp}},\%chginfo);
+ }
+ }
+ }
+ }
+ }
+ $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted,
+ \%advcounted);
+ return $activatedcount;
+}
+
+sub getrolechanges {
+ my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_;
+ my (%stucounted,%advcounted);
+ if (ref($stucountref) eq 'HASH') {
+ %stucounted = %{$stucountref};
+ }
+ if (ref($advcountref) eq 'HASH') {
+ %advcounted = %{$advcountref};
+ }
+ my $withsec = 1;
+ my $hidepriv = 1;
+ my $context = 'course';
+ my @statuses = ($status);
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $now = time();
+ my ($permission,$allowed) =
+ &Apache::lonuserutils::get_permission($context);
+ my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
+ my $secidx = &Apache::loncoursedata::CL_SECTION();
+ my $startidx = &Apache::loncoursedata::CL_START();
+ my $endidx = &Apache::loncoursedata::CL_END();
+ my $rolechgcount = 0;
+ 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) {
+ $userstatus = 'previous';
+ }
+ } else {
+ $userstatus = 'previous';
+ }
+ } else {
+ if ($rolechgtime > 0) {
+ if ($start >= $rolechgtime) {
+ $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);
+ }
+ }
+ }
+ my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
+ \@statuses,undef,undef,$withsec,$hidepriv);
+ foreach my $item (keys(%advrolehash)) {
+ my ($userstatus,$eventtime);
+ my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
+ my ($start,$end) = split(/:/,$advrolehash{$item});
+ if ($start eq '-1' && $end eq '-1') {
+ next;
+ } else {
+ if ($status eq 'active') {
+ if (exists($advcounted{$item})) {
+ next;
+ }
+ }
+ if (($end == 0) || ($end > $start)) {
+ if ($start <= $now) {
+ if ($end && $end < $now) {
+ if ($rolechgtime > 0) {
+ if ($end > $rolechgtime) {
+ $userstatus = 'previous';
+ }
+ } else {
+ $userstatus = 'previous';
+ }
+ } else {
+ if ($rolechgtime > 0) {
+ if ($start >= $rolechgtime) {
+ $userstatus = 'active';
+ }
+ } else {
+ $userstatus = 'active';
+ }
+ }
+ }
+ }
+ next if ($userstatus ne $status);
+ if ($status eq 'active') {
+ $eventtime = $start;
+ } else {
+ $eventtime = $end;
+ }
+ }
+ if (($viewablesec ne '') && ($section ne '')) {
+ next if ($viewablesec ne $section);
+ }
+ my %chginfo = (
+ 'section' => $section,
+ 'uname' => $uname,
+ 'udom' => $udom,
+ 'role' => $role,
+ 'status' => $userstatus,
+ );
+ $rolechgcount ++;
+ push (@{$rolechgs->{$eventtime}},\%chginfo);
+ }
+ 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) = @_;
@@ -1091,7 +1787,7 @@ sub checkversions {
'lastrevisiondate');
$revdate = &Apache::lonlocal::locallocaltime($revdate);
my $linkurl=&Apache::lonnet::clutter($key);
- my $usedversion=$navmap->usedVersion('version_'.$linkurl);
+ my $usedversion=$navmap->usedVersion($linkurl);
my @resources = $navmap->getResourceByUrl($linkurl,1);
if (($usedversion) && ($usedversion ne 'mostrecent')) {
$version = $usedversion;
@@ -1116,7 +1812,7 @@ sub checkversions {
}
sub display_handgrade {
- my ($r,$tograde,$ungraded) = @_;
+ my ($r,$tograde,$ungraded,$itemserror) = @_;
my %lt = &Apache::lonlocal::texthash(
'prna' => 'Problem Name',
'nmun' => 'Number ungraded',
@@ -1130,22 +1826,35 @@ 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('
'.
@@ -1420,24 +2307,36 @@ sub store_interval_setting {
my ($uname,$udom,$cid,$interval_titles) = @_;
my %interval_settings = ();
my $result;
- if (defined($env{'form.interval'})) {
- $interval_settings{$cid.':interval'} = $env{'form.interval'};
+ my $context = $env{'form.intervaltype'};
+ if ($env{'form.interval'} ne '') {
+ if ($context eq 'oldroles') {
+ $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'};
+ }
my $outcome = &Apache::lonnet::put('nohist_whatsnew',
\%interval_settings,$udom,$uname);
if ($outcome eq 'ok') {
- $result = &mt('Interval set to version changes [_1]',
- ''.$$interval_titles{$env{'form.interval'}}.'').' ';
-
+ if (ref($interval_titles->{$context}) eq 'HASH') {
+ $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 interval setting'.
+ &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].',
- ''.$$interval_titles{$env{'form.interval'}}.'',
- ''.$outcome.'. ');
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
+ ''.$interval_titles->{$context}->{$env{'form.interval'}}.'',
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_discussion_setting {
@@ -1449,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 {
@@ -1487,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 {
@@ -1539,24 +2440,52 @@ sub start_box {
if ($$show{$caller}) {
$r->print('