version 1.688, 2022/10/29 18:13:28
|
version 1.689, 2022/12/17 18:07:47
|
Line 6135 sub handler {
|
Line 6135 sub handler {
|
'stpr' => 'Standard Problem', |
'stpr' => 'Standard Problem', |
'news' => 'New sub-directory', |
'news' => 'New sub-directory', |
'crpr' => 'Create Problem', |
'crpr' => 'Create Problem', |
|
'swit' => 'Switch Server', |
'drbx' => 'Drop Box', |
'drbx' => 'Drop Box', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'bull' => 'Discussion Board', |
'bull' => 'Discussion Board', |
Line 6531 NROSTFORM
|
Line 6532 NROSTFORM
|
NWEBFORM |
NWEBFORM |
|
|
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
my %select_menus; |
my (%select_menus,$rolehomes); |
my $numauthor = 0; |
my $numauthor = 0; |
my $numcrsdirs = 0; |
my $numcrsdirs = 0; |
|
my ($showstdprob,$showswitch,$switchlink); |
my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
if ($env{'user.author'}) { |
if ($env{'user.author'}) { |
$numauthor ++; |
$numauthor ++; |
Line 6550 NWEBFORM
|
Line 6552 NWEBFORM
|
push(@ordered,$relpath); |
push(@ordered,$relpath); |
} |
} |
$select_menus{'author'}->{'order'} = \@ordered; |
$select_menus{'author'}->{'order'} = \@ordered; |
|
$showstdprob = 'block'; |
} else { |
} else { |
|
$rolehomes = '<input type="hidden" name="rolehome_author" value="'.$env{'user.home'}.'" />'."\n"; |
$select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{'author'}->{'default'} = 'switch'; |
$select_menus{'author'}->{'default'} = 'switch'; |
$select_menus{'author'}->{'order'} = ['switch']; |
$select_menus{'author'}->{'order'} = ['switch']; |
|
$showstdprob = 'none'; |
} |
} |
} |
} |
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
['active'],['ca','aa']); |
['active'],['ca','aa']); |
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
my %by_roletype; |
my (%by_roletype,%at_home); |
if (keys(%roleshash)) { |
if (keys(%roleshash)) { |
foreach my $entry (keys(%roleshash)) { |
foreach my $entry (keys(%roleshash)) { |
my ($auname,$audom,$roletype) = split(/:/,$entry); |
my ($auname,$audom,$roletype) = split(/:/,$entry); |
Line 6569 NWEBFORM
|
Line 6574 NWEBFORM
|
$select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)"; |
$select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)"; |
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
if (grep(/^\Q$rolehome\E$/,@ids)) { |
if (grep(/^\Q$rolehome\E$/,@ids)) { |
|
$at_home{$auname.'___'.$audom} = 1; |
my $is_home = 1; |
my $is_home = 1; |
my (%subdirs,@ordered); |
my (%subdirs,@ordered); |
my $toppath="/priv/$audom/$auname"; |
my $toppath="/priv/$audom/$auname"; |
Line 6582 NWEBFORM
|
Line 6588 NWEBFORM
|
} |
} |
$select_menus{$key}->{'order'} = \@ordered; |
$select_menus{$key}->{'order'} = \@ordered; |
} else { |
} else { |
|
$rolehomes .= '<input type="hidden" name="rolehome_coauthor" value="'.$roletype.'='.$audom.'/'.$auname.'='.$rolehome.'" />'."\n"; |
$select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{$key}->{'default'} = 'switch'; |
$select_menus{$key}->{'default'} = 'switch'; |
$select_menus{$key}->{'order'} = ['switch']; |
$select_menus{$key}->{'order'} = ['switch']; |
Line 6603 NWEBFORM
|
Line 6610 NWEBFORM
|
foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) { |
foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) { |
unless ($defrole) { |
unless ($defrole) { |
$defrole = $author; |
$defrole = $author; |
|
if ($at_home{$author}) { |
|
$showstdprob = 'block'; |
|
} else { |
|
$showstdprob = 'none'; |
|
} |
} |
} |
push(@order,$author.'___'.$possrole); |
push(@order,$author.'___'.$possrole); |
} |
} |
Line 6625 NWEBFORM
|
Line 6637 NWEBFORM
|
} |
} |
$select_menus{'course'}->{'order'} = \@ordered; |
$select_menus{'course'}->{'order'} = \@ordered; |
} else { |
} else { |
|
$rolehomes .= '<input type="hidden" name="rolehome_course" value="'.$crshome.'" />'."\n"; |
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
$select_menus{'course'}->{'default'} = 'switch'; |
$select_menus{'course'}->{'default'} = 'switch'; |
$select_menus{'course'}->{'order'} = ['switch']; |
$select_menus{'course'}->{'order'} = ['switch']; |
Line 6641 NWEBFORM
|
Line 6654 NWEBFORM
|
$showtitle = 'inline'; |
$showtitle = 'inline'; |
if (grep(/^\Q$crshome\E$/,@ids)) { |
if (grep(/^\Q$crshome\E$/,@ids)) { |
$is_home = 1; |
$is_home = 1; |
|
$showstdprob = 'block'; |
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
my $toppath="/priv/$coursedom/$coursenum'}"; |
my $toppath="/priv/$coursedom/$coursenum'}"; |
my %subdirs; |
my %subdirs; |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
$numcrsdirs = keys(%subdirs); |
$numcrsdirs = keys(%subdirs); |
if ($numcrsdirs) { |
if ($numcrsdirs) { |
$pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n". |
$pickdir .= $lt{'dire'}.' <select name="authorpath">'."\n". |
'<option value="/">/</option>'."\n"; |
'<option value="/">/</option>'."\n"; |
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n"; |
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n"; |
Line 6656 NWEBFORM
|
Line 6670 NWEBFORM
|
} else { |
} else { |
$pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n"; |
$pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n"; |
} |
} |
|
} else { |
|
$showstdprob = 'none'; |
|
$rolehomes .= '<input type="hidden" name="rolehome_course" value="'.$crshome.'" />'."\n"; |
|
my @order; |
|
$select_menus{'course'}->{'text'} = &mt('Course Resource'); |
|
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{'course'}->{'default'} = 'switch'; |
|
$select_menus{'course'}->{'order'} = ['switch']; |
|
push(@order,'course'); |
|
my $defrole; |
|
$pickdir = $lt{'loca'}. |
|
&Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'dire'}, |
|
$defrole,'authorrole','authorpath', |
|
\%select_menus,\@order,'toggleCrsResTitle();', |
|
'','priv').'<br />'; |
|
$showtitle = 'none'; |
|
|
} |
} |
} |
} |
|
if ($showstdprob eq 'none') { |
|
$showswitch = 'block'; |
|
} else { |
|
$showswitch = 'none'; |
|
} |
|
|
my %seltemplate_menus; |
my %seltemplate_menus; |
my @files = &Apache::lonhomework::get_template_list('problem'); |
my @files = &Apache::lonhomework::get_template_list('problem'); |
Line 6708 NWEBFORM
|
Line 6744 NWEBFORM
|
<input type="hidden" name="active" value="bb" /> |
<input type="hidden" name="active" value="bb" /> |
<p> |
<p> |
$pickdir |
$pickdir |
|
<div id="newstdproblem" style="display:$showstdprob;"> |
<span class="LC_nobreak">$lt{'news'}? |
<span class="LC_nobreak">$lt{'news'}? |
<label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label> |
<label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label> |
|
|
Line 6743 NWEBFORM
|
Line 6780 NWEBFORM
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled /> |
<input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled /> |
</span> |
</span> |
|
</div> |
|
<div id="stdprobswitch" style="display:$showswitch;"> |
|
$rolehomes |
|
<input type="button" name="switchfornewprob" value="$lt{'swit'}" onclick="switchForProb();" /> |
|
</div> |
</fieldset> |
</fieldset> |
</form> |
</form> |
|
|
Line 7921 function toggleCrsResTitle() {
|
Line 7963 function toggleCrsResTitle() {
|
} else { |
} else { |
document.getElementById('newresource').style.display = 'none'; |
document.getElementById('newresource').style.display = 'none'; |
} |
} |
} |
} |
|
if (document.getElementById('newstdproblem')) { |
|
if (document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value == 'switch') { |
|
document.getElementById('newstdproblem').style.display = 'none'; |
|
if (document.getElementById('stdprobswitch')) { |
|
document.getElementById('stdprobswitch').style.display = 'block'; |
|
} |
|
} else { |
|
document.getElementById('newstdproblem').style.display = 'block'; |
|
if (document.getElementById('stdprobswitch')) { |
|
document.getElementById('stdprobswitch').style.display = 'none'; |
|
} |
|
} |
|
} |
} |
} |
|
|
function toggleNewInCourse(form) { |
function toggleNewInCourse(form) { |
Line 8019 function toggleImportCrsres(caller,dirco
|
Line 8074 function toggleImportCrsres(caller,dirco
|
} |
} |
return; |
return; |
} |
} |
|
|
|
function switchForProb() { |
|
if (document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value == 'switch') { |
|
var url = '/adm/switchserver?otherserver='; |
|
var newhostid = ''; |
|
var role = ''; |
|
var selloc = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value; |
|
if (selloc == 'author') { |
|
newhostid = document.courseresform.rolehome_author.value; |
|
role = "au./&js_escape($env{'user.domain'})/"; |
|
} else if (selloc == 'course') { |
|
newhostid = document.courseresform.rolehome_course.value; |
|
role = "&js_escape($env{'request.role'})"; |
|
} else { |
|
var items = new Array(); |
|
items = selloc.split('___'); |
|
var len = document.courseresform.rolehome_coauthor.length; |
|
if (null == len) { |
|
var currval = document.courseresform.rolehome_coauthor.value; |
|
if (null != currval) { |
|
var info = new Array(); |
|
info = currval.split('='); |
|
newhostid = info[2]; |
|
role = info[0]+'./'+info[1]; |
|
} |
|
} else { |
|
for (var i=0; i<len; i++) { |
|
var currval = document.courseresform.rolehome_coauthor[i].value; |
|
if (null != currval) { |
|
var info = new Array(); |
|
info = currval.split('='); |
|
if ((info[1] == items[1]+'/'+items[0]) && (info[0] == items[2])) { |
|
newhostid = info[2]; |
|
role = info[0]+'./'+info[1]; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (newhostid != '') { |
|
url += newhostid; |
|
if (role != '') { |
|
url += '&role='+role; |
|
} |
|
document.location.href = url; |
|
} |
|
} |
|
return; |
|
} |
|
|
function makeims(imsform) { |
function makeims(imsform) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |