- ');
+
+
+');
}
#-------------------------------
@@ -477,7 +766,7 @@ 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;"';
$r->print(&Apache::loncommon::start_data_table_row()."\n".
@@ -491,7 +780,7 @@ sub display_threshold_config {
&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table()."\n".
- '
+ '
');
@@ -505,28 +794,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;
}
@@ -556,7 +879,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('
';
+ if ($checkallowed->{'resetcounters'}) {
+ $$triggered{$symb}{text}[$partcount] .=
+ '
'.
+ '
';
+ }
$partcount ++;
}
$$triggered{$symb}{numparts} = $partcount;
@@ -901,7 +1275,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};
@@ -916,7 +1290,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} =
@@ -941,7 +1315,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');
@@ -982,10 +1360,14 @@ sub process_reset {
sub process_update {
my ($uname,$udom,$threshold_titles) = @_;
- my $setoutput = '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',
@@ -993,45 +1375,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
- });
}
}
}
@@ -1041,23 +1430,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,
@@ -1069,6 +1459,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) = @_;
@@ -1086,7 +1780,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;
@@ -1111,7 +1805,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',
@@ -1125,22 +1819,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('
');
}
} else {
@@ -1414,24 +2300,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 {
@@ -1443,20 +2341,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]',
- ''.$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].',
- ''.$env{'form.countunread'}.'',
- ''.$outcome.'. ');
+ ''.&mt($env{'form.countunread'}).'',
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_courseinit_setting {
@@ -1481,27 +2379,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 {
@@ -1526,31 +2426,59 @@ sub start_box {
$r->print('
-
'.$$heading{$caller}.'
+
'.$$heading{$caller}.'
'.$showhide.'
');
if (($caller eq 'abovethreshold') && ($$show{$caller})) {
if ($$show{$caller}) {
$r->print('