[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
raeburn
raeburn at source.lon-capa.org
Sat Dec 17 13:07:47 EST 2022
raeburn Sat Dec 17 18:07:47 2022 EDT
Modified files:
/loncom/interface londocs.pm
Log:
- "Standard Problem" item (Grading tab) in Course Editor:
- If homeserver for selected location is a different server, display
"Switch server" button and hide form elements for: New sub-directory,
File Name, Use Template etc.
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.688 loncom/interface/londocs.pm:1.689
--- loncom/interface/londocs.pm:1.688 Sat Oct 29 18:13:28 2022
+++ loncom/interface/londocs.pm Sat Dec 17 18:07:47 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.688 2022/10/29 18:13:28 raeburn Exp $
+# $Id: londocs.pm,v 1.689 2022/12/17 18:07:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6135,6 +6135,7 @@
'stpr' => 'Standard Problem',
'news' => 'New sub-directory',
'crpr' => 'Create Problem',
+ 'swit' => 'Switch Server',
'drbx' => 'Drop Box',
'scuf' => 'External Scores (handgrade, upload, clicker)',
'bull' => 'Discussion Board',
@@ -6531,9 +6532,10 @@
NWEBFORM
my @ids=&Apache::lonnet::current_machine_ids();
- my %select_menus;
+ my (%select_menus,$rolehomes);
my $numauthor = 0;
my $numcrsdirs = 0;
+ my ($showstdprob,$showswitch,$switchlink);
my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}";
if ($env{'user.author'}) {
$numauthor ++;
@@ -6550,16 +6552,19 @@
push(@ordered,$relpath);
}
$select_menus{'author'}->{'order'} = \@ordered;
+ $showstdprob = 'block';
} 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'}->{'default'} = 'switch';
$select_menus{'author'}->{'order'} = ['switch'];
+ $showstdprob = 'none';
}
}
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
['active'],['ca','aa']);
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
- my %by_roletype;
+ my (%by_roletype,%at_home);
if (keys(%roleshash)) {
foreach my $entry (keys(%roleshash)) {
my ($auname,$audom,$roletype) = split(/:/,$entry);
@@ -6569,6 +6574,7 @@
$select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)";
my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
if (grep(/^\Q$rolehome\E$/, at ids)) {
+ $at_home{$auname.'___'.$audom} = 1;
my $is_home = 1;
my (%subdirs, at ordered);
my $toppath="/priv/$audom/$auname";
@@ -6582,6 +6588,7 @@
}
$select_menus{$key}->{'order'} = \@ordered;
} 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}->{'default'} = 'switch';
$select_menus{$key}->{'order'} = ['switch'];
@@ -6603,6 +6610,11 @@
foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) {
unless ($defrole) {
$defrole = $author;
+ if ($at_home{$author}) {
+ $showstdprob = 'block';
+ } else {
+ $showstdprob = 'none';
+ }
}
push(@order,$author.'___'.$possrole);
}
@@ -6625,6 +6637,7 @@
}
$select_menus{'course'}->{'order'} = \@ordered;
} else {
+ $rolehomes .= '<input type="hidden" name="rolehome_course" value="'.$crshome.'" />'."\n";
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required');
$select_menus{'course'}->{'default'} = 'switch';
$select_menus{'course'}->{'order'} = ['switch'];
@@ -6641,13 +6654,14 @@
$showtitle = 'inline';
if (grep(/^\Q$crshome\E$/, at ids)) {
$is_home = 1;
+ $showstdprob = 'block';
$pickdir .= '<input type="hidden" name="authorrole" value="course" />';
my $toppath="/priv/$coursedom/$coursenum'}";
my %subdirs;
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
$numcrsdirs = keys(%subdirs);
if ($numcrsdirs) {
- $pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n".
+ $pickdir .= $lt{'dire'}.' <select name="authorpath">'."\n".
'<option value="/">/</option>'."\n";
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n";
@@ -6656,8 +6670,30 @@
} else {
$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 @files = &Apache::lonhomework::get_template_list('problem');
@@ -6708,6 +6744,7 @@
<input type="hidden" name="active" value="bb" />
<p>
$pickdir
+ <div id="newstdproblem" style="display:$showstdprob;">
<span class="LC_nobreak">$lt{'news'}?
<label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label>
@@ -6743,6 +6780,11 @@
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
<input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled />
</span>
+ </div>
+ <div id="stdprobswitch" style="display:$showswitch;">
+ $rolehomes
+ <input type="button" name="switchfornewprob" value="$lt{'swit'}" onclick="switchForProb();" />
+ </div>
</fieldset>
</form>
@@ -7921,7 +7963,20 @@
} else {
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) {
@@ -8020,6 +8075,56 @@
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) {
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
alert("$js_lt{'imsfile'}");
More information about the LON-CAPA-cvs
mailing list