version 1.1075.2.63, 2014/01/03 20:04:35
|
version 1.1075.2.89, 2015/04/01 23:42:05
|
Line 69 use Apache::lontexconvert();
|
Line 69 use Apache::lontexconvert();
|
use Apache::lonclonecourse(); |
use Apache::lonclonecourse(); |
use Apache::lonuserutils(); |
use Apache::lonuserutils(); |
use Apache::lonuserstate(); |
use Apache::lonuserstate(); |
|
use Apache::courseclassifier(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale::Catalog; |
use DateTime::Locale::Catalog; |
use Authen::Captcha; |
use Authen::Captcha; |
use Captcha::reCAPTCHA; |
use Captcha::reCAPTCHA; |
|
use Crypt::DES; |
|
use DynaLoader; # for Crypt::DES version |
|
|
# ---------------------------------------------- Designs |
# ---------------------------------------------- Designs |
use vars qw(%defaultdesign); |
use vars qw(%defaultdesign); |
Line 1289 sub helpLatexCheatsheet {
|
Line 1292 sub helpLatexCheatsheet {
|
unless ($not_author) { |
unless ($not_author) { |
$out .= ' <span>' |
$out .= ' <span>' |
.&help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),$stayOnPage,undef,600) |
.&help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),$stayOnPage,undef,600) |
.'</span>'; |
.'</span> <span>' |
|
.&help_open_topic('Authoring_Multilingual_Problems',&mt('Languages'),$stayOnPage,undef,600) |
|
.'</span>'; |
} |
} |
$out .= '</span>'; # End cheatsheet |
$out .= '</span>'; # End cheatsheet |
return $out; |
return $out; |
Line 2336 Outputs:
|
Line 2341 Outputs:
|
|
|
=item * $clientinfo |
=item * $clientinfo |
|
|
|
=item * $clientosversion |
|
|
=back |
=back |
|
|
=back |
=back |
Line 2355 sub decode_user_agent {
|
Line 2362 sub decode_user_agent {
|
my $clientmathml=''; |
my $clientmathml=''; |
my $clientunicode='0'; |
my $clientunicode='0'; |
my $clientmobile=0; |
my $clientmobile=0; |
|
my $clientosversion=''; |
for (my $i=0;$i<=$#browsertype;$i++) { |
for (my $i=0;$i<=$#browsertype;$i++) { |
my ($bname,$match,$notmatch,$vreg,$minv,$univ)=split(/\:/,$browsertype[$i]); |
my ($bname,$match,$notmatch,$vreg,$minv,$univ)=split(/\%/,$browsertype[$i]); |
if (($httpbrowser=~/$match/i) && ($httpbrowser!~/$notmatch/i)) { |
if (($httpbrowser=~/$match/i) && ($httpbrowser!~/$notmatch/i)) { |
$clientbrowser=$bname; |
$clientbrowser=$bname; |
$httpbrowser=~/$vreg/i; |
$httpbrowser=~/$vreg/i; |
Line 2376 sub decode_user_agent {
|
Line 2384 sub decode_user_agent {
|
if ($httpbrowser=~/next/i) { $clientos='next'; } |
if ($httpbrowser=~/next/i) { $clientos='next'; } |
if (($httpbrowser=~/mac/i) || |
if (($httpbrowser=~/mac/i) || |
($httpbrowser=~/powerpc/i)) { $clientos='mac'; } |
($httpbrowser=~/powerpc/i)) { $clientos='mac'; } |
if ($httpbrowser=~/win/i) { $clientos='win'; } |
if ($httpbrowser=~/win/i) { |
|
$clientos='win'; |
|
if ($httpbrowser =~/Windows\s+NT\s+(\d+\.\d+)/i) { |
|
$clientosversion = $1; |
|
} |
|
} |
if ($httpbrowser=~/embed/i) { $clientos='pda'; } |
if ($httpbrowser=~/embed/i) { $clientos='pda'; } |
if ($httpbrowser=~/(Android|iPod|iPad|iPhone|webOS|Blackberry|Windows Phone|Opera m(?:ob|in)|Fennec)/i) { |
if ($httpbrowser=~/(Android|iPod|iPad|iPhone|webOS|Blackberry|Windows Phone|Opera m(?:ob|in)|Fennec)/i) { |
$clientmobile=lc($1); |
$clientmobile=lc($1); |
Line 2387 sub decode_user_agent {
|
Line 2400 sub decode_user_agent {
|
$clientinfo = 'chromeframe-'.$1; |
$clientinfo = 'chromeframe-'.$1; |
} |
} |
return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
$clientunicode,$clientos,$clientmobile,$clientinfo); |
$clientunicode,$clientos,$clientmobile,$clientinfo, |
|
$clientosversion); |
} |
} |
|
|
############################################################### |
############################################################### |
Line 3663 sub user_lang {
|
Line 3677 sub user_lang {
|
=over 4 |
=over 4 |
|
|
=item * &get_previous_attempt($symb, $username, $domain, $course, |
=item * &get_previous_attempt($symb, $username, $domain, $course, |
$getattempt, $regexp, $gradesub) |
$getattempt, $regexp, $gradesub, $usec, $identifier) |
|
|
Return string with previous attempt on problem. Arguments: |
Return string with previous attempt on problem. Arguments: |
|
|
Line 3685 Return string with previous attempt on p
|
Line 3699 Return string with previous attempt on p
|
|
|
=item * $gradesub: routine that processes the string if it matches $regexp |
=item * $gradesub: routine that processes the string if it matches $regexp |
|
|
|
=item * $usec: section of the desired student |
|
|
|
=item * $identifier: counter for student (multiple students one problem) or |
|
problem (one student; whole sequence). |
|
|
=back |
=back |
|
|
The output string is a table containing all desired attempts, if any. |
The output string is a table containing all desired attempts, if any. |
Line 3692 The output string is a table containing
|
Line 3711 The output string is a table containing
|
=cut |
=cut |
|
|
sub get_previous_attempt { |
sub get_previous_attempt { |
my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_; |
my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub,$usec,$identifier)=@_; |
my $prevattempts=''; |
my $prevattempts=''; |
no strict 'refs'; |
no strict 'refs'; |
if ($symb) { |
if ($symb) { |
Line 3708 sub get_previous_attempt {
|
Line 3727 sub get_previous_attempt {
|
} |
} |
$prevattempts=&start_data_table().&start_data_table_header_row(); |
$prevattempts=&start_data_table().&start_data_table_header_row(); |
$prevattempts.='<th>'.&mt('History').'</th>'; |
$prevattempts.='<th>'.&mt('History').'</th>'; |
my (%typeparts,%lasthidden); |
my (%typeparts,%lasthidden,%regraded,%hidestatus); |
my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'}); |
my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'}); |
foreach my $key (sort(keys(%lasthash))) { |
foreach my $key (sort(keys(%lasthash))) { |
my ($ign,@parts) = split(/\./,$key); |
my ($ign,@parts) = split(/\./,$key); |
Line 3725 sub get_previous_attempt {
|
Line 3744 sub get_previous_attempt {
|
$lasthidden{$ign.'.'.$id} = 1; |
$lasthidden{$ign.'.'.$id} = 1; |
} |
} |
} |
} |
|
if ($identifier ne '') { |
|
my $id = join(',',@parts); |
|
if (&Apache::lonnet::EXT("resource.$id.problemstatus",$symb, |
|
$domain,$username,$usec,undef,$course) =~ /^no/) { |
|
$hidestatus{$ign.'.'.$id} = 1; |
|
} |
|
} |
|
} elsif ($data eq 'regrader') { |
|
if (($identifier ne '') && (@parts)) { |
|
my $id = join(',',@parts); |
|
$regraded{$ign.'.'.$id} = 1; |
|
} |
} |
} |
} else { |
} else { |
if ($#parts == 0) { |
if ($#parts == 0) { |
Line 3736 sub get_previous_attempt {
|
Line 3767 sub get_previous_attempt {
|
} |
} |
$prevattempts.=&end_data_table_header_row(); |
$prevattempts.=&end_data_table_header_row(); |
if ($getattempt eq '') { |
if ($getattempt eq '') { |
|
my (%solved,%resets,%probstatus); |
|
if (($identifier ne '') && (keys(%regraded) > 0)) { |
|
for ($version=1;$version<=$returnhash{'version'};$version++) { |
|
foreach my $id (keys(%regraded)) { |
|
if (($returnhash{$version.':'.$id.'.regrader'}) && |
|
($returnhash{$version.':'.$id.'.tries'} eq '') && |
|
($returnhash{$version.':'.$id.'.award'} eq '')) { |
|
push(@{$resets{$id}},$version); |
|
} |
|
} |
|
} |
|
} |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
my @hidden; |
my (@hidden,@unsolved); |
if (%typeparts) { |
if (%typeparts) { |
foreach my $id (keys(%typeparts)) { |
foreach my $id (keys(%typeparts)) { |
if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) { |
if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || |
|
($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) { |
push(@hidden,$id); |
push(@hidden,$id); |
|
} elsif ($identifier ne '') { |
|
unless (($returnhash{$version.':'.$id.'.type'} eq 'survey') || |
|
($returnhash{$version.':'.$id.'.type'} eq 'surveycred') || |
|
($hidestatus{$id})) { |
|
next if ((ref($resets{$id}) eq 'ARRAY') && grep(/^\Q$version\E$/,@{$resets{$id}})); |
|
if ($returnhash{$version.':'.$id.'.solved'} eq 'correct_by_student') { |
|
push(@{$solved{$id}},$version); |
|
} elsif (($returnhash{$version.':'.$id.'.solved'} ne '') && |
|
(ref($solved{$id}) eq 'ARRAY')) { |
|
my $skip; |
|
if (ref($resets{$id}) eq 'ARRAY') { |
|
foreach my $reset (@{$resets{$id}}) { |
|
if ($reset > $solved{$id}[-1]) { |
|
$skip=1; |
|
last; |
|
} |
|
} |
|
} |
|
unless ($skip) { |
|
my ($ign,$partslist) = split(/\./,$id,2); |
|
push(@unsolved,$partslist); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
$prevattempts.=&start_data_table_row(). |
$prevattempts.=&start_data_table_row(). |
'<td>'.&mt('Transaction [_1]',$version).'</td>'; |
'<td>'.&mt('Transaction [_1]',$version); |
|
if (@unsolved) { |
|
$prevattempts .= '<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="HIDE'.$identifier.'" value="'.$version.':'.join('_',@unsolved).'" />'. |
|
&mt('Hide').'</label></span>'; |
|
} |
|
$prevattempts .= '</td>'; |
if (@hidden) { |
if (@hidden) { |
foreach my $key (sort(keys(%lasthash))) { |
foreach my $key (sort(keys(%lasthash))) { |
next if ($key =~ /\.foilorder$/); |
next if ($key =~ /\.foilorder$/); |
Line 4231 sub findallcourses {
|
Line 4305 sub findallcourses {
|
############################################### |
############################################### |
|
|
sub blockcheck { |
sub blockcheck { |
my ($setters,$activity,$uname,$udom,$url) = @_; |
my ($setters,$activity,$uname,$udom,$url,$is_course) = @_; |
|
|
if (!defined($udom)) { |
if (defined($udom) && defined($uname)) { |
|
# If uname and udom are for a course, check for blocks in the course. |
|
if (($is_course) || (&Apache::lonnet::is_course($udom,$uname))) { |
|
my ($startblock,$endblock,$triggerblock) = |
|
&get_blocks($setters,$activity,$udom,$uname,$url); |
|
return ($startblock,$endblock,$triggerblock); |
|
} |
|
} else { |
$udom = $env{'user.domain'}; |
$udom = $env{'user.domain'}; |
} |
|
if (!defined($uname)) { |
|
$uname = $env{'user.name'}; |
$uname = $env{'user.name'}; |
} |
} |
|
|
# If uname and udom are for a course, check for blocks in the course. |
|
|
|
if (&Apache::lonnet::is_course($udom,$uname)) { |
|
my ($startblock,$endblock,$triggerblock) = |
|
&get_blocks($setters,$activity,$udom,$uname,$url); |
|
return ($startblock,$endblock,$triggerblock); |
|
} |
|
|
|
my $startblock = 0; |
my $startblock = 0; |
my $endblock = 0; |
my $endblock = 0; |
my $triggerblock = ''; |
my $triggerblock = ''; |
Line 4257 sub blockcheck {
|
Line 4328 sub blockcheck {
|
# boards, chat or groups, check for blocking in current course only. |
# boards, chat or groups, check for blocking in current course only. |
|
|
if (($activity eq 'boards' || $activity eq 'chat' || |
if (($activity eq 'boards' || $activity eq 'chat' || |
$activity eq 'groups') && ($env{'request.course.id'})) { |
$activity eq 'groups' || $activity eq 'printout') && |
|
($env{'request.course.id'})) { |
foreach my $key (keys(%live_courses)) { |
foreach my $key (keys(%live_courses)) { |
if ($key ne $env{'request.course.id'}) { |
if ($key ne $env{'request.course.id'}) { |
delete($live_courses{$key}); |
delete($live_courses{$key}); |
Line 4521 sub parse_block_record {
|
Line 4593 sub parse_block_record {
|
} |
} |
|
|
sub blocking_status { |
sub blocking_status { |
my ($activity,$uname,$udom,$url) = @_; |
my ($activity,$uname,$udom,$url,$is_course) = @_; |
my %setters; |
my %setters; |
|
|
# check for active blocking |
# check for active blocking |
my ($startblock,$endblock,$triggerblock) = |
my ($startblock,$endblock,$triggerblock) = |
&blockcheck(\%setters,$activity,$uname,$udom,$url); |
&blockcheck(\%setters,$activity,$uname,$udom,$url,$is_course); |
my $blocked = 0; |
my $blocked = 0; |
if ($startblock && $endblock) { |
if ($startblock && $endblock) { |
$blocked = 1; |
$blocked = 1; |
Line 4683 sub get_domainconf {
|
Line 4755 sub get_domainconf {
|
if (keys(%{$domconfig{'login'}})) { |
if (keys(%{$domconfig{'login'}})) { |
foreach my $key (keys(%{$domconfig{'login'}})) { |
foreach my $key (keys(%{$domconfig{'login'}})) { |
if (ref($domconfig{'login'}{$key}) eq 'HASH') { |
if (ref($domconfig{'login'}{$key}) eq 'HASH') { |
if ($key eq 'loginvia') { |
if (($key eq 'loginvia') || ($key eq 'headtag')) { |
if (ref($domconfig{'login'}{'loginvia'}) eq 'HASH') { |
if (ref($domconfig{'login'}{$key}) eq 'HASH') { |
foreach my $hostname (keys(%{$domconfig{'login'}{'loginvia'}})) { |
foreach my $hostname (keys(%{$domconfig{'login'}{$key}})) { |
if (ref($domconfig{'login'}{'loginvia'}{$hostname}) eq 'HASH') { |
if (ref($domconfig{'login'}{$key}{$hostname}) eq 'HASH') { |
if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) { |
if ($key eq 'loginvia') { |
my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'}; |
if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) { |
$designhash{$udom.'.login.loginvia'} = $server; |
my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'}; |
if ($domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'} eq 'custom') { |
$designhash{$udom.'.login.loginvia'} = $server; |
|
if ($domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'} eq 'custom') { |
$designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'}; |
$designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'}; |
} else { |
} else { |
$designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; |
$designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'}; |
|
} |
} |
} |
if ($domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}) { |
} elsif ($key eq 'headtag') { |
$designhash{$udom.'.login.loginvia_exempt_'.$hostname} = $domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}; |
if ($domconfig{'login'}{'headtag'}{$hostname}{'url'}) { |
|
$designhash{$udom.'.login.headtag_'.$hostname} = $domconfig{'login'}{'headtag'}{$hostname}{'url'}; |
} |
} |
} |
} |
|
if ($domconfig{'login'}{$key}{$hostname}{'exempt'}) { |
|
$designhash{$udom.'.login.'.$key.'_exempt_'.$hostname} = $domconfig{'login'}{$key}{$hostname}{'exempt'}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 5066 sub bodytag {
|
Line 5143 sub bodytag {
|
@design{keys(%$addentries)} = @$addentries{keys(%$addentries)}; |
@design{keys(%$addentries)} = @$addentries{keys(%$addentries)}; |
|
|
# role and realm |
# role and realm |
my ($role,$realm) = split(/\./,$env{'request.role'},2); |
my ($role,$realm) = split(m{\./},$env{'request.role'},2); |
|
if ($realm) { |
|
$realm = '/'.$realm; |
|
} |
if ($role eq 'ca') { |
if ($role eq 'ca') { |
my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$}); |
my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$}); |
$realm = &plainname($rname,$rdom); |
$realm = &plainname($rname,$rdom); |
Line 7288 sub headtag {
|
Line 7368 sub headtag {
|
'<head>'. |
'<head>'. |
&font_settings($args); |
&font_settings($args); |
|
|
my $inhibitprint = &print_suppression(); |
my $inhibitprint; |
|
if ($args->{'print_suppress'}) { |
|
$inhibitprint = &print_suppression(); |
|
} |
|
|
if (!$args->{'frameset'}) { |
if (!$args->{'frameset'}) { |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
Line 7328 sub headtag {
|
Line 7411 sub headtag {
|
<meta http-equiv="pragma" content="no-cache" /> |
<meta http-equiv="pragma" content="no-cache" /> |
<meta http-equiv="Refresh" content="$time; url=$url" /> |
<meta http-equiv="Refresh" content="$time; url=$url" /> |
ADDMETA |
ADDMETA |
|
} else { |
|
unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) { |
|
my $requrl = $env{'request.uri'}; |
|
if ($requrl eq '') { |
|
$requrl = $ENV{'REQUEST_URI'}; |
|
$requrl =~ s/\?.+$//; |
|
} |
|
unless (($requrl =~ m{^/adm/(?:switchserver|login|authenticate|logout|groupsort|cleanup|helper|slotrequest|grades)(\?|$)}) || |
|
(($requrl =~ m{^/res/}) && (($env{'form.submitted'} eq 'scantron') || |
|
($env{'form.grade_symb'}) || ($Apache::lonhomework::scantronmode)))) { |
|
my $dom_in_use = $Apache::lonnet::perlvar{'lonDefDomain'}; |
|
unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); |
|
if (ref($domdefs{'offloadnow'}) eq 'HASH') { |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
if ($domdefs{'offloadnow'}{$lonhost}) { |
|
my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); |
|
if (($newserver) && ($newserver ne $lonhost)) { |
|
my $numsec = 5; |
|
my $timeout = $numsec * 1000; |
|
my ($newurl,$locknum,%locks,$msg); |
|
if ($env{'request.role.adv'}) { |
|
($locknum,%locks) = &Apache::lonnet::get_locks(); |
|
} |
|
my $disable_submit = 0; |
|
if ($requrl =~ /$LONCAPA::assess_re/) { |
|
$disable_submit = 1; |
|
} |
|
if ($locknum) { |
|
my @lockinfo = sort(values(%locks)); |
|
$msg = &mt('Once the following tasks are complete: ')."\\n". |
|
join(", ",sort(values(%locks)))."\\n". |
|
&mt('your session will be transferred to a different server, after you click "Roles".'); |
|
} else { |
|
if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) { |
|
$msg = &mt('Your LON-CAPA submission has been recorded')."\\n"; |
|
} |
|
$msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec); |
|
$newurl = '/adm/switchserver?otherserver='.$newserver; |
|
if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) { |
|
$newurl .= '&role='.$env{'request.role'}; |
|
} |
|
if ($env{'request.symb'}) { |
|
$newurl .= '&symb='.$env{'request.symb'}; |
|
} else { |
|
$newurl .= '&origurl='.$requrl; |
|
} |
|
} |
|
$result.=<<OFFLOAD |
|
<meta http-equiv="pragma" content="no-cache" /> |
|
<script type="text/javascript"> |
|
function LC_Offload_Now() { |
|
var dest = "$newurl"; |
|
if (dest != '') { |
|
window.location.href="$newurl"; |
|
} |
|
} |
|
window.alert('$msg'); |
|
if ($disable_submit) { |
|
\$(document).ready(function () { |
|
\$(".LC_hwk_submit").prop("disabled", true); |
|
\$( ".LC_textline" ).prop( "readonly", "readonly"); |
|
}); |
|
} |
|
setTimeout('LC_Offload_Now()', $timeout); |
|
</script> |
|
OFFLOAD |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
} |
if (!defined($title)) { |
if (!defined($title)) { |
$title = 'The LearningOnline Network with CAPA'; |
$title = 'The LearningOnline Network with CAPA'; |
Line 7414 sub print_suppression {
|
Line 7570 sub print_suppression {
|
} |
} |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $blocked = &blocking_status('printout',$cnum,$cdom); |
my $blocked = &blocking_status('printout',$cnum,$cdom,undef,1); |
if ($blocked) { |
if ($blocked) { |
my $checkrole = "cm./$cdom/$cnum"; |
my $checkrole = "cm./$cdom/$cnum"; |
if ($env{'request.course.sec'} ne '') { |
if ($env{'request.course.sec'} ne '') { |
Line 7653 function set_wishlistlink(title, path) {
|
Line 7809 function set_wishlistlink(title, path) {
|
title = document.title; |
title = document.title; |
title = title.replace(/^LON-CAPA /,''); |
title = title.replace(/^LON-CAPA /,''); |
} |
} |
|
title = encodeURIComponent(title); |
|
title = title.replace("'","\\\'"); |
if (!path) { |
if (!path) { |
path = location.pathname; |
path = location.pathname; |
} |
} |
|
path = encodeURIComponent(path); |
|
path = path.replace("'","\\\'"); |
Win = window.open('/adm/wishlist?mode=newLink&setTitle='+title+'&setPath='+path, |
Win = window.open('/adm/wishlist?mode=newLink&setTitle='+title+'&setPath='+path, |
'wishlistNewLink','width=560,height=350,scrollbars=0'); |
'wishlistNewLink','width=560,height=350,scrollbars=0'); |
} |
} |
Line 7698 var modalWindow = {
|
Line 7858 var modalWindow = {
|
}; |
}; |
var openMyModal = function(source,width,height,scrolling,transparency,style) |
var openMyModal = function(source,width,height,scrolling,transparency,style) |
{ |
{ |
|
source = source.replace("'","'"); |
modalWindow.windowId = "myModal"; |
modalWindow.windowId = "myModal"; |
modalWindow.width = width; |
modalWindow.width = width; |
modalWindow.height = height; |
modalWindow.height = height; |
modalWindow.content = "<iframe width='"+width+"' height='"+height+"' frameborder='0' scrolling='"+scrolling+"' allowtransparency='"+transparency+"' src='" + source + "' style='"+style+"'></iframe>"; |
modalWindow.content = "<iframe width='"+width+"' height='"+height+"' frameborder='0' scrolling='"+scrolling+"' allowtransparency='"+transparency+"' src='" + source + "' style='"+style+"'></iframe>"; |
modalWindow.open(); |
modalWindow.open(); |
}; |
}; |
// END LON-CAPA Internal --> |
// END LON-CAPA Internal --> |
// ]]> |
// ]]> |
</script> |
</script> |
Line 8305 role status: active, previous or future.
|
Line 8466 role status: active, previous or future.
|
sub check_user_status { |
sub check_user_status { |
my ($udom,$uname,$cdom,$crs,$role,$sec) = @_; |
my ($udom,$uname,$cdom,$crs,$role,$sec) = @_; |
my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname); |
my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname); |
my @uroles = keys %userinfo; |
my @uroles = keys(%userinfo); |
my $srchstr; |
my $srchstr; |
my $active_chk = 'none'; |
my $active_chk = 'none'; |
my $now = time; |
my $now = time; |
Line 8962 sub excess_filesize_warning {
|
Line 9123 sub excess_filesize_warning {
|
} |
} |
$disk_quota = int($disk_quota * 1000); |
$disk_quota = int($disk_quota * 1000); |
if (($current_disk_usage + $filesize) > $disk_quota) { |
if (($current_disk_usage + $filesize) > $disk_quota) { |
return '<p><span class="LC_warning">'. |
return '<p class="LC_warning">'. |
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", |
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", |
'<span class="LC_filename">'.$filename.'</span>',$filesize).'</span>'. |
'<span class="LC_filename">'.$filename.'</span>',$filesize).'</p>'. |
'<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.', |
'<p>'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.', |
$disk_quota,$current_disk_usage). |
$disk_quota,$current_disk_usage). |
'</p>'; |
'</p>'; |
} |
} |
Line 9416 sub personal_data_fieldtitles {
|
Line 9577 sub personal_data_fieldtitles {
|
|
|
sub sorted_inst_types { |
sub sorted_inst_types { |
my ($dom) = @_; |
my ($dom) = @_; |
my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom); |
my ($usertypes,$order); |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); |
|
if (ref($domdefaults{'inststatus'}) eq 'HASH') { |
|
$usertypes = $domdefaults{'inststatus'}{'inststatustypes'}; |
|
$order = $domdefaults{'inststatus'}{'inststatusorder'}; |
|
} else { |
|
($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom); |
|
} |
my $othertitle = &mt('All users'); |
my $othertitle = &mt('All users'); |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$othertitle = &mt('Any users'); |
$othertitle = &mt('Any users'); |
Line 9879 sub ask_for_embedded_content {
|
Line 10047 sub ask_for_embedded_content {
|
($path) = |
($path) = |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
} |
} |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
if ($toplevel=~/^\/*(uploaded|editupload)/) { |
|
$fileloc = $toplevel; |
|
$fileloc=~ s/^\s*(\S+)\s*$/$1/; |
|
my ($udom,$uname,$fname) = |
|
($fileloc=~ m{^/+(?:uploaded|editupload)/+($match_domain)/+($match_name)/+(.*)$}); |
|
$fileloc = propath($udom,$uname).'/userfiles/'.$fname; |
|
} else { |
|
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
|
} |
$fileloc =~ s{^/}{}; |
$fileloc =~ s{^/}{}; |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
Line 10910 sub check_for_upload {
|
Line 11086 sub check_for_upload {
|
if ($currsize < $filesize) { |
if ($currsize < $filesize) { |
my $extra = $filesize - $currsize; |
my $extra = $filesize - $currsize; |
if (($current_disk_usage + $extra) > $disk_quota) { |
if (($current_disk_usage + $extra) > $disk_quota) { |
my $msg = '<span class="LC_error">'. |
my $msg = '<p class="LC_warning">'. |
&mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded if existing (smaller) file with same name (size = [_3] kilobytes) is replaced.', |
&mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded if existing (smaller) file with same name (size = [_3] kilobytes) is replaced.', |
'<span class="LC_filename">'.$fname.'</span>',$filesize,$currsize).'</span>'. |
'<span class="LC_filename">'.$fname.'</span>',$filesize,$currsize).'</p>'. |
'<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.', |
'<p>'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.', |
$disk_quota,$current_disk_usage); |
$disk_quota,$current_disk_usage).'</p>'; |
return ('will_exceed_quota',$msg); |
return ('will_exceed_quota',$msg); |
} |
} |
} |
} |
Line 10923 sub check_for_upload {
|
Line 11099 sub check_for_upload {
|
} |
} |
} |
} |
if (($current_disk_usage + $filesize) > $disk_quota){ |
if (($current_disk_usage + $filesize) > $disk_quota){ |
my $msg = '<span class="LC_error">'. |
my $msg = '<p class="LC_warning">'. |
&mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.','<span class="LC_filename">'.$fname.'</span>',$filesize).'</span>'. |
&mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.','<span class="LC_filename">'.$fname.'</span>',$filesize).'</p>'. |
'<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage); |
'<p>'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage).'</p>'; |
return ('will_exceed_quota',$msg); |
return ('will_exceed_quota',$msg); |
} elsif ($found_file) { |
} elsif ($found_file) { |
if ($locked_file) { |
if ($locked_file) { |
my $msg = '<span class="LC_error">'; |
my $msg = '<p class="LC_warning">'; |
$msg .= &mt('Unable to upload [_1]. A locked file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>','<span class="LC_filename">'.$port_path.$env{'form.currentpath'}.'</span>'); |
$msg .= &mt('Unable to upload [_1]. A locked file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>','<span class="LC_filename">'.$port_path.$env{'form.currentpath'}.'</span>'); |
$msg .= '</span><br />'; |
$msg .= '</p>'; |
$msg .= &mt('You will be able to rename or delete existing [_1] after a grade has been assigned.','<span class="LC_filename">'.$fname.'</span>'); |
$msg .= &mt('You will be able to rename or delete existing [_1] after a grade has been assigned.','<span class="LC_filename">'.$fname.'</span>'); |
return ('file_locked',$msg); |
return ('file_locked',$msg); |
} else { |
} else { |
my $msg = '<span class="LC_error">'; |
my $msg = '<p class="LC_error">'; |
$msg .= &mt(' A file by that name: [_1] was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$port_path.$env{'form.currentpath'}); |
$msg .= &mt(' A file by that name: [_1] was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$port_path.$env{'form.currentpath'}); |
$msg .= '</span>'; |
$msg .= '</p>'; |
return ('existingfile',$msg); |
return ('existingfile',$msg); |
} |
} |
} |
} |
Line 11035 sub decompress_form {
|
Line 11211 sub decompress_form {
|
"$topdir/media/player.swf", |
"$topdir/media/player.swf", |
"$topdir/media/swfobject.js", |
"$topdir/media/swfobject.js", |
"$topdir/media/expressInstall.swf"); |
"$topdir/media/expressInstall.swf"); |
my @camtasia8 = ("$topdir/","$topdir/$topdir.html", |
my @camtasia8_1 = ("$topdir/","$topdir/$topdir.html", |
"$topdir/$topdir.mp4", |
"$topdir/$topdir.mp4", |
"$topdir/$topdir\_config.xml", |
"$topdir/$topdir\_config.xml", |
"$topdir/$topdir\_controller.swf", |
"$topdir/$topdir\_controller.swf", |
Line 11057 sub decompress_form {
|
Line 11233 sub decompress_form {
|
"$topdir/skins/express_show/", |
"$topdir/skins/express_show/", |
"$topdir/skins/express_show/player-min.css", |
"$topdir/skins/express_show/player-min.css", |
"$topdir/skins/express_show/spritesheet.png"); |
"$topdir/skins/express_show/spritesheet.png"); |
|
my @camtasia8_4 = ("$topdir/","$topdir/$topdir.html", |
|
"$topdir/$topdir.mp4", |
|
"$topdir/$topdir\_config.xml", |
|
"$topdir/$topdir\_controller.swf", |
|
"$topdir/$topdir\_embed.css", |
|
"$topdir/$topdir\_First_Frame.png", |
|
"$topdir/$topdir\_player.html", |
|
"$topdir/$topdir\_Thumbnails.png", |
|
"$topdir/playerProductInstall.swf", |
|
"$topdir/scripts/", |
|
"$topdir/scripts/config_xml.js", |
|
"$topdir/scripts/techsmith-smart-player.min.js", |
|
"$topdir/skins/", |
|
"$topdir/skins/configuration_express.xml", |
|
"$topdir/skins/express_show/", |
|
"$topdir/skins/express_show/spritesheet.min.css", |
|
"$topdir/skins/express_show/spritesheet.png", |
|
"$topdir/skins/express_show/techsmith-smart-player.min.css"); |
my @diffs = &compare_arrays(\@paths,\@camtasia6); |
my @diffs = &compare_arrays(\@paths,\@camtasia6); |
if (@diffs == 0) { |
if (@diffs == 0) { |
$is_camtasia = 6; |
$is_camtasia = 6; |
} else { |
} else { |
@diffs = &compare_arrays(\@paths,\@camtasia8); |
@diffs = &compare_arrays(\@paths,\@camtasia8_1); |
if (@diffs == 0) { |
if (@diffs == 0) { |
$is_camtasia = 8; |
$is_camtasia = 8; |
|
} else { |
|
@diffs = &compare_arrays(\@paths,\@camtasia8_4); |
|
if (@diffs == 0) { |
|
$is_camtasia = 8; |
|
} |
} |
} |
} |
} |
} |
} |
Line 11261 sub decompress_uploaded_file {
|
Line 11460 sub decompress_uploaded_file {
|
sub process_decompression { |
sub process_decompression { |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($dir,$error,$warning,$output); |
my ($dir,$error,$warning,$output); |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i) { |
$error = &mt('Filename not a supported archive file type.'). |
$error = &mt('Filename not a supported archive file type.'). |
'<br />'.&mt('Filename should end with one of: [_1].', |
'<br />'.&mt('Filename should end with one of: [_1].', |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
Line 13652 sub assign_category_rows {
|
Line 13851 sub assign_category_rows {
|
return $text; |
return $text; |
} |
} |
|
|
|
=pod |
|
|
|
=back |
|
|
|
=cut |
|
|
############################################################ |
############################################################ |
############################################################ |
############################################################ |
|
|
Line 14424 sub escape_url {
|
Line 14629 sub escape_url {
|
my ($url) = @_; |
my ($url) = @_; |
my @urlslices = split(/\//, $url,-1); |
my @urlslices = split(/\//, $url,-1); |
my $lastitem = &escape(pop(@urlslices)); |
my $lastitem = &escape(pop(@urlslices)); |
return join('/',@urlslices).'/'.$lastitem; |
return &HTML::Entities::encode(join('/',@urlslices),"'").'/'.$lastitem; |
} |
} |
|
|
sub compare_arrays { |
sub compare_arrays { |
Line 14482 sub init_user_environment {
|
Line 14687 sub init_user_environment {
|
} |
} |
} |
} |
closedir(DIR); |
closedir(DIR); |
|
# If there is a undeleted lockfile for the user's paste buffer remove it. |
|
my $namespace = 'nohist_courseeditor'; |
|
my $lockingkey = 'paste'."\0".'locked_num'; |
|
my %lockhash = &Apache::lonnet::get($namespace,[$lockingkey], |
|
$domain,$username); |
|
if (exists($lockhash{$lockingkey})) { |
|
my $delresult = &Apache::lonnet::del($namespace,[$lockingkey],$domain,$username); |
|
unless ($delresult eq 'ok') { |
|
&Apache::lonnet::logthis("Failed to delete paste buffer locking key in $namespace for ".$username.":".$domain." Result was: $delresult"); |
|
} |
|
} |
} |
} |
# Give them a new cookie |
# Give them a new cookie |
my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'} |
my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'} |
Line 14495 sub init_user_environment {
|
Line 14711 sub init_user_environment {
|
} |
} |
# ------------------------------------ Check browser type and MathML capability |
# ------------------------------------ Check browser type and MathML capability |
|
|
my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml,$clientunicode, |
$clientunicode,$clientos,$clientmobile,$clientinfo) = &decode_user_agent($r); |
$clientos,$clientmobile,$clientinfo,$clientosversion) = &decode_user_agent($r); |
|
|
# ------------------------------------------------------------- Get environment |
# ------------------------------------------------------------- Get environment |
|
|
Line 14529 sub init_user_environment {
|
Line 14745 sub init_user_environment {
|
"browser.os" => $clientos, |
"browser.os" => $clientos, |
"browser.mobile" => $clientmobile, |
"browser.mobile" => $clientmobile, |
"browser.info" => $clientinfo, |
"browser.info" => $clientinfo, |
|
"browser.osversion" => $clientosversion, |
"server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'}, |
"server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'}, |
"request.course.fn" => '', |
"request.course.fn" => '', |
"request.course.uri" => '', |
"request.course.uri" => '', |
Line 14671 sub clean_symb {
|
Line 14888 sub clean_symb {
|
return ($symb,$enc); |
return ($symb,$enc); |
} |
} |
|
|
sub build_release_hashes { |
############################################################ |
my ($checkparms,$checkresponsetypes,$checkcrstypes,$anonsurvey,$randomizetry) = @_; |
############################################################ |
return unless((ref($checkparms) eq 'HASH') && (ref($checkresponsetypes) eq 'HASH') && |
|
(ref($checkcrstypes) eq 'HASH') && (ref($anonsurvey) eq 'HASH') && |
=pod |
(ref($randomizetry) eq 'HASH')); |
|
foreach my $key (keys(%Apache::lonnet::needsrelease)) { |
=head1 Routines for building display used to search for courses |
my ($item,$name,$value) = split(/:/,$key); |
|
if ($item eq 'parameter') { |
|
if (ref($checkparms->{$name}) eq 'ARRAY') { |
=over 4 |
unless(grep(/^\Q$name\E$/,@{$checkparms->{$name}})) { |
|
push(@{$checkparms->{$name}},$value); |
=item * &build_filters() |
} |
|
|
Create markup for a table used to set filters to use when selecting |
|
courses in a domain. Used by lonpickcourse.pm, lonmodifycourse.pm |
|
and quotacheck.pl |
|
|
|
|
|
Inputs: |
|
|
|
filterlist - anonymous array of fields to include as potential filters |
|
|
|
crstype - course type |
|
|
|
roleelement - fifth arg in selectcourse_link() populates fifth arg in javascript: opencrsbrowser() function, used |
|
to pop-open a course selector (will contain "extra element"). |
|
|
|
multelement - if multiple course selections will be allowed, this will be a hidden form element: name: multiple; value: 1 |
|
|
|
filter - anonymous hash of criteria and their values |
|
|
|
action - form action |
|
|
|
numfiltersref - ref to scalar (count of number of elements in institutional codes -- e.g., 4 for year, semester, department, and number) |
|
|
|
caller - caller context (e.g., set to 'modifycourse' when routine is called from lonmodifycourse.pm) |
|
|
|
cloneruname - username of owner of new course who wants to clone |
|
|
|
clonerudom - domain of owner of new course who wants to clone |
|
|
|
typeelem - text to use for left column in row containing course type (i.e., Course, Community or Course/Community) |
|
|
|
codetitlesref - reference to array of titles of components in institutional codes (official courses) |
|
|
|
codedom - domain |
|
|
|
formname - value of form element named "form". |
|
|
|
fixeddom - domain, if fixed. |
|
|
|
prevphase - value to assign to form element named "phase" when going back to the previous screen |
|
|
|
cnameelement - name of form element in form on opener page which will receive title of selected course |
|
|
|
cnumelement - name of form element in form on opener page which will receive courseID of selected course |
|
|
|
cdomelement - name of form element in form on opener page which will receive domain of selected course |
|
|
|
setroles - includes access constraint identifier when setting a roles-based condition for acces to a portfolio file |
|
|
|
clonetext - hidden form elements containing list of courses cloneable by intended course owner when DC creates a course |
|
|
|
clonewarning - warning message about missing information for intended course owner when DC creates a course |
|
|
|
|
|
Returns: $output - HTML for display of search criteria, and hidden form elements. |
|
|
|
|
|
Side Effects: None |
|
|
|
=cut |
|
|
|
# ---------------------------------------------- search for courses based on last activity etc. |
|
|
|
sub build_filters { |
|
my ($filterlist,$crstype,$roleelement,$multelement,$filter,$action, |
|
$numtitlesref,$caller,$cloneruname,$clonerudom,$typeelement, |
|
$codetitlesref,$codedom,$formname,$fixeddom,$prevphase, |
|
$cnameelement,$cnumelement,$cdomelement,$setroles, |
|
$clonetext,$clonewarning) = @_; |
|
my ($list,$jscript); |
|
my $onchange = 'javascript:updateFilters(this)'; |
|
my ($domainselectform,$sincefilterform,$createdfilterform, |
|
$ownerdomselectform,$persondomselectform,$instcodeform, |
|
$typeselectform,$instcodetitle); |
|
if ($formname eq '') { |
|
$formname = $caller; |
|
} |
|
foreach my $item (@{$filterlist}) { |
|
unless (($item eq 'descriptfilter') || ($item eq 'instcodefilter') || |
|
($item eq 'sincefilter') || ($item eq 'createdfilter')) { |
|
if ($item eq 'domainfilter') { |
|
$filter->{$item} = &LONCAPA::clean_domain($filter->{$item}); |
|
} elsif ($item eq 'coursefilter') { |
|
$filter->{$item} = &LONCAPA::clean_courseid($filter->{$item}); |
|
} elsif ($item eq 'ownerfilter') { |
|
$filter->{$item} = &LONCAPA::clean_username($filter->{$item}); |
|
} elsif ($item eq 'ownerdomfilter') { |
|
$filter->{'ownerdomfilter'} = |
|
&LONCAPA::clean_domain($filter->{$item}); |
|
$ownerdomselectform = &select_dom_form($filter->{'ownerdomfilter'}, |
|
'ownerdomfilter',1); |
|
} elsif ($item eq 'personfilter') { |
|
$filter->{$item} = &LONCAPA::clean_username($filter->{$item}); |
|
} elsif ($item eq 'persondomfilter') { |
|
$persondomselectform = &select_dom_form($filter->{'persondomfilter'}, |
|
'persondomfilter',1); |
} else { |
} else { |
push(@{$checkparms->{$name}},$value); |
$filter->{$item} =~ s/\W//g; |
} |
} |
} elsif ($item eq 'resourcetag') { |
if (!$filter->{$item}) { |
if ($name eq 'responsetype') { |
$filter->{$item} = ''; |
$checkresponsetypes->{$value} = $Apache::lonnet::needsrelease{$key} |
|
} |
} |
} elsif ($item eq 'course') { |
} |
if ($name eq 'crstype') { |
if ($item eq 'domainfilter') { |
$checkcrstypes->{$value} = $Apache::lonnet::needsrelease{$key}; |
my $allow_blank = 1; |
|
if ($formname eq 'portform') { |
|
$allow_blank=0; |
|
} elsif ($formname eq 'studentform') { |
|
$allow_blank=0; |
} |
} |
|
if ($fixeddom) { |
|
$domainselectform = '<input type="hidden" name="domainfilter"'. |
|
' value="'.$codedom.'" />'. |
|
&Apache::lonnet::domain($codedom,'description'); |
|
} else { |
|
$domainselectform = &select_dom_form($filter->{$item}, |
|
'domainfilter', |
|
$allow_blank,'',$onchange); |
|
} |
|
} else { |
|
$list->{$item} = &HTML::Entities::encode($filter->{$item},'<>&"'); |
|
} |
|
} |
|
|
|
# last course activity filter and selection |
|
$sincefilterform = &timebased_select_form('sincefilter',$filter); |
|
|
|
# course created filter and selection |
|
if (exists($filter->{'createdfilter'})) { |
|
$createdfilterform = &timebased_select_form('createdfilter',$filter); |
|
} |
|
|
|
my %lt = &Apache::lonlocal::texthash( |
|
'cac' => "$crstype Activity", |
|
'ccr' => "$crstype Created", |
|
'cde' => "$crstype Title", |
|
'cdo' => "$crstype Domain", |
|
'ins' => 'Institutional Code', |
|
'inc' => 'Institutional Categorization', |
|
'cow' => "$crstype Owner/Co-owner", |
|
'cop' => "$crstype Personnel Includes", |
|
'cog' => 'Type', |
|
); |
|
|
|
if (($formname eq 'ccrs') || ($formname eq 'requestcrs')) { |
|
my $typeval = 'Course'; |
|
if ($crstype eq 'Community') { |
|
$typeval = 'Community'; |
|
} |
|
$typeselectform = '<input type="hidden" name="type" value="'.$typeval.'" />'; |
|
} else { |
|
$typeselectform = '<select name="type" size="1"'; |
|
if ($onchange) { |
|
$typeselectform .= ' onchange="'.$onchange.'"'; |
|
} |
|
$typeselectform .= '>'."\n"; |
|
foreach my $posstype ('Course','Community') { |
|
$typeselectform.='<option value="'.$posstype.'"'. |
|
($posstype eq $crstype ? ' selected="selected" ' : ''). ">".&mt($posstype)."</option>\n"; |
|
} |
|
$typeselectform.="</select>"; |
|
} |
|
|
|
my ($cloneableonlyform,$cloneabletitle); |
|
if (exists($filter->{'cloneableonly'})) { |
|
my $cloneableon = ''; |
|
my $cloneableoff = ' checked="checked"'; |
|
if ($filter->{'cloneableonly'}) { |
|
$cloneableon = $cloneableoff; |
|
$cloneableoff = ''; |
|
} |
|
$cloneableonlyform = '<span class="LC_nobreak"><label><input type="radio" name="cloneableonly" value="1" '.$cloneableon.'/> '.&mt('Required').'</label>'.(' 'x3).'<label><input type="radio" name="cloneableonly" value="" '.$cloneableoff.' /> '.&mt('No restriction').'</label></span>'; |
|
if ($formname eq 'ccrs') { |
|
$cloneabletitle = &mt('Cloneable for [_1]',$cloneruname.':'.$clonerudom); |
|
} else { |
|
$cloneabletitle = &mt('Cloneable by you'); |
|
} |
|
} |
|
my $officialjs; |
|
if ($crstype eq 'Course') { |
|
if (exists($filter->{'instcodefilter'})) { |
|
# if (($fixeddom) || ($formname eq 'requestcrs') || |
|
# ($formname eq 'modifycourse') || ($formname eq 'filterpicker')) { |
|
if ($codedom) { |
|
$officialjs = 1; |
|
($instcodeform,$jscript,$$numtitlesref) = |
|
&Apache::courseclassifier::instcode_selectors($codedom,'filterpicker', |
|
$officialjs,$codetitlesref); |
|
if ($jscript) { |
|
$jscript = '<script type="text/javascript">'."\n". |
|
'// <![CDATA['."\n". |
|
$jscript."\n". |
|
'// ]]>'."\n". |
|
'</script>'."\n"; |
|
} |
|
} |
|
if ($instcodeform eq '') { |
|
$instcodeform = |
|
'<input type="text" name="instcodefilter" size="10" value="'. |
|
$list->{'instcodefilter'}.'" />'; |
|
$instcodetitle = $lt{'ins'}; |
|
} else { |
|
$instcodetitle = $lt{'inc'}; |
|
} |
|
if ($fixeddom) { |
|
$instcodetitle .= '<br />('.$codedom.')'; |
|
} |
|
} |
|
} |
|
my $output = qq| |
|
<form method="post" name="filterpicker" action="$action"> |
|
<input type="hidden" name="form" value="$formname" /> |
|
|; |
|
if ($formname eq 'modifycourse') { |
|
$output .= '<input type="hidden" name="phase" value="courselist" />'."\n". |
|
'<input type="hidden" name="prevphase" value="'. |
|
$prevphase.'" />'."\n"; |
|
} elsif ($formname eq 'quotacheck') { |
|
$output .= qq| |
|
<input type="hidden" name="sortby" value="" /> |
|
<input type="hidden" name="sortorder" value="" /> |
|
|; |
|
} else { |
|
my $name_input; |
|
if ($cnameelement ne '') { |
|
$name_input = '<input type="hidden" name="cnameelement" value="'. |
|
$cnameelement.'" />'; |
|
} |
|
$output .= qq| |
|
<input type="hidden" name="cnumelement" value="$cnumelement" /> |
|
<input type="hidden" name="cdomelement" value="$cdomelement" /> |
|
$name_input |
|
$roleelement |
|
$multelement |
|
$typeelement |
|
|; |
|
if ($formname eq 'portform') { |
|
$output .= '<input type="hidden" name="setroles" value="'.$setroles.'" />'."\n"; |
} |
} |
} |
} |
($anonsurvey->{major},$anonsurvey->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'}); |
if ($fixeddom) { |
($randomizetry->{major},$randomizetry->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:randomizetry'}); |
$output .= '<input type="hidden" name="fixeddom" value="'.$fixeddom.'" />'."\n"; |
|
} |
|
$output .= "<br />\n".&Apache::lonhtmlcommon::start_pick_box(); |
|
if ($sincefilterform) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cac'}) |
|
.$sincefilterform |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if ($createdfilterform) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'ccr'}) |
|
.$createdfilterform |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if ($domainselectform) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cdo'}) |
|
.$domainselectform |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if ($typeselectform) { |
|
if (($formname eq 'ccrs') || ($formname eq 'requestcrs')) { |
|
$output .= $typeselectform; |
|
} else { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cog'}) |
|
.$typeselectform |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
} |
|
if ($instcodeform) { |
|
$output .= &Apache::lonhtmlcommon::row_title($instcodetitle) |
|
.$instcodeform |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if (exists($filter->{'ownerfilter'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cow'}). |
|
'<table><tr><td>'.&mt('Username').'<br />'. |
|
'<input type="text" name="ownerfilter" size="20" value="'. |
|
$list->{'ownerfilter'}.'" /></td><td>'.&mt('Domain').'<br />'. |
|
$ownerdomselectform.'</td></tr></table>'. |
|
&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if (exists($filter->{'personfilter'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cop'}). |
|
'<table><tr><td>'.&mt('Username').'<br />'. |
|
'<input type="text" name="personfilter" size="20" value="'. |
|
$list->{'personfilter'}.'" /></td><td>'.&mt('Domain').'<br />'. |
|
$persondomselectform.'</td></tr></table>'. |
|
&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if (exists($filter->{'coursefilter'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title(&mt('LON-CAPA course ID')) |
|
.'<input type="text" name="coursefilter" size="25" value="' |
|
.$list->{'coursefilter'}.'" />' |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if ($cloneableonlyform) { |
|
$output .= &Apache::lonhtmlcommon::row_title($cloneabletitle). |
|
$cloneableonlyform.&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
if (exists($filter->{'descriptfilter'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'cde'}) |
|
.'<input type="text" name="descriptfilter" size="40" value="' |
|
.$list->{'descriptfilter'}.'" />' |
|
.&Apache::lonhtmlcommon::row_closure(1); |
|
} |
|
$output .= &Apache::lonhtmlcommon::end_pick_box().'<p>'.$clonetext."\n". |
|
'<input type="hidden" name="updater" value="" />'."\n". |
|
'<input type="submit" name="gosearch" value="'. |
|
&mt('Search').'" /></p>'."\n".'</form>'."\n".'<hr />'."\n"; |
|
return $jscript.$clonewarning.$output; |
|
} |
|
|
|
=pod |
|
|
|
=item * &timebased_select_form() |
|
|
|
Create markup for a dropdown list used to select a time-based |
|
filter e.g., Course Activity, Course Created, when searching for courses |
|
or communities |
|
|
|
Inputs: |
|
|
|
item - name of form element (sincefilter or createdfilter) |
|
|
|
filter - anonymous hash of criteria and their values |
|
|
|
Returns: HTML for a select box contained a blank, then six time selections, |
|
with value set in incoming form variables currently selected. |
|
|
|
Side Effects: None |
|
|
|
=cut |
|
|
|
sub timebased_select_form { |
|
my ($item,$filter) = @_; |
|
if (ref($filter) eq 'HASH') { |
|
$filter->{$item} =~ s/[^\d-]//g; |
|
if (!$filter->{$item}) { $filter->{$item}=-1; } |
|
return &select_form( |
|
$filter->{$item}, |
|
$item, |
|
{ '-1' => '', |
|
'86400' => &mt('today'), |
|
'604800' => &mt('last week'), |
|
'2592000' => &mt('last month'), |
|
'7776000' => &mt('last three months'), |
|
'15552000' => &mt('last six months'), |
|
'31104000' => &mt('last year'), |
|
'select_form_order' => |
|
['-1','86400','604800','2592000','7776000', |
|
'15552000','31104000']}); |
|
} |
|
} |
|
|
|
=pod |
|
|
|
=item * &js_changer() |
|
|
|
Create script tag containing Javascript used to submit course search form |
|
when course type or domain is changed, and also to hide 'Searching ...' on |
|
page load completion for page showing search result. |
|
|
|
Inputs: None |
|
|
|
Returns: markup containing updateFilters() and hideSearching() javascript functions. |
|
|
|
Side Effects: None |
|
|
|
=cut |
|
|
|
sub js_changer { |
|
return <<ENDJS; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function updateFilters(caller) { |
|
if (typeof(caller) != "undefined") { |
|
document.filterpicker.updater.value = caller.name; |
|
} |
|
document.filterpicker.submit(); |
|
} |
|
|
|
function hideSearching() { |
|
if (document.getElementById('searching')) { |
|
document.getElementById('searching').style.display = 'none'; |
|
} |
return; |
return; |
} |
} |
|
|
|
// ]]> |
|
</script> |
|
|
|
ENDJS |
|
} |
|
|
|
=pod |
|
|
|
=item * &search_courses() |
|
|
|
Process selected filters form course search form and pass to lonnet::courseiddump |
|
to retrieve a hash for which keys are courseIDs which match the selected filters. |
|
|
|
Inputs: |
|
|
|
dom - domain being searched |
|
|
|
type - course type ('Course' or 'Community' or '.' if any). |
|
|
|
filter - anonymous hash of criteria and their values |
|
|
|
numtitles - for institutional codes - number of categories |
|
|
|
cloneruname - optional username of new course owner |
|
|
|
clonerudom - optional domain of new course owner |
|
|
|
domcloner - Optional "domcloner" flag; has value=1 if user has ccc priv in domain being filtered by, |
|
(used when DC is using course creation form) |
|
|
|
codetitles - reference to array of titles of components in institutional codes (official courses). |
|
|
|
|
|
Returns: %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type. |
|
|
|
|
|
Side Effects: None |
|
|
|
=cut |
|
|
|
|
|
sub search_courses { |
|
my ($dom,$type,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner,$codetitles) = @_; |
|
my (%courses,%showcourses,$cloner); |
|
if (($filter->{'ownerfilter'} ne '') || |
|
($filter->{'ownerdomfilter'} ne '')) { |
|
$filter->{'combownerfilter'} = $filter->{'ownerfilter'}.':'. |
|
$filter->{'ownerdomfilter'}; |
|
} |
|
foreach my $item ('descriptfilter','coursefilter','combownerfilter') { |
|
if (!$filter->{$item}) { |
|
$filter->{$item}='.'; |
|
} |
|
} |
|
my $now = time; |
|
my $timefilter = |
|
($filter->{'sincefilter'}==-1?1:$now-$filter->{'sincefilter'}); |
|
my ($createdbefore,$createdafter); |
|
if (($filter->{'createdfilter'} ne '') && ($filter->{'createdfilter'} !=-1)) { |
|
$createdbefore = $now; |
|
$createdafter = $now-$filter->{'createdfilter'}; |
|
} |
|
my ($instcodefilter,$regexpok); |
|
if ($numtitles) { |
|
if ($env{'form.official'} eq 'on') { |
|
$instcodefilter = |
|
&Apache::courseclassifier::instcode_search_str($dom,$numtitles,$codetitles); |
|
$regexpok = 1; |
|
} elsif ($env{'form.official'} eq 'off') { |
|
$instcodefilter = &Apache::courseclassifier::instcode_search_str($dom,$numtitles,$codetitles); |
|
unless ($instcodefilter eq '') { |
|
$regexpok = -1; |
|
} |
|
} |
|
} else { |
|
$instcodefilter = $filter->{'instcodefilter'}; |
|
} |
|
if ($instcodefilter eq '') { $instcodefilter = '.'; } |
|
if ($type eq '') { $type = '.'; } |
|
|
|
if (($clonerudom ne '') && ($cloneruname ne '')) { |
|
$cloner = $cloneruname.':'.$clonerudom; |
|
} |
|
%courses = &Apache::lonnet::courseiddump($dom, |
|
$filter->{'descriptfilter'}, |
|
$timefilter, |
|
$instcodefilter, |
|
$filter->{'combownerfilter'}, |
|
$filter->{'coursefilter'}, |
|
undef,undef,$type,$regexpok,undef,undef, |
|
undef,undef,$cloner,$env{'form.cc_clone'}, |
|
$filter->{'cloneableonly'}, |
|
$createdbefore,$createdafter,undef, |
|
$domcloner); |
|
if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) { |
|
my $ccrole; |
|
if ($type eq 'Community') { |
|
$ccrole = 'co'; |
|
} else { |
|
$ccrole = 'cc'; |
|
} |
|
my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'}, |
|
$filter->{'persondomfilter'}, |
|
'userroles',undef, |
|
[$ccrole,'in','ad','ep','ta','cr'], |
|
$dom); |
|
foreach my $role (keys(%rolehash)) { |
|
my ($cnum,$cdom,$courserole) = split(':',$role); |
|
my $cid = $cdom.'_'.$cnum; |
|
if (exists($courses{$cid})) { |
|
if (ref($courses{$cid}) eq 'HASH') { |
|
if (ref($courses{$cid}{roles}) eq 'ARRAY') { |
|
if (!grep(/^\Q$courserole\E$/,@{$courses{$cid}{roles}})) { |
|
push (@{$courses{$cid}{roles}},$courserole); |
|
} |
|
} else { |
|
$courses{$cid}{roles} = [$courserole]; |
|
} |
|
$showcourses{$cid} = $courses{$cid}; |
|
} |
|
} |
|
} |
|
%courses = %showcourses; |
|
} |
|
return %courses; |
|
} |
|
|
|
=pod |
|
|
|
=back |
|
|
|
=head1 Routines for version requirements for current course. |
|
|
|
=over 4 |
|
|
|
=item * &check_release_required() |
|
|
|
Compares required LON-CAPA version with version on server, and |
|
if required version is newer looks for a server with the required version. |
|
|
|
Looks first at servers in user's owen domain; if none suitable, looks at |
|
servers in course's domain are permitted to host sessions for user's domain. |
|
|
|
Inputs: |
|
|
|
$loncaparev - Version on current server (format: Major.Minor.Subrelease-datestamp) |
|
|
|
$courseid - Course ID of current course |
|
|
|
$rolecode - User's current role in course (for switchserver query string). |
|
|
|
$required - LON-CAPA version needed by course (format: Major.Minor). |
|
|
|
|
|
Returns: |
|
|
|
$switchserver - query string tp append to /adm/switchserver call (if |
|
current server's LON-CAPA version is too old. |
|
|
|
$warning - Message is displayed if no suitable server could be found. |
|
|
|
=cut |
|
|
|
sub check_release_required { |
|
my ($loncaparev,$courseid,$rolecode,$required) = @_; |
|
my ($switchserver,$warning); |
|
if ($required ne '') { |
|
my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/); |
|
my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/); |
|
if ($reqdmajor ne '' && $reqdminor ne '') { |
|
my $otherserver; |
|
if (($major eq '' && $minor eq '') || |
|
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
|
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required,1); |
|
my $switchlcrev = |
|
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
|
$userdomserver); |
|
my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/); |
|
if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) || |
|
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
|
my $cdom = $env{'course.'.$courseid.'.domain'}; |
|
if ($cdom ne $env{'user.domain'}) { |
|
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1); |
|
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
|
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
|
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
|
my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
|
my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver); |
|
my $canhost = |
|
&Apache::lonnet::can_host_session($env{'user.domain'}, |
|
$coursedomserver, |
|
$remoterev, |
|
$udomdefaults{'remotesessions'}, |
|
$defdomdefaults{'hostedsessions'}); |
|
|
|
if ($canhost) { |
|
$otherserver = $coursedomserver; |
|
} else { |
|
$warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$courseid.'.internal.releaserequired'}).'<br />'. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain."); |
|
} |
|
} else { |
|
$warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$courseid.'.internal.releaserequired'}).'<br />'.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain)."); |
|
} |
|
} else { |
|
$otherserver = $userdomserver; |
|
} |
|
} |
|
if ($otherserver ne '') { |
|
$switchserver = 'otherserver='.$otherserver.'&role='.$rolecode; |
|
} |
|
} |
|
} |
|
return ($switchserver,$warning); |
|
} |
|
|
|
=pod |
|
|
|
=item * &check_release_result() |
|
|
|
Inputs: |
|
|
|
$switchwarning - Warning message if no suitable server found to host session. |
|
|
|
$switchserver - query string to append to /adm/switchserver containing lonHostID |
|
and current role. |
|
|
|
Returns: HTML to display with information about requirement to switch server. |
|
Either displaying warning with link to Roles/Courses screen or |
|
display link to switchserver. |
|
|
|
=cut |
|
|
|
sub check_release_result { |
|
my ($switchwarning,$switchserver) = @_; |
|
my $output = &start_page('Selected course unavailable on this server'). |
|
'<p class="LC_warning">'; |
|
if ($switchwarning) { |
|
$output .= $switchwarning.'<br /><a href="/adm/roles">'; |
|
if (&show_course()) { |
|
$output .= &mt('Display courses'); |
|
} else { |
|
$output .= &mt('Display roles'); |
|
} |
|
$output .= '</a>'; |
|
} elsif ($switchserver) { |
|
$output .= &mt('This course requires a newer version of LON-CAPA than is installed on this server.'). |
|
'<br />'. |
|
'<a href="/adm/switchserver?'.$switchserver.'">'. |
|
&mt('Switch Server'). |
|
'</a>'; |
|
} |
|
$output .= '</p>'.&end_page(); |
|
return $output; |
|
} |
|
|
|
=pod |
|
|
|
=item * &needs_coursereinit() |
|
|
|
Determine if course contents stored for user's session needs to be |
|
refreshed, because content has changed since "Big Hash" last tied. |
|
|
|
Check for change is made if time last checked is more than 10 minutes ago |
|
(by default). |
|
|
|
Inputs: |
|
|
|
$loncaparev - Version on current server (format: Major.Minor.Subrelease-datestamp) |
|
|
|
$interval (optional) - Time which may elapse (in s) between last check for content |
|
change in current course. (default: 600 s). |
|
|
|
Returns: an array; first element is: |
|
|
|
=over 4 |
|
|
|
'switch' - if content updates mean user's session |
|
needs to be switched to a server running a newer LON-CAPA version |
|
|
|
'update' - if course session needs to be refreshed (i.e., Big Hash needs to be reloaded) |
|
on current server hosting user's session |
|
|
|
'' - if no action required. |
|
|
|
=back |
|
|
|
If first item element is 'switch': |
|
|
|
second item is $switchwarning - Warning message if no suitable server found to host session. |
|
|
|
third item is $switchserver - query string to append to /adm/switchserver containing lonHostID |
|
and current role. |
|
|
|
otherwise: no other elements returned. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
sub needs_coursereinit { |
|
my ($loncaparev,$interval) = @_; |
|
return() unless ($env{'request.course.id'} && $env{'request.course.tied'}); |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $now = time; |
|
if ($interval eq '') { |
|
$interval = 600; |
|
} |
|
if (($now-$env{'request.course.timechecked'})>$interval) { |
|
my $lastchange = &Apache::lonnet::get_coursechange($cdom,$cnum); |
|
&Apache::lonnet::appenv({'request.course.timechecked'=>$now}); |
|
if ($lastchange > $env{'request.course.tied'}) { |
|
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
|
if ($curr_reqd_hash{'internal.releaserequired'} ne '') { |
|
my $required = $env{'course.'.$cdom.'_'.$cnum.'.internal.releaserequired'}; |
|
if ($curr_reqd_hash{'internal.releaserequired'} ne $required) { |
|
&Apache::lonnet::appenv({'course.'.$cdom.'_'.$cnum.'.internal.releaserequired' => |
|
$curr_reqd_hash{'internal.releaserequired'}}); |
|
my ($switchserver,$switchwarning) = |
|
&check_release_required($loncaparev,$cdom.'_'.$cnum,$env{'request.role'}, |
|
$curr_reqd_hash{'internal.releaserequired'}); |
|
if ($switchwarning ne '' || $switchserver ne '') { |
|
return ('switch',$switchwarning,$switchserver); |
|
} |
|
} |
|
} |
|
return ('update'); |
|
} |
|
} |
|
return (); |
|
} |
|
|
sub update_content_constraints { |
sub update_content_constraints { |
my ($cdom,$cnum,$chome,$cid) = @_; |
my ($cdom,$cnum,$chome,$cid) = @_; |
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
Line 14894 sub captcha_display {
|
Line 15812 sub captcha_display {
|
$error = 'recaptcha'; |
$error = 'recaptcha'; |
} |
} |
} |
} |
return ($output,$error); |
return ($output,$error,$captcha); |
} |
} |
|
|
sub captcha_response { |
sub captcha_response { |
Line 14970 sub create_captcha {
|
Line 15888 sub create_captcha {
|
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
&mt('Type in the letters/numbers shown below').' '. |
&mt('Type in the letters/numbers shown below').' '. |
'<input type="text" size="5" name="code" value="" /><br />'. |
'<input type="text" size="5" name="code" value="" autocomplete="off" />'. |
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" />'; |
'<br />'. |
|
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" alt="captcha" />'; |
last; |
last; |
} |
} |
} |
} |
Line 15041 sub check_recaptcha {
|
Line 15960 sub check_recaptcha {
|
return $captcha_chk; |
return $captcha_chk; |
} |
} |
|
|
|
sub emailusername_info { |
|
my @fields = ('firstname','lastname','institution','web','location','officialemail'); |
|
my %titles = &Apache::lonlocal::texthash ( |
|
lastname => 'Last Name', |
|
firstname => 'First Name', |
|
institution => 'School/college/university', |
|
location => "School's city, state/province, country", |
|
web => "School's web address", |
|
officialemail => 'E-mail address at institution (if different)', |
|
); |
|
return (\@fields,\%titles); |
|
} |
|
|
sub cleanup_html { |
sub cleanup_html { |
my ($incoming) = @_; |
my ($incoming) = @_; |
my $outgoing; |
my $outgoing; |
Line 15063 sub cleanup_html {
|
Line 15995 sub cleanup_html {
|
return $outgoing; |
return $outgoing; |
} |
} |
|
|
=pod |
# Checks for critical messages and returns a redirect url if one exists. |
|
# $interval indicates how often to check for messages. |
=back |
sub critical_redirect { |
|
my ($interval) = @_; |
|
if ((time-$env{'user.criticalcheck.time'})>$interval) { |
|
my @what=&Apache::lonnet::dump('critical', $env{'user.domain'}, |
|
$env{'user.name'}); |
|
&Apache::lonnet::appenv({'user.criticalcheck.time'=>time}); |
|
my $redirecturl; |
|
if ($what[0]) { |
|
if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) { |
|
$redirecturl='/adm/email?critical=display'; |
|
my $url=&Apache::lonnet::absolute_url().$redirecturl; |
|
return (1, $url); |
|
} |
|
} |
|
} |
|
return (); |
|
} |
|
|
=cut |
# Use: |
|
# my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver); |
|
# |
|
################################################## |
|
# password associated functions # |
|
################################################## |
|
sub des_keys { |
|
# Make a new key for DES encryption. |
|
# Each key has two parts which are returned separately. |
|
# Please note: Each key must be passed through the &hex function |
|
# before it is output to the web browser. The hex versions cannot |
|
# be used to decrypt. |
|
my @hexstr=('0','1','2','3','4','5','6','7', |
|
'8','9','a','b','c','d','e','f'); |
|
my $lkey=''; |
|
for (0..7) { |
|
$lkey.=$hexstr[rand(15)]; |
|
} |
|
my $ukey=''; |
|
for (0..7) { |
|
$ukey.=$hexstr[rand(15)]; |
|
} |
|
return ($lkey,$ukey); |
|
} |
|
|
|
sub des_decrypt { |
|
my ($key,$cyphertext) = @_; |
|
my $keybin=pack("H16",$key); |
|
my $cypher; |
|
if ($Crypt::DES::VERSION>=2.03) { |
|
$cypher=new Crypt::DES $keybin; |
|
} else { |
|
$cypher=new DES $keybin; |
|
} |
|
my $plaintext= |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16)))); |
|
$plaintext.= |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16)))); |
|
$plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) ); |
|
return $plaintext; |
|
} |
|
|
1; |
1; |
__END__; |
__END__; |