version 1.91, 2009/04/16 21:19:56
|
version 1.101.2.1.2.2, 2012/02/11 17:58:17
|
Line 42 use Time::Local;
|
Line 42 use Time::Local;
|
use GDBM_File; |
use GDBM_File; |
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
|
use HTML::Entities; |
|
|
#---------------------------- |
#---------------------------- |
# handler |
# handler |
Line 71 sub handler {
|
Line 72 sub handler {
|
['mdc','versionchanges',0], |
['mdc','versionchanges',0], |
['vcl','newroles',1], |
['vcl','newroles',1], |
['vcl','oldroles',1], |
['vcl','oldroles',1], |
|
['whn','crslogin',1], |
) { |
) { |
my ($perm,$key,$check_section) = @{ $perm_check }; |
my ($perm,$key,$check_section) = @{ $perm_check }; |
my $scope = $env{'request.course.id'}; |
my $scope = $env{'request.course.id'}; |
Line 87 sub handler {
|
Line 89 sub handler {
|
|
|
if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) { |
if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) { |
# Not in a course, or no whn priv in course |
# Not in a course, or no whn priv in course |
$env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page"; |
$env{'user.error.msg'}="/adm/whatsnew:whn:0:0:Cannot display what's new page"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
|
|
Line 142 sub handler {
|
Line 144 sub handler {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
("What's New?",#'Course_Action_Items_Intervals' |
("What's New?",#'Course_Action_Items_Intervals' |
)); |
)); |
|
} elsif ($command eq 'chgcrslogininterval' && $checkallowed{'crslogin'}) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage, |
|
text=>"Change interval"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
|
("What's New?",#'Course_Action_Items_Intervals' |
|
)); |
} else { |
} else { |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
("What's New?",#'Course_Action_Items_Display' |
("What's New?",#'Course_Action_Items_Display' |
Line 187 sub display_main_box {
|
Line 196 sub display_main_box {
|
604800 => 'roles which expired since last week', |
604800 => 'roles which expired since last week', |
86400 => 'roles which expired since yesterday', |
86400 => 'roles which expired since yesterday', |
); |
); |
|
my %crslogins = ( |
|
-1 => 'last logins for anyone who has ever logged in', |
|
2592000 => 'last logins for users in last 30 days', |
|
604800 => 'last logins for users in last 7 days', |
|
86400 => 'last logins for users in last 24 hours', |
|
); |
my %interval_titles = ( |
my %interval_titles = ( |
versions => \%versions, |
versions => \%versions, |
newroles => \%newroles, |
newroles => \%newroles, |
oldroles => \%oldroles, |
oldroles => \%oldroles, |
|
crslogin => \%crslogins, |
); |
); |
my %initpage = &Apache::lonlocal::texthash ( |
my %initpage = &Apache::lonlocal::texthash ( |
firstres => "first resource in the $lctype", |
firstres => "first resource in the $lctype", |
Line 219 sub display_main_box {
|
Line 235 sub display_main_box {
|
} elsif (($command eq 'chgoldroleinterval') |
} elsif (($command eq 'chgoldroleinterval') |
&& $checkallowed->{'oldroles'}) { |
&& $checkallowed->{'oldroles'}) { |
&display_interval_config($r,$refpage,\%interval_titles,'oldroles'); |
&display_interval_config($r,$refpage,\%interval_titles,'oldroles'); |
|
} elsif (($command eq 'chgcrslogininterval') |
|
&& $checkallowed->{'crslogin'}) { |
|
&display_interval_config($r,$refpage,\%interval_titles,'crslogin'); |
} else { |
} else { |
&display_actions_box($r,$command,$refpage,\%threshold_titles, |
&display_actions_box($r,$command,$refpage,\%threshold_titles, |
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed); |
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed); |
Line 244 sub display_header {
|
Line 263 sub display_header {
|
|
|
my $scripttag; |
my $scripttag; |
unless ($command eq 'chgthreshold' || $command eq 'chginterval' || |
unless ($command eq 'chgthreshold' || $command eq 'chginterval' || |
$command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') { |
$command eq 'chgoldroleinterval' || |
|
$command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') { |
$scripttag = <<"END"; |
$scripttag = <<"END"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
|
// <![CDATA[ |
function change_display(caller,change) { |
function change_display(caller,change) { |
caller.value = change; |
caller.value = change; |
document.visible.submit(); |
document.visible.submit(); |
Line 263 END
|
Line 284 END
|
} |
} |
$scripttag.='document.visible.submit(); |
$scripttag.='document.visible.submit(); |
} |
} |
|
|
|
function togglelogins() { |
|
var total = document.visible.logincount.value; |
|
var sumrow = document.visible.loginrow.value; |
|
if (total == 0) { |
|
return; |
|
} |
|
var showlogindetails = 0; |
|
for (var i=0; i<document.visible.logindetails.length; i++) { |
|
if (document.visible.logindetails[i].checked) { |
|
showlogindetails = document.visible.logindetails[i].value; |
|
} |
|
} |
|
var detval = "none"; |
|
var sumval = ""; |
|
if (showlogindetails == 1) { |
|
detval = ""; |
|
sumval = "none"; |
|
} |
|
for (var j=0; j<total; j++) { |
|
var counter = j+1; |
|
var itemid = "logindet_"+counter; |
|
personele = document.getElementById(itemid); |
|
if (personele != null) { |
|
personele.style.display = detval; |
|
} |
|
} |
|
var detheaderele = document.getElementById("logintitledet"); |
|
if (detheaderele != null) { |
|
detheaderele.style.display = detval; |
|
} |
|
for (var k=0; k<sumrow; k++) { |
|
var counter = k+1; |
|
var itemid = "loginsum_"+counter; |
|
logincatele = document.getElementById(itemid); |
|
if (logincatele != null) { |
|
logincatele.style.display = sumval; |
|
} |
|
} |
|
var sumheaderele = document.getElementById("logintitlesum"); |
|
if (sumheaderele != null) { |
|
sumheaderele.style.display = sumval; |
|
} |
|
return; |
|
} |
|
// ]]> |
</script> |
</script> |
'; |
'; |
} |
} |
Line 288 sub display_actions_box {
|
Line 355 sub display_actions_box {
|
my $lctype = lc($crstype); |
my $lctype = lc($crstype); |
my %stulabel = ( |
my %stulabel = ( |
'Course' => 'students', |
'Course' => 'students', |
'Group' => 'members', |
'Community' => 'members', |
); |
); |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'yacc' => 'You are accessing an invalid course', |
'yacc' => 'You are accessing an invalid course', |
Line 314 sub display_actions_box {
|
Line 381 sub display_actions_box {
|
my %expired; |
my %expired; |
my $activecount; |
my $activecount; |
my %activated; |
my %activated; |
|
my %loggedin; |
|
my $logincount; |
my %res_title = (); |
my %res_title = (); |
my %show = (); |
my %show = (); |
my $needitems = 0; |
my $needitems = 0; |
Line 341 sub display_actions_box {
|
Line 410 sub display_actions_box {
|
return; |
return; |
} |
} |
|
|
|
my $header = ''; |
if ($refpage eq 'start') { |
if ($refpage eq 'start') { |
if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', |
if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', |
&GDBM_READER(),0640)) { |
&GDBM_READER(),0640)) { |
my $furl=$bighash{'first_url'}; |
my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&'); |
untie(%bighash); |
untie(%bighash); |
$r->print('<span style="font-size: larger;"><a href="'.$furl.'">'.$lt{'gtfr'}. |
$header .= '<b><a href="'.$furl.'">'.$lt{'gtfr'}. |
'</a></span><br />'); |
'</a></b><br />'; |
} |
} |
} |
} |
$r->print(&mt('Page set to be displayed after you have selected a role in this '.$lctype).'.' |
$header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.' |
.' <span class="LC_nobreak">' |
.' <span class="LC_nobreak">' |
.&mt('Currently: [_1].','<i>'.$currinit.'</i>') |
.&mt('Currently: [_1].','<i>'.$currinit.'</i>') |
.' ' |
.' ' |
.&mt('[_1]Change[_2] for just [_3]this course[_4] or for all [_5]your courses[_6].' |
.&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].' |
,'<b>' |
,'<b>' |
,'</b>' |
,'</b>' |
,'<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.'">' |
,'<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.'">' |
,'</a>' |
,'</a>' |
,'<a href="/adm/preferences?action=changecourseinit&refpage='.$refpage.'">' |
,'<a href="/adm/preferences?action=changecourseinit&refpage='.$refpage.'">' |
,'</a>') |
,'</a>') |
.' </span><br /><hr />'); |
.' </span>'; |
|
|
|
$r->print(&Apache::loncommon::head_subbox($header)); |
|
|
if ($command eq 'reset') { |
if ($command eq 'reset') { |
$result = &process_reset($cdom,$crs); |
$result = &process_reset($cdom,$crs); |
Line 378 sub display_actions_box {
|
Line 450 sub display_actions_box {
|
unless ($store_result eq 'ok') { |
unless ($store_result eq 'ok') { |
&Apache::lonnet::logthis('Error saving whatsnew settings: '. |
&Apache::lonnet::logthis('Error saving whatsnew settings: '. |
$store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid); |
$store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid); |
$result .= &mt('Unable to save visibility settings due to [_1]', |
$result .= '<span class="LC_error">' |
$store_result); |
.&mt('Unable to save visibility settings due to [_1]', |
|
$store_result) |
|
.'</span>'; |
} |
} |
|
|
if ($result) { |
if ($result) { |
$r->print($result.'<hr width="100%" />'); |
$r->print($result.'<hr />'); |
} |
} |
$r->rflush(); |
$r->rflush(); |
|
|
Line 439 sub display_actions_box {
|
Line 513 sub display_actions_box {
|
$headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); |
$headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); |
} |
} |
|
|
|
$timediff{'crslogin'} = $display_settings{$cid.':crslogininterval'}; |
|
unless (defined($timediff{'crslogin'})) { $timediff{'crslogin'} = 604800; } |
|
$interval{'crslogin'} = $interval_titles->{'crslogin'}->{$timediff{'crslogin'}}; |
|
|
|
if ($timediff{'crslogin'} == -1) { |
|
$headings{'crslogin'} = &mt('Last login for anyone who has ever logged in'); |
|
} elsif ($timediff{'crslogin'} == 2592000) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 30 days'); |
|
} elsif ($timediff{'crslogin'} == 604800) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 7 days'); |
|
} elsif ($timediff{'crslogin'} == 86400) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 24 hours'); |
|
} |
|
|
my $now = time; |
my $now = time; |
if ($timediff{'versions'} == -1) { |
if ($timediff{'versions'} == -1) { |
$timediff{'versions'} = time; |
$timediff{'versions'} = time; |
Line 455 sub display_actions_box {
|
Line 543 sub display_actions_box {
|
} |
} |
my $expiredstart = $now - $timediff{'oldroles'}; |
my $expiredstart = $now - $timediff{'oldroles'}; |
|
|
|
if ($timediff{'crslogin'} == -1) { |
|
$timediff{'crslogin'} = time; |
|
} |
|
|
|
my $crsloginstart = $now - $timediff{'crslogin'}; |
|
|
my $countunread = $display_settings{$cid.':countunread'}; |
my $countunread = $display_settings{$cid.':countunread'}; |
unless (defined($countunread)) { |
unless (defined($countunread)) { |
$countunread = 'on'; |
$countunread = 'on'; |
Line 468 sub display_actions_box {
|
Line 562 sub display_actions_box {
|
$threshold{'av_attempts'},$threshold{'degdiff'}, |
$threshold{'av_attempts'},$threshold{'degdiff'}, |
'<br />',$threshold{'numstudents'}); |
'<br />',$threshold{'numstudents'}); |
|
|
my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles'); |
my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles','crslogin'); |
|
|
foreach my $key (keys(%{$checkallowed})) { |
foreach my $key (keys(%{$checkallowed})) { |
if ($key =~ /_section$/) { next; } |
if ($key =~ /_section$/) { next; } |
Line 506 sub display_actions_box {
|
Line 600 sub display_actions_box {
|
if ($show{'newroles'}) { |
if ($show{'newroles'}) { |
$activecount = &getactivated(\%activated,$activatedstart,'active'); |
$activecount = &getactivated(\%activated,$activatedstart,'active'); |
} |
} |
|
if ($show{'crslogin'}) { |
|
$logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart); |
|
} |
$r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a> |
$r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a> |
<a href="javascript:changeAll('show');">$lt{'shal'}</a> |
<a href="javascript:changeAll('show');">$lt{'shal'}</a> |
<form method="post" name="visible" action="/adm/whatsnew">\n|); |
<form method="post" name="visible" action="/adm/whatsnew">\n|); |
Line 516 sub display_actions_box {
|
Line 613 sub display_actions_box {
|
} |
} |
} |
} |
|
|
$r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /></form><table class="LC_double_column"><tr><td class="LC_left_col">'); |
$r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /><table class="LC_double_column"><tr><td class="LC_left_col">'); |
|
|
my $displayed = 0; |
my $displayed = 0; |
my $totalboxes = 0; |
my $totalboxes = 0; |
Line 534 sub display_actions_box {
|
Line 631 sub display_actions_box {
|
if ($displayed == $halfway) { |
if ($displayed == $halfway) { |
$r->print('</td><td> </td><td class="LC_right_col" >'); |
$r->print('</td><td> </td><td class="LC_right_col" >'); |
} |
} |
&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); |
$displayed ++; |
$displayed ++; |
} |
} |
} |
} |
Line 542 sub display_actions_box {
|
Line 639 sub display_actions_box {
|
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
|
</form> |
'); |
'); |
} |
} |
|
|
Line 622 sub display_interval_config {
|
Line 720 sub display_interval_config {
|
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />'); |
} elsif ($context eq 'newroles') { |
} elsif ($context eq 'newroles') { |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />'); |
|
} elsif ($context eq 'crslogin') { |
|
$r->print('<br />'.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).'<br />'); |
} else { |
} else { |
$r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />'); |
} |
} |
Line 787 sub display_launcher {
|
Line 887 sub display_launcher {
|
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, |
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, |
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, |
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, |
$interval,$countunread,$expired,$expirecount,$activated,$activecount, |
$interval,$countunread,$expired,$expirecount,$activated,$activecount, |
$crstype,$itemserror) = @_; |
$crstype,$itemserror,$loggedin,$logincount) = @_; |
|
|
if ($$checkallowed{$action}) { |
if ($$checkallowed{$action}) { |
&start_box($r,$show,$headings,$action,$refpage,$action); |
&start_box($r,$show,$headings,$action,$refpage); |
if ($$show{$action}) { |
if ($$show{$action}) { |
if ($action eq 'handgrading') { # UNGRADED ITEMS |
if ($action eq 'handgrading') { # UNGRADED ITEMS |
&display_handgrade($r,$tograde,$ungraded,$itemserror); |
&display_handgrade($r,$tograde,$ungraded,$itemserror); |
Line 814 sub display_launcher {
|
Line 914 sub display_launcher {
|
} elsif ($action eq 'oldroles') { # EXPIRED ROLES |
} elsif ($action eq 'oldroles') { # EXPIRED ROLES |
&display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, |
&display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, |
$crstype); |
$crstype); |
|
} elsif ($action eq 'crslogin') { #LAST LOGIN |
|
&display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, |
|
$crstype); |
|
|
} |
} |
} |
} |
&end_box($r); |
&end_box($r); |
Line 968 sub check_thresholds {
|
Line 1072 sub check_thresholds {
|
if ($resource->handgrade($part) eq 'yes') { |
if ($resource->handgrade($part) eq 'yes') { |
next; |
next; |
} |
} |
|
if ($resource->is_anonsurvey($part)) { |
|
next; |
|
} |
if ($resource->is_survey($part)) { |
if ($resource->is_survey($part)) { |
next; |
next; |
} |
} |
Line 1124 sub process_reset {
|
Line 1231 sub process_reset {
|
|
|
sub process_update { |
sub process_update { |
my ($uname,$udom,$threshold_titles) = @_; |
my ($uname,$udom,$threshold_titles) = @_; |
my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br />'; |
my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br/><br />'; |
foreach (keys %env) { |
foreach (keys %env) { |
next if ($_!~/^form\.(.+)\_setparmval$/); |
next if ($_!~/^form\.(.+)\_setparmval$/); |
my $name = $1; |
my $name = $1; |
Line 1135 sub process_update {
|
Line 1242 sub process_update {
|
|
|
my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/); |
my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/); |
if ($put_result eq 'ok') { |
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]', |
'<b>'.$$threshold_titles{$shortname}.'</b>', |
'<b>'.$$threshold_titles{$shortname}.'</b>', |
'<b>'.$value.'</b>').'<br />'; |
'<b>'.$value.'</b>').'<br />'); |
} else { |
} 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].', |
'<b>'.$name.'</b>','<b>'.$value.'</b>', |
'<b>'.$name.'</b>','<b>'.$value.'</b>', |
'<tt>'.$put_result.'</tt>').'<br />'; |
'<tt>'.$put_result.'</tt>').'<br />',1); |
} |
} |
} |
} |
} |
} |
return $setoutput; |
return &Apache::loncommon::confirmwrapper($setoutput); |
} |
} |
|
|
sub getnormalmail { |
sub getnormalmail { |
Line 1160 sub getnormalmail {
|
Line 1267 sub getnormalmail {
|
&Apache::lonmsg::unpackmsgid($msgid); |
&Apache::lonmsg::unpackmsgid($msgid); |
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { |
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { |
if (defined($sendtime) && $sendtime!~/error/) { |
if (defined($sendtime) && $sendtime!~/error/) { |
my $numsendtime = $sendtime; |
|
if ($status eq 'new') { |
if ($status eq 'new') { |
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
$msgcount ++; |
$msgcount ++; |
Line 1192 sub getcritmail {
|
Line 1298 sub getcritmail {
|
&Apache::lonmsg::unpackmsgid($msgid); |
&Apache::lonmsg::unpackmsgid($msgid); |
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { |
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { |
if (defined($sendtime) && $sendtime!~/error/) { |
if (defined($sendtime) && $sendtime!~/error/) { |
my $numsendtime = $sendtime; |
|
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
$sendtime = &Apache::lonlocal::locallocaltime($sendtime); |
$critmsgcount ++; |
$critmsgcount ++; |
if ($shortsubj eq '') { |
if ($shortsubj eq '') { |
Line 1411 sub getrolechanges {
|
Line 1516 sub getrolechanges {
|
return $rolechgcount; |
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 checkversions { |
sub checkversions { |
my ($cdom,$crs,$navmap,$changed,$starttime) = @_; |
my ($cdom,$crs,$navmap,$changed,$starttime) = @_; |
my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs); |
my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs); |
Line 1427 sub checkversions {
|
Line 1565 sub checkversions {
|
'lastrevisiondate'); |
'lastrevisiondate'); |
$revdate = &Apache::lonlocal::locallocaltime($revdate); |
$revdate = &Apache::lonlocal::locallocaltime($revdate); |
my $linkurl=&Apache::lonnet::clutter($key); |
my $linkurl=&Apache::lonnet::clutter($key); |
my $usedversion=$navmap->usedVersion('version_'.$linkurl); |
my $usedversion=$navmap->usedVersion($linkurl); |
my @resources = $navmap->getResourceByUrl($linkurl,1); |
my @resources = $navmap->getResourceByUrl($linkurl,1); |
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
$version = $usedversion; |
$version = $usedversion; |
Line 1667 sub display_rolechanges {
|
Line 1805 sub display_rolechanges {
|
} |
} |
return; |
return; |
} |
} |
|
|
|
sub display_crslogins { |
|
my ($r,$logincount,$loggedin,$interval,$crstype) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
'user' => 'User', |
|
'role' => 'Role', |
|
'sec' => 'Section', |
|
'number' => 'Total number of logins', |
|
); |
|
if ($logincount) { |
|
|
|
my $hdr = '<tr class="LC_info_row" style="display:none" id="logintitledet">'. |
|
'<td class="LC_left_item">'.$lt{'user'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'role'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'sec'}.'</td></tr>'. |
|
'<tr class="LC_info_row" id="logintitlesum">'. |
|
'<td class="LC_left_item">'.$lt{'number'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'role'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'sec'}; |
|
my (%bylastname,%counts); |
|
if (ref($loggedin) eq 'HASH') { |
|
my @logins = sort { $b <=> $a } (keys(%{$loggedin})); |
|
my $numlogin = 0; |
|
foreach my $item (@logins) { |
|
if (ref($loggedin->{$item}) eq 'ARRAY') { |
|
foreach my $user (@{$loggedin->{$item}}) { |
|
if (ref($user) eq 'HASH') { |
|
my $section; |
|
my $role = |
|
&Apache::lonnet::plaintext($user->{'role'},$crstype); |
|
my $status = &mt($user->{'status'}); |
|
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 = &Apache::loncommon::plainname($uname,$udom,'lastname'); |
|
my $link = |
|
&Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); |
|
push(@{$bylastname{$fullname}}, |
|
'<td>'.$link.'</td>'. |
|
'<td>'.$role.'</td>'. |
|
'<td>'.$section.'</td>'); |
|
} |
|
} |
|
} |
|
} |
|
my $table; |
|
foreach my $person (sort(keys(%bylastname))) { |
|
if (ref($bylastname{$person}) eq 'ARRAY') { |
|
foreach my $item (@{$bylastname{$person}}) { |
|
$numlogin ++; |
|
my $css_class = $numlogin%2?' class="LC_odd_row"':''; |
|
$table .= '<tr'.$css_class.' style="display:none;" id="logindet_'.$numlogin.'">'.$item.'</tr>'; |
|
} |
|
} |
|
} |
|
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 .= '<tr '.$css_class.' id="loginsum_'.$numrow.'">'. |
|
'<td>'.$counts{$role}{$sec}.'</td>'. |
|
'<td>'.$showrole.'</td>'. |
|
'<td>'.$sec.'</td></tr>'; |
|
} |
|
} |
|
} |
|
$r->print($hdr.'<input type="hidden" name="logincount" value="'.$numlogin. |
|
'" /><input type="hidden" name="loginrow" value="'.$numrow. |
|
'" /></td></tr>'.$table); |
|
} |
|
} else { |
|
$r->print('<tr class="LC_empty_row"><td>'. |
|
&mt('There are no '.$interval). |
|
'<input type="hidden" name="logincount" value="'.$logincount. |
|
'." /></td></tr>'); |
|
} |
|
return; |
|
} |
|
|
sub display_coursediscussion { |
sub display_coursediscussion { |
my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; |
my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; |
Line 1828 sub store_interval_setting {
|
Line 2052 sub store_interval_setting {
|
$interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'}; |
$interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'}; |
} elsif ($context eq 'newroles') { |
} elsif ($context eq 'newroles') { |
$interval_settings{$cid.':newroleinterval'} = $env{'form.interval'}; |
$interval_settings{$cid.':newroleinterval'} = $env{'form.interval'}; |
|
} elsif ($context eq 'crslogin') { |
|
$interval_settings{$cid.':crslogininterval'} = $env{'form.interval'}; |
} else { |
} else { |
$interval_settings{$cid.':interval'} = $env{'form.interval'}; |
$interval_settings{$cid.':interval'} = $env{'form.interval'}; |
} |
} |
Line 1835 sub store_interval_setting {
|
Line 2061 sub store_interval_setting {
|
\%interval_settings,$udom,$uname); |
\%interval_settings,$udom,$uname); |
if ($outcome eq 'ok') { |
if ($outcome eq 'ok') { |
if (ref($interval_titles->{$context}) eq 'HASH') { |
if (ref($interval_titles->{$context}) eq 'HASH') { |
$result = &mt('New filter setting: [_1].','<b>'. |
$result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].','<b>'. |
$interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />'; |
$interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />'); |
} |
} |
} else { |
} else { |
my $lctype = lc(&Apache::loncommon::course_type()); |
my $lctype = lc(&Apache::loncommon::course_type()); |
&Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'. |
&Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'. |
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); |
' '.$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].', |
'<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>', |
'<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>', |
'<tt>'.$outcome.'</tt>.<br />'); |
'<tt>'.$outcome.'</tt>'),1); |
} |
} |
} |
} |
return $result; |
return &Apache::loncommon::confirmwrapper($result); |
} |
} |
|
|
sub store_discussion_setting { |
sub store_discussion_setting { |
Line 1859 sub store_discussion_setting {
|
Line 2085 sub store_discussion_setting {
|
my $outcome = &Apache::lonnet::put('nohist_whatsnew', |
my $outcome = &Apache::lonnet::put('nohist_whatsnew', |
\%discussion_settings,$udom,$uname); |
\%discussion_settings,$udom,$uname); |
if ($outcome eq 'ok') { |
if ($outcome eq 'ok') { |
$result = &mt('Count unread posts in discussions display set to [_1]', |
$result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]', |
'<b>'.&mt($env{'form.countunread'}).'</b>').'<br />'; |
'<b>'.&mt($env{'form.countunread'}).'</b>').'<br />'); |
|
|
} else { |
} else { |
my $lctype = lc(&Apache::loncommon::course_type()); |
my $lctype = lc(&Apache::loncommon::course_type()); |
&Apache::lonnet::logthis('Error saving whatsnew countunread setting'. |
&Apache::lonnet::logthis('Error saving whatsnew countunread setting'. |
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); |
' '.$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].', |
' due to [_2].', |
'<b>'.&mt($env{'form.countunread'}).'</b>', |
'<b>'.&mt($env{'form.countunread'}).'</b>', |
'<tt>'.$outcome.'</tt>.<br />'); |
'<tt>'.$outcome.'</tt>'),1); |
} |
} |
} |
} |
return $result; |
return &Apache::loncommon::confirmwrapper($result); |
} |
} |
|
|
sub store_courseinit_setting { |
sub store_courseinit_setting { |
Line 1897 sub store_courseinit_setting {
|
Line 2123 sub store_courseinit_setting {
|
\%courseinit_settings,$udom,$uname); |
\%courseinit_settings,$udom,$uname); |
if ($outcome eq 'ok') { |
if ($outcome eq 'ok') { |
if ($page_control eq 'global preferences') { |
if ($page_control eq 'global preferences') { |
$result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>'); |
$result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>')); |
} else { |
} else { |
$result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].' |
$result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].' |
,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'); |
,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>')); |
} |
} |
} else { |
} else { |
&Apache::lonnet::logthis('Error saving whatsnew courseinit '. |
&Apache::lonnet::logthis('Error saving whatsnew courseinit '. |
'setting: '.$outcome.' for '.$uname. |
'setting: '.$outcome.' for '.$uname. |
':'.$udom.' in '.$lctype.' '.$cid); |
':'.$udom.' in '.$lctype.' '.$cid); |
if ($page_control eq 'global preferences') { |
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].', |
' due to [_2].', |
'<b>'.$page_control.'</b>', |
'<b>'.$page_control.'</b>', |
'<tt>'.$outcome.'</tt>.<br />'); |
'<tt>'.$outcome.'</tt>'),1); |
} else { |
} else { |
$result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' |
$result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' |
,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>' |
,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>' |
,'<tt>'.$outcome.'</tt>') |
,'<tt>'.$outcome.'</tt>'),1); |
.'<br />'; |
|
} |
} |
} |
} |
} |
} |
} |
} |
return $result; |
return &Apache::loncommon::confirmwrapper($result); |
} |
} |
|
|
sub start_box { |
sub start_box { |
Line 1952 sub start_box {
|
Line 2177 sub start_box {
|
if ($$show{$caller}) { |
if ($$show{$caller}) { |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
} elsif (($caller eq 'versionchanges') && ($$show{$caller})) { |
} elsif (($caller eq 'versionchanges') && ($$show{$caller})) { |
if ($$show{$caller}) { |
if ($$show{$caller}) { |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
} elsif ($caller eq 'coursediscussion') { |
} elsif ($caller eq 'coursediscussion') { |
if ($$show{$caller}) { |
if ($$show{$caller}) { |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
} elsif (($caller eq 'newroles') && ($$show{$caller})) { |
} elsif (($caller eq 'newroles') && ($$show{$caller})) { |
if ($$show{$caller}) { |
if ($$show{$caller}) { |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
} elsif (($caller eq 'oldroles') && ($$show{$caller})) { |
} elsif (($caller eq 'oldroles') && ($$show{$caller})) { |
if ($$show{$caller}) { |
if ($$show{$caller}) { |
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
} |
} elsif (($caller eq 'crslogin') && ($$show{$caller})) { |
|
if ($$show{$caller}) { |
|
$r->print(' |
|
<tr> |
|
<td class="LC_subheader" align="left"><span class="LC_nobreak"><label><input type="radio" name="logindetails" value="0" checked="checked" onclick="javascript:togglelogins();" /> '.&mt('Summary').'</label><label><input type="radio" name="logindetails" value="1" onclick="javascript:togglelogins();" /> '.&mt('Details').'</label></span></td><td class="LC_subheader"><a href="/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
|
</tr>'); |
|
} |
|
} |
|
|
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td colspan="2"> |
<td colspan="2"> |