version 1.124, 2017/01/03 17:47:57
|
version 1.127, 2017/04/08 14:28:56
|
Line 44 sub handler {
|
Line 44 sub handler {
|
if ($env{'form.context'} eq 'adhoc') { |
if ($env{'form.context'} eq 'adhoc') { |
&Apache::loncommon::content_type($r,'application/json'); |
&Apache::loncommon::content_type($r,'application/json'); |
$r->send_http_header; |
$r->send_http_header; |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.cid'}); |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.cid'},1); |
if ((ref($possroles) eq 'ARRAY') && (ref($description) eq 'HASH')) { |
if ((ref($possroles) eq 'ARRAY') && (ref($description) eq 'HASH')) { |
my $response = []; |
my $response = []; |
if (@{$possroles}) { |
if (@{$possroles}) { |
Line 89 sub handler {
|
Line 89 sub handler {
|
$title = 'Selecting '.$type.'(s)'; |
$title = 'Selecting '.$type.'(s)'; |
} |
} |
|
|
# if called when a DC or DH is selecting a course |
# if called when a DC, DH or DA is selecting a course |
my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'}); |
my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'}); |
if ($roledom) { |
if ($roledom) { |
$roleelement = '<input type="hidden" name="roleelement" value="'.$env{'form.roleelement'}.'" />'; |
$roleelement = '<input type="hidden" name="roleelement" value="'.$env{'form.roleelement'}.'" />'; |
$submitopener = &processpick(); |
$submitopener = &processpick(); |
$autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")'; |
$autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")'; |
if ($rolename eq 'dh') { |
if (($rolename eq 'dh') || ($rolename eq 'da')) { |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
title => 'Ad hoc role selection', |
title => 'Ad hoc role selection', |
preamble => 'Please choose an ad hoc role in the course.', |
preamble => 'Please choose an ad hoc role in the course.', |
Line 103 sub handler {
|
Line 103 sub handler {
|
); |
); |
|
|
$rolechooser = <<"END"; |
$rolechooser = <<"END"; |
<div id="LC_adhocrole_chooser" title="$lt{'title'}"> |
<div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none"> |
<p>$lt{'preamble'}</p> |
<p>$lt{'preamble'}</p> |
<form name="LChelpdeskadhoc" id="LChelpdeskpicker" action=""> |
<form name="LChelpdeskadhoc" id="LChelpdeskpicker" action=""> |
<div id="LC_choose_adhoc"> |
<div id="LC_choose_adhoc"> |
Line 440 sub display_matched_courses {
|
Line 440 sub display_matched_courses {
|
$action = '/adm/portfolio'; |
$action = '/adm/portfolio'; |
} |
} |
my $numcourses = keys(%courses); |
my $numcourses = keys(%courses); |
$r->print('<form name="courselist" method="post" action="'.$action.'">'); |
$r->print('<form name="courselist" method="post" action="'.$action.'" id="LCcoursepicker">'); |
if ($env{'form.form'} eq 'modifycourse') { |
if ($env{'form.form'} eq 'modifycourse') { |
if ($numcourses > 0) { |
if ($numcourses > 0) { |
my $ccrole = 'cc'; |
my $ccrole = 'cc'; |
Line 469 sub display_matched_courses {
|
Line 469 sub display_matched_courses {
|
$r->print(&mt('Enter the course with the role of [_1].',$cctitle)); |
$r->print(&mt('Enter the course with the role of [_1].',$cctitle)); |
} |
} |
} elsif (&Apache::lonnet::allowed('rar',$crsdom)) { |
} elsif (&Apache::lonnet::allowed('rar',$crsdom)) { |
my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($crsdom); |
'adhocroles.'.$crsdom); |
if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) { |
if ($adhocroles{'adhocroles.'.$crsdom} ne '') { |
if (@{$roles_by_num} > 1) { |
$possrole = 1; |
$r->print($roleradio); |
$r->print($roleradio); |
|
my @adhoc = split(/,/,$adhocroles{'adhocroles.'.$crsdom}); |
|
if (@adhoc > 1) { |
|
my %adhochash; |
|
map { $adhochash{$_} = $_; } @adhoc; |
|
my $selector = &Apache::loncommon::select_form($adhoc[0],'adhocrole',\%adhochash); |
|
if ($type eq 'Community') { |
if ($type eq 'Community') { |
$r->print(&mt('Enter the community with one of the available ad hoc roles: [_1].', |
$r->print(&mt('Enter the community with one of the available ad hoc roles.')); |
$selector)); |
|
} elsif ($type eq 'Placement') { |
} elsif ($type eq 'Placement') { |
$r->print(&mt('Enter the placement test with one of the available ad hoc roles: [_1].', |
$r->print(&mt('Enter the placement test with one of the available ad hoc roles.')); |
$selector)); |
|
} else { |
} else { |
$r->print(&mt('Enter the course with one of the available ad hoc roles: [_1].', |
$r->print(&mt('Enter the course with one of the available ad hoc roles.')); |
$selector)); |
|
} |
} |
} else { |
$possrole = 1; |
|
} elsif (@{$roles_by_num} == 1) { |
|
$r->print($roleradio); |
|
my $rolename = $description->{$roles_by_num->[0]}; |
if ($type eq 'Community') { |
if ($type eq 'Community') { |
$r->print(&mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0])); |
$r->print(&mt('Enter the community with the ad hoc role of: [_1]',$rolename)); |
} elsif ($type eq 'Placement') { |
} elsif ($type eq 'Placement') { |
$r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0])); |
$r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$rolename)); |
} else { |
} else { |
$r->print(&mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0])); |
$r->print(&mt('Enter the course with the ad hoc role of: [_1]',$rolename)); |
} |
} |
$r->print('<input type="hidden" name="adhocrole" value="'.$adhoc[0].'" />'); |
$possrole = 1; |
|
} |
|
if ($possrole) { |
|
$r->print('<input type="hidden" name="adhocrole" value="" />'); |
} |
} |
} |
} |
} |
} |
if ($possrole) { |
if ($possrole) { |
$r->print('</label></span><br />'); |
$r->print('</label></span><br />'); |
} |
} |
$r->print('<span class="LC_nobreak"><label>' |
$r->print('<span class="LC_nobreak"><label>' |
Line 766 sub display_matched_courses {
|
Line 763 sub display_matched_courses {
|
$r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />'); |
$r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />'); |
$r->print('<input type="hidden" name="action" value="rolepicker" />'); |
$r->print('<input type="hidden" name="action" value="rolepicker" />'); |
} elsif ($env{'form.form'} eq 'modifycourse') { |
} elsif ($env{'form.form'} eq 'modifycourse') { |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state'])); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state','adhocrole'])); |
} else { |
} else { |
$r->print('<input type="hidden" name="cnumelement" value="'. |
$r->print('<input type="hidden" name="cnumelement" value="'. |
$env{'form.cnumelement'}.'" />'."\n". |
$env{'form.cnumelement'}.'" />'."\n". |
Line 872 sub gochoose_javascript {
|
Line 869 sub gochoose_javascript {
|
my $output; |
my $output; |
if ($rolechooser) { |
if ($rolechooser) { |
$output .= qq| |
$output .= qq| |
\$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false }); |
\$(document).ready(function(){ |
|
\$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false }); |
|
}); |
|; |
|; |
} |
} |
$output .= qq| |
$output .= qq| |
Line 959 ENDNAMECODE
|
Line 958 ENDNAMECODE
|
document.courselist.cnum.value = cname; |
document.courselist.cnum.value = cname; |
document.courselist.cdom.value = cdom; |
document.courselist.cdom.value = cdom; |
} |
} |
if ((openerForm == 'rolechoice') && (openerRole == 'dh')) { |
if ((openerForm == 'rolechoice') && ((openerRole == 'dh') || (openerRole == 'da'))) { |
\$("#LC_choose_adhoc").empty(); |
\$("#LC_choose_adhoc").empty(); |
var http = new XMLHttpRequest(); |
var http = new XMLHttpRequest(); |
var url = "/adm/pickcourse"; |
var url = "/adm/pickcourse"; |
Line 978 http.onreadystatechange = function() {
|
Line 977 http.onreadystatechange = function() {
|
$lastaction; |
$lastaction; |
} else { |
} else { |
var str = ''; |
var str = ''; |
|
\$("#LC_choose_adhoc").empty(); |
for (var i=0; i<data.roles.length; i++) { |
for (var i=0; i<data.roles.length; i++) { |
\$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span> </span>") |
\$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span> </span>") |
.appendTo("#LC_choose_adhoc"); |
.appendTo("#LC_choose_adhoc"); |
} |
} |
|
\$( "#LC_adhocrole_chooser" ).toggle( true ); |
\$( "#LC_get_role_0").prop("checked", true); |
\$( "#LC_get_role_0").prop("checked", true); |
\$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false }); |
\$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false }); |
\$( "#LC_adhocrole_chooser" ).dialog("open"); |
\$( "#LC_adhocrole_chooser" ).dialog("open"); |