version 1.111, 2004/11/19 20:17:52
|
version 1.113, 2004/12/03 05:15:30
|
Line 84 sub handler {
|
Line 84 sub handler {
|
my $envkey; |
my $envkey; |
my %dcroles = (); |
my %dcroles = (); |
my $numdc = &check_fordc(\%dcroles,$then); |
my $numdc = &check_fordc(\%dcroles,$then); |
my %recentroles; |
|
if ($numdc > 0) { |
|
%recentroles = &Apache::lonnet::dump(&recent_filename('roles')); |
|
} |
|
|
|
# ================================================================== Roles Init |
# ================================================================== Roles Init |
if ($ENV{'form.selectrole'}) { |
if ($ENV{'form.selectrole'}) { |
Line 117 sub handler {
|
Line 113 sub handler {
|
} |
} |
} |
} |
|
|
# Check if user is a DC with courses in the recent list which need privs. |
|
# if ($numdc > 0) { |
|
# %recentroles = &Apache::lonnet::dump(&recent_filename('recent_roles')); |
|
# foreach my $rolekey (keys %recentroles) { |
|
# if ($rolekey =~ m-^user\.role.cc\./\w+/\w+$-) { |
|
# &check_privs($rolekey,$then,$now); |
|
# } |
|
# } |
|
# } |
|
|
|
foreach $envkey (keys %ENV) { |
foreach $envkey (keys %ENV) { |
next if ($envkey!~/^user\.role\./); |
next if ($envkey!~/^user\.role\./); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
Line 276 ENDENTERKEY
|
Line 262 ENDENTERKEY
|
'.course.helper.not.run'}) { |
'.course.helper.not.run'}) { |
$furl = "/adm/helper/course.initialization.helper"; |
$furl = "/adm/helper/course.initialization.helper"; |
} |
} |
# Check to see if the user is a DC selecting a course |
|
if (($numdc > 0) && ($role eq 'cc')) { |
|
my $formaction = '/adm/roles/'; |
|
my ($dcdom,$pickedcourse) = split/_/,$courseid; |
|
if ($ENV{'user.role.dc./'.$dcdom.'/'}) { |
|
&Apache::lonhtmlcommon::store_recent('roles', |
|
$envkey,$formaction); |
|
} |
|
} |
|
# |
|
# Send the user to the course they selected |
# Send the user to the course they selected |
&redirect_user($r,&mt('Entering Course'), |
&redirect_user($r,&mt('Entering Course'), |
$furl,$msg, |
$furl,$msg, |
Line 563 ENDHEADER
|
Line 539 ENDHEADER
|
$sortkey=$role.$twhere; |
$sortkey=$role.$twhere; |
} |
} |
|
|
$roletext.='<tr bgcolor='.$tbg.'>'; |
|
$roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver); |
$roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver); |
$roletext{$envkey}=$roletext; |
$roletext{$envkey}=$roletext; |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
Line 619 ENDHEADER
|
Line 594 ENDHEADER
|
foreach (sort(keys(%recent_roles))) { |
foreach (sort(keys(%recent_roles))) { |
if (defined($roletext{'user.role.'.$_})) { |
if (defined($roletext{'user.role.'.$_})) { |
$output.=$roletext{'user.role.'.$_}; |
$output.=$roletext{'user.role.'.$_}; |
} |
} elsif ($numdc > 0) { |
|
unless ($_ =~/^error\:/) { |
|
$output.=&display_cc_role('user.role.'.$_); |
|
} |
|
} |
} |
} |
if ($output) { |
if ($output) { |
$r->print("<tr bgcolor='#BBffBB'><td align='center' colspan='7'>". |
$r->print("<tr bgcolor='#BBffBB'><td align='center' colspan='7'>". |
Line 630 ENDHEADER
|
Line 609 ENDHEADER
|
} |
} |
|
|
if ($numdc > 0) { |
if ($numdc > 0) { |
&display_recent_roles($r,\%roletext,\%recentroles); |
$r->print(&coursepick_jscript()); |
|
$r->print(&Apache::loncommon::coursebrowser_javascript()); |
} |
} |
foreach my $type ('Construction Space','Course','Domain','System') { |
foreach my $type ('Construction Space','Course','Domain','System') { |
my $output; |
my $output; |
Line 647 ENDHEADER
|
Line 627 ENDHEADER
|
if ($output) { |
if ($output) { |
if ($doheaders > 0) { |
if ($doheaders > 0) { |
$r->print("<tr bgcolor='#BBffBB'>". |
$r->print("<tr bgcolor='#BBffBB'>". |
"<td align='center' colspan='7'>".&mt($type)."</td>"); |
"<td align='center' colspan='7'>".&mt($type)."</td></tr>"); |
} |
} |
$r->print($output); |
$r->print($output); |
} |
} |
Line 768 sub role_status {
|
Line 748 sub role_status {
|
|
|
sub build_roletext { |
sub build_roletext { |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_; |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_; |
my $roletext='<tr bgcolor='.$tbg.'>'; |
my $roletext='<tr bgcolor="'.$tbg.'">'; |
unless ($nochoose) { |
unless ($nochoose) { |
if (!$button) { |
if (!$button) { |
if ($switchserver) { |
if ($switchserver) { |
Line 843 sub check_fordc {
|
Line 823 sub check_fordc {
|
|
|
sub courselink { |
sub courselink { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom); |
|
my $verify_script = &coursepick_jscript($dcdom); |
|
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom); |
('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom); |
my $hiddenitems = '<input type="hidden" name="dcdomain_'.$dcdom.'" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="dcdomain_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom_'.$dcdom.'" value="'.$dcdom.'" />'. |
'<input type="hidden" name="dccourse_'.$dcdom.'" value="" />'. |
'<input type="hidden" name="dccourse_'.$dcdom.'" value="" />'. |
'<input type="hidden" name="coursedesc_'.$dcdom.'" value="" />'; |
'<input type="hidden" name="coursedesc_'.$dcdom.'" value="" />'; |
return $cb_jscript.$verify_script.$courseform.$hiddenitems; |
return $courseform.$hiddenitems; |
} |
} |
|
|
sub coursepick_jscript { |
sub coursepick_jscript { |
my ($dcdom) = @_; |
|
my $verify_script = <<"END"; |
my $verify_script = <<"END"; |
<script> |
<script> |
function verifyCoursePick(caller) { |
function verifyCoursePick(caller) { |
var numbutton = getIndex(caller) |
var numbutton = getIndex(caller) |
var pickedCourse = document.rolechoice.dccourse_$dcdom.value |
var pickedCourse = document.rolechoice.elements[numbutton+4].value |
var pickedDomain = document.rolechoice.dcdomain_$dcdom.value |
var pickedDomain = document.rolechoice.elements[numbutton+2].value |
if (document.rolechoice.dcdomain_$dcdom.value == document.rolechoice.origdom_$dcdom.value) { |
if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) { |
if (pickedCourse != '') { |
if (pickedCourse != '') { |
if (numbutton != -1) { |
if (numbutton != -1) { |
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
Line 925 END
|
Line 902 END
|
return $process_pick; |
return $process_pick; |
} |
} |
|
|
sub display_recent_roles { |
sub display_cc_role { |
my ($r,$roletext,$recentroles)=@_; |
my $rolekey = shift; |
|
my $roletext; |
my $advanced = $ENV{'user.adv'}; |
my $advanced = $ENV{'user.adv'}; |
my $tryagain = $ENV{'form.tryagain'}; |
my $tryagain = $ENV{'form.tryagain'}; |
my $numrecent = 0; |
unless ($rolekey =~/^error\:/) { |
my $roledisplay = '<tr bgcolor="#BBffBB">'. |
if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) { |
'<td align="center" colspan="7">'. |
my $tcourseid = $1.'_'.$2; |
&mt('Recent courses accessed by DC'). |
my $trolecode = 'cc./'.$1.'/'.$2; |
'</td></tr>'."\n"; |
my $trole = Apache::lonnet::plaintext('cc'); |
foreach my $rolekey (sort keys %{$recentroles}) { |
my $twhere; |
unless ($rolekey =~/^error\:/) { |
my $tbg='#77FF77'; |
unless ($$roletext{$rolekey}) { |
my $tfont='#003300'; |
if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) { |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
my $tcourseid = $1.'_'.$2; |
if (%newhash) { |
my $trolecode = 'cc./'.$1.'/'.$2; |
$twhere=$newhash{'description'}. |
my $trole = Apache::lonnet::plaintext('cc'); |
' <font size="-2">'. |
my $twhere; |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). |
my $tbg='#77FF77'; |
'</font>'; |
my $tfont='#003300'; |
} else { |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
$twhere=&mt('Currently not available'); |
if (%newhash) { |
$ENV{'course.'.$tcourseid.'.description'}=$twhere; |
$twhere=$newhash{'description'}. |
|
' <font size="-2">'. |
|
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). |
|
'</font>'; |
|
} else { |
|
$twhere=&mt('Currently not available'); |
|
$ENV{'course.'.$tcourseid.'.description'}=$twhere; |
|
} |
|
$twhere.="<br />".&mt('Domain').":".$1; |
|
$$roletext{$rolekey} = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,''); |
|
} |
|
} |
} |
$roledisplay.=$$roletext{$rolekey}; |
$twhere.="<br />".&mt('Domain').":".$1; |
$numrecent ++; |
$roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,''); |
} |
} |
} |
} |
if ($numrecent > 0) { |
return $roletext; |
$r->print("$roledisplay\n"); |
|
} |
|
} |
} |
|
|
sub allcourses_row { |
sub allcourses_row { |