[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm lonmodifycourse.pm lonpickcourse.pm mydesk.tab
raeburn
raeburn at source.lon-capa.org
Wed Oct 5 09:59:47 EDT 2016
raeburn Wed Oct 5 13:59:47 2016 EDT
Modified files:
/loncom/interface domainprefs.pm lonmodifycourse.pm
lonpickcourse.pm mydesk.tab
Log:
- Domain configuration (Support Settings) allows custom course role(s) to be
defined which will be available for domain helpdesk staff to select as
ad hoc role(s) via "View a course or community" in main menu.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.281 loncom/interface/domainprefs.pm:1.282
--- loncom/interface/domainprefs.pm:1.281 Wed Sep 21 01:38:50 2016
+++ loncom/interface/domainprefs.pm Wed Oct 5 13:59:46 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.281 2016/09/21 01:38:50 raeburn Exp $
+# $Id: domainprefs.pm,v 1.282 2016/10/05 13:59:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -417,10 +417,12 @@
modify => \&modify_serverstatuses,
},
'helpsettings' =>
- {text => 'Help page settings',
+ {text => 'Support settings',
help => 'Domain_Configuration_Help_Settings',
- header => [{col1 => 'Help Settings (logged-in users)',
- col2 => 'Value'}],
+ header => [{col1 => 'Help Page Settings (logged-in users)',
+ col2 => 'Value'},
+ {col1 => 'Helpdesk Roles',
+ col2 => 'Settings'},],
print => \&print_helpsettings,
modify => \&modify_helpsettings,
},
@@ -712,6 +714,22 @@
$output = &coursecategories_javascript($settings);
} elsif ($action eq 'defaults') {
$output = &defaults_javascript($settings);
+ } elsif ($action eq 'helpsettings') {
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my $context = 'domain';
+ my $crstype = 'Course';
+ my $formname = 'display';
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $output =
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
+ \@templateroles);
}
$output .=
'<table class="LC_nested_outer">
@@ -748,7 +766,7 @@
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
- ($action eq 'directorysrch') || ($action eq 'trust')) {
+ ($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
@@ -836,7 +854,8 @@
}
$rowtotal ++;
} elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
- ($action eq 'defaults') || ($action eq 'directorysrch')) {
+ ($action eq 'defaults') || ($action eq 'directorysrch') ||
+ ($action eq 'helpsettings')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'login') {
if ($numheaders == 4) {
@@ -999,8 +1018,6 @@
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
- } elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
}
}
$output .= '
@@ -3026,18 +3043,92 @@
}
sub print_helpsettings {
- my ($dom,$confname,$settings,$rowtotal) = @_;
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $confname = $dom.'-domainconfig';
my ($datatable,$itemcount);
- $itemcount = 1;
- my (%choices,%defaultchecked, at toggles);
- $choices{'submitbugs'} = &mt('Display link to: [_1]?',
- &Apache::loncommon::modal_link('http://bugs.loncapa.org',
- &mt('LON-CAPA bug tracker'),600,500));
- %defaultchecked = ('submitbugs' => 'on');
- @toggles = ('submitbugs',);
-
- ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
- \%choices,$itemcount);
+ if ($position eq 'top') {
+ $itemcount = 1;
+ my (%choices,%defaultchecked, at toggles);
+ $choices{'submitbugs'} = &mt('Display link to: [_1]?',
+ &Apache::loncommon::modal_link('http://bugs.loncapa.org',
+ &mt('LON-CAPA bug tracker'),600,500));
+ %defaultchecked = ('submitbugs' => 'on');
+ @toggles = ('submitbugs');
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
+ $$rowtotal ++;
+ } else {
+ my $css_class;
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ my %customroles;
+ foreach my $key (keys(%existing)) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
+ my $rolename = $1;
+ my %privs;
+ ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
+ $customroles{$rolename} = \%privs;
+ }
+ }
+ my $count = 0;
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ foreach my $role (sort(keys(%customroles))) {
+ my $prefix = 'custhelp'.$count;
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '<tr '.$css_class.'><td><label>'.
+ '<input type="checkbox" name="modifycusthelp" value="'.$count.'" />'.
+ '<input type="hidden" name="custhelprole'.$count.'" value="'.$role.'" />'.
+ &mt('Modify').'</label></td>'.
+ '<td>'.&mt('Existing helpdesk role:').' '.
+ '<b>'.$role.'</b><br />'.
+ &Apache::lonuserutils::custom_role_header($context,$crstype,
+ \@templateroles,$prefix).
+ &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels,
+ \%levelscurrent,$prefix).
+ '<br /></td>';
+ $count ++;
+ $itemcount ++;
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $newcust = 'custhelp'.$count;
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="newcusthelp" value="'.$count.'" />'. &mt('Add').
+ '</label></span></td>'.
+ '<td><span class="LC_nobreak">'.
+ '<b>'.&mt('Name of new helpdesk role:').'</b> '.
+ '<input type="text" size="20" name="newcusthelpname" value="" />'.
+ '</span><br />'.
+ &Apache::lonuserutils::custom_role_header($context,$crstype,
+ \@templateroles,$newcust).
+ &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,
+ \%levelscurrent,$newcust).
+ '<br /><br />'.
+ '</td></tr>';
+ $count ++;
+ $$rowtotal += $count;
+ }
return $datatable;
}
@@ -11704,30 +11795,76 @@
my %defaultchecked = ('submitbugs' => 'on');
my @offon = ('off','on');
my @toggles = ('submitbugs');
+ my %current = ('submitbugs' => '');
if (ref($domconfig{'helpsettings'}) eq 'HASH') {
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '0') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ %current = %{$domconfig{'helpsettings'}};
+ }
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '0') {
$changes{$item} = 1;
}
- } elsif ($defaultchecked{$item} eq 'off') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '1') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '1') {
$changes{$item} = 1;
}
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
}
- if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
- $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ }
+
+ my @modify = &Apache::loncommon::get_env_multiple('form.modifycusthelp');
+ my $confname = $dom.'-domainconfig';
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ if (@modify) {
+ foreach my $num (@modify) {
+ my $rolename = $env{'form.custhelprole'.$num};
+ if ($rolename ne '') {
+ if (exists($existing{'rolesdef_'.$rolename})) {
+ my $prefix = 'custhelp'.$num;
+ my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
+ my %currprivs;
+ ($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) =
+ split(/\_/,$existing{'rolesdef_'.$rolename});
+ foreach my $level ('c','d','s') {
+ if ($newprivs{$level} ne $currprivs{$level}) {
+ $changes{'customrole'}{$rolename} = 1;
+ my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
+ $newprivs{'c'},$confname,$dom);
+ last;
+ }
+ }
+ }
+ }
+ }
+ }
+ if ($env{'form.newcusthelp'} ne '') {
+ my $prefix = 'custhelp'.$env{'form.newcusthelp'};
+ my $rolename = $env{'form.newcusthelpname'};
+ $rolename=~s/[^A-Za-z0-9]//gs;
+ if ($rolename ne '') {
+ unless(exists($existing{'rolesdef_'.$rolename})) {
+ my $errmsg;
+ my $result = &Apache::lonuserutils::store_custom_role($rolename,$prefix,
+ $confname,$dom);
+ if ($result eq 'ok') {
+ $changes{'newcustomrole'} = $rolename;
+ } else {
+ $errmsg = ': '.$result;
+ }
}
}
}
+
my $putresult;
if (keys(%changes) > 0) {
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
@@ -11738,6 +11875,16 @@
$resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
&Apache::loncommon::modal_link('http://bugs.loncapa.org',
&mt('LON-CAPA bug tracker'),600,500)).'</li>';
+ } elsif ($item eq 'customrole') {
+ if (ref($changes{'customrole'}) eq 'HASH') {
+ foreach my $role (sort(keys(%{$changes{'customrole'}}))) {
+ $resulttext .= '<li>'.&mt('Existing custom role modified: [_1]',
+ $role).'</li>';
+ }
+ }
+ } elsif ($item eq 'newcustomrole') {
+ $resulttext .= '<li>'.&mt('New custom role added: [_1]',
+ $changes{'newcustomrole'}).'</li>';
}
}
$resulttext .= '</ul>';
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.85 loncom/interface/lonmodifycourse.pm:1.86
--- loncom/interface/lonmodifycourse.pm:1.85 Mon Aug 15 18:01:08 2016
+++ loncom/interface/lonmodifycourse.pm Wed Oct 5 13:59:46 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.85 2016/08/15 18:01:08 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.86 2016/10/05 13:59:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -182,22 +182,65 @@
$r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
\$numtitles,'modifycourse',undef,undef,undef,
\@codetitles,$dom));
+
+ my ($actiontext,$roleoption,$settingsoption);
if ($type eq 'Community') {
- $r->print(&mt('Actions available after searching for a community:').'<ul>'.
- '<li>'.&mt('Enter the community with the role of [_1]',$cctitle).'</li>'."\n".
- '<li>'.&mt('View or modify community settings which only a [_1] may modify.',$dctitle).
- '</li>'."\n".'</ul>');
+ $actiontext = &mt('Actions available after searching for a community:');
} elsif ($type eq 'Placement') {
- $r->print(&mt('Actions available after searching for a placement test:').'<ul>'.
- '<li>'.&mt('Enter the placement test with the role of [_1]',$cctitle).'</li>'."\n".
- '<li>'.&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle).
- '</li>'."\n".'</ul>');
- } else {
- $r->print(&mt('Actions available after searching for a course:').'<ul>'.
- '<li>'.&mt('Enter the course with the role of [_1]',$cctitle).'</li>'."\n".
- '<li>'.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
- '</li>'."\n".'</ul>');
+ $actiontext = &mt('Actions available after searching for a placement test:')
+ } else {
+ $actiontext = &mt('Actions available after searching for a course:');
}
+ if (&Apache::lonnet::allowed('ccc',$dom)) {
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
+ $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
+ } elsif ($type eq 'Placement') {
+ $roleoption = &mt('Enter the placement test with the role of [_1]',$cctitle);
+ $settingsoption = &mt('View or modify placement test settings which only a [_1] may modify.',$dctitle);
+ } else {
+ $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
+ $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
+ }
+ } elsif (&Apache::lonnet::allowed('rar',$dom)) {
+ my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
+ 'adhocroles.'.$dom);
+ if (keys(%adhocroles)) {
+ my @adhoc = split(',',$adhocroles{'adhocroles.'.$dom});
+ if (@adhoc > 1) {
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with one of the available ad hoc roles: [_1].',
+ join(', ', at adhoc));
+ } elsif ($type eq 'Placement') {
+ $roleoption = &mt('Enter the placement test with one of the available ad hoc roles: [_1].',
+ join(', ', at adhoc));
+ } else {
+ $roleoption = &mt('Enter the course with one of the available ad hoc roles: [_1].',
+ join(', ', at adhoc));
+ }
+ } else {
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0]);
+ } elsif ($type eq 'Placement') {
+ $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0]);
+ } else {
+ $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0]);
+ }
+ }
+ }
+ if ($type eq 'Community') {
+ $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
+ } elsif ($type eq 'Placement') {
+ $settingsoption = &mt('View placement test settings which only a [_1] may modify.',$dctitle);
+ } else {
+ $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
+ }
+ }
+ $r->print($actiontext.'<ul>');
+ if ($roleoption) {
+ $r->print('<li>'.$roleoption.'</li>'."\n");
+ }
+ $r->print('<li>'.$settingsoption.'</li>'."\n".'</ul>');
return;
}
@@ -222,7 +265,7 @@
my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
undef,undef,undef,\@codetitles);
&Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
- undef,undef,%courses);
+ $dom,undef,%courses);
return;
}
@@ -243,7 +286,7 @@
}
sub print_modification_menu {
- my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash) = @_;
+ my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
&print_header($r,$type);
my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text,
$cdom,$cnum);
@@ -283,12 +326,14 @@
my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
sub manage_selfenrollment {
- my ($cdom,$cnum,$type,$coursehash) = @_;
- my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
- if (ref($managed_by_dc) eq 'ARRAY') {
- if (@{$managed_by_dc}) {
- return 1;
- }
+ my ($cdom,$cnum,$type,$coursehash,$permission) = @_;
+ if ($permission->{'selfenroll'}) {
+ my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
+ if (ref($managed_by_dc) eq 'ARRAY') {
+ if (@{$managed_by_dc}) {
+ return 1;
+ }
+ }
}
return 0;
}
@@ -303,7 +348,7 @@
{
linktext => $setparams_text,
url => &phaseurl('setparms'),
- permission => 1,
+ permission => $permission->{'setparms'},
#help => '',
icon => 'crsconf.png',
linktitle => ''
@@ -311,7 +356,7 @@
{
linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.',
url => &phaseurl('setquota'),
- permission => 1,
+ permission => $permission->{'setquota'},
#help => '',
icon => 'groupportfolioquota.png',
linktitle => ''
@@ -319,7 +364,7 @@
{
linktext => 'View/Modify responders threshold for anonymous survey submissions display',
url => &phaseurl('setanon'),
- permission => 1,
+ permission => $permission->{'setanon'},
#help => '',
icon => 'anonsurveythreshold.png',
linktitle => ''
@@ -327,7 +372,7 @@
{
linktext => $cat_text,
url => &phaseurl('catsettings'),
- permission => (@additional_params > 0),
+ permission => (($permission->{'catsettings'}) && (@additional_params > 0)),
#help => '',
icon => 'ccatconf.png',
linktitle => ''
@@ -335,7 +380,7 @@
{
linktext => 'Display current settings for automated enrollment',
url => &phaseurl('viewparms'),
- permission => (($type ne 'Community') && ($type ne 'Placement')),
+ permission => ($permission->{'viewparms'} && ($type ne 'Community') && ($type ne 'Placement')),
#help => '',
icon => 'roles.png',
linktitle => ''
@@ -345,7 +390,7 @@
icon => 'self_enroll.png',
#help => 'Course_Self_Enrollment',
url => &phaseurl('selfenroll'),
- permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash),
+ permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash,$permission),
linktitle => 'Configure user self-enrollment.',
},
{
@@ -353,7 +398,7 @@
icon => 'emblem-readonly.png',
#help => '',
url => &phaseurl('setpostsubmit'),
- permission => 1,
+ permission => $permission->{'setpostsubmit'},
linktitle => '',
},
]
@@ -387,18 +432,23 @@
'<li>'.$setuploadquota_text.'</li>'."\n".
'<li>'.$anon_text.'</li>'."\n".
'<li>'.$postsubmit_text.'</li>'."\n";
+ my ($categories_link_start,$categories_link_end);
+ if ($permission->{'catsettings'}) {
+ $categories_link_start = '<a href="/adm/domainprefs?actions=coursecategories&phase=display">';
+ $categories_link_end = '</a>';
+ }
foreach my $item (@additional_params) {
if ($type eq 'Community') {
if ($item eq 'togglecats') {
- $menu_html .= ' <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";
+ $menu_html .= ' <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).',$categories_link_start,$categories_link_end).'</li>'."\n";
} elsif ($item eq 'categorize') {
- $menu_html .= ' <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";
+ $menu_html .= ' <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).',$categories_link_start,$categories_link_end).'</li>'."\n";
}
} else {
if ($item eq 'togglecats') {
- $menu_html .= ' <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";
+ $menu_html .= ' <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).',$categories_link_start,$categories_link_end).'</li>'."\n";
} elsif ($item eq 'categorize') {
- $menu_html .= ' <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";
+ $menu_html .= ' <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).',$categories_link_start,$categories_link_end).'</li>'."\n";
}
}
}
@@ -414,18 +464,47 @@
return;
}
-sub print_ccrole_selected {
+sub print_adhocrole_selected {
my ($r,$type) = @_;
&print_header($r,$type);
my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
- $r->print('<form name="ccrole" method="post" action="/adm/roles">
-<input type="hidden" name="selectrole" value="1" />
-<input type="hidden" name="newrole" value="cc./'.$cdom.'/'.$cnum.'" />
+ my ($newrole,$selectrole);
+ if (&Apache::lonnet::allowed('ccc',$cdom)) {
+ if ($type eq 'Community') {
+ $newrole = "co./$cdom/$cnum";
+ } else {
+ $newrole = "cc./$cdom/$cnum";
+ }
+ $selectrole = 1;
+ } elsif (&Apache::lonnet::allowed('rar',$cdom)) {
+ my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
+ 'adhocroles.'.$cdom);
+ if (keys(%adhocroles)) {
+ my $possrole = $env{'form.adhocrole'};
+ if ($possrole ne '') {
+ my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom});
+ if (grep(/^\Q$possrole\E$/, at adhoc)) {
+ my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
+ $newrole = "cr/$cdom/$confname/$possrole./$cdom/$cnum";
+ $selectrole = 1;
+ }
+ }
+ }
+ }
+ if ($selectrole) {
+ $r->print('<form name="adhocrole" method="post" action="/adm/roles">
+<input type="hidden" name="selectrole" value="'.$selectrole.'" />
+<input type="hidden" name="newrole" value="'.$newrole.'" />
</form>');
+ } else {
+ $r->print('<form name="ccrole" method="post" action="/adm/modifycourse">'.
+ '</form>');
+ }
+ return;
}
sub print_settings_display {
- my ($r,$cdom,$cnum,$cdesc,$type) = @_;
+ my ($r,$cdom,$cnum,$cdesc,$type,$permission) = @_;
my %enrollvar = &get_enrollment_settings($cdom,$cnum);
my %longtype = &course_settings_descrip($type);
my %lt = &Apache::lonlocal::texthash(
@@ -466,25 +545,35 @@
}
$disp_table .= &Apache::loncommon::end_data_table()."\n";
&print_header($r,$type);
- my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
- my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
- '=1&destinationurl=/adm/populate','&<>"');
+ my ($enroll_link_start,$enroll_link_end,$setparms_link_start,$setparms_link_end);
+ if (&Apache::lonnet::allowed('ccc',$cdom)) {
+ my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
+ my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
+ '=1&destinationurl=/adm/populate','&<>"');
+ $enroll_link_start = '<a href="'.$escuri.'">';
+ $enroll_link_end = '</a>';
+ }
+ if ($permission->{'setparms'}) {
+ $setparms_link_start = '<a href="javascript:changePage(document.viewparms,'."'setparms'".');">';
+ $setparms_link_end = '</a>';
+ }
$r->print('<h3>'.&mt('Current automated enrollment settings for:').
' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
'<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
'<p>'.$lt{'cose'}.'<ul>'.
- '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'<a href="'.$escuri.'">','</a>').'</li>');
+ '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',
+ $cctitle,$enroll_link_start,$enroll_link_end).'</li>');
if (&showcredits($cdom)) {
- $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, and self-enrollment[_3].',$dctitle,'<a href="javascript:changePage(document.viewparms,'."'setparms'".');">','</a>')."\n");
+ $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, and self-enrollment[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
} else {
- $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, and self-enrollment[_3].',$dctitle,'<a href="javascript:changePage(document.viewparms,'."'setparms'".');">','</a>')."\n");
+ $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, and self-enrollment[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
}
$r->print('</li></ul></p>'.
'<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
'<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
&hidden_form_elements().
'</p></form>'
- );
+ );
}
sub print_setquota {
@@ -2059,9 +2148,9 @@
}
my $starthash;
- if ($env{'form.phase'} eq 'ccrole') {
+ if ($env{'form.phase'} eq 'adhocrole') {
$starthash = {
- add_entries => {'onload' => "javascript:document.ccrole.submit();"},
+ add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
};
} elsif ($phase eq 'courselist') {
$starthash = {
@@ -2178,6 +2267,34 @@
}
}
+sub get_permission {
+ my ($dom) = @_;
+ my ($allowed,%permission);
+ if (&Apache::lonnet::allowed('ccc',$dom)) {
+ $allowed = 1;
+ %permission = (
+ setquota => 1,
+ processquota => 1,
+ setanon => 1,
+ processthreshold => 1,
+ setpostsubmit => 1,
+ processpostsubmit => 1,
+ viewparms => 1,
+ setparms => 1,
+ processparms => 1,
+ catsettings => 1,
+ processcat => 1,
+ selfenroll => 1,
+ );
+ } elsif (&Apache::lonnet::allowed('rar',$dom)) {
+ $allowed = 1;
+ %permission = (
+ viewparms => 1,
+ );
+ }
+ return ($allowed,\%permission);
+}
+
sub handler {
my $r = shift;
if ($r->header_only) {
@@ -2188,8 +2305,8 @@
my $dom = $env{'request.role.domain'};
my $domdesc = &Apache::lonnet::domain($dom,'description');
-
- if (&Apache::lonnet::allowed('ccc',$dom)) {
+ my ($allowed,$permission) = &get_permission($dom);
+ if ($allowed) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -2244,23 +2361,24 @@
({href=>"javascript:changePage(document.$phase,'menu')",
text=>"Pick action"});
&print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
- $env{'form.pickedcourse'},$coursehash);
- } elsif ($phase eq 'ccrole') {
+ $env{'form.pickedcourse'},$coursehash,
+ $permission);
+ } elsif ($phase eq 'adhocrole') {
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:changePage(document.$phase,'ccrole')",
+ ({href=>"javascript:changePage(document.$phase,'adhocrole')",
text=>$enter_text});
- &print_ccrole_selected($r,$type);
+ &print_adhocrole_selected($r,$type);
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'menu')",
text=>"Pick action"});
my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
- if ($phase eq 'setquota') {
+ if (($phase eq 'setquota') && ($permission->{'setquota'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
- text=>"Set quota"});
+ text=>"Set quota",});
&print_setquota($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'processquota') {
+ } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'setquota')",
text=>"Set quota"});
@@ -2268,12 +2386,12 @@
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'setanon') {
+ } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Threshold for anonymous submissions display"});
&print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'processthreshold') {
+ } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'setanon')",
text=>"Threshold for anonymous submissions display"});
@@ -2281,27 +2399,27 @@
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'setpostsubmit') {
+ } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Configure submit button behavior post-submission"});
&print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'processpostsubmit') {
+ } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'viewparms') {
+ } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'viewparms')",
text=>"Display settings"});
- &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'setparms') {
+ &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
+ } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Change settings"});
&print_course_modification_page($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'processparms') {
+ } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'setparms')",
text=>"Change settings"});
@@ -2309,12 +2427,12 @@
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'catsettings') {
+ } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Catalog settings"});
&print_catsettings($r,$cdom,$cnum,$cdesc,$type);
- } elsif ($phase eq 'processcat') {
+ } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'catsettings')",
text=>"Catalog settings"});
@@ -2322,7 +2440,7 @@
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'selfenroll') {
+ } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href => "javascript:changePage(document.$phase,'$phase')",
text => "Self-enrollment settings"});
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.118 loncom/interface/lonpickcourse.pm:1.119
--- loncom/interface/lonpickcourse.pm:1.118 Mon Oct 3 18:46:29 2016
+++ loncom/interface/lonpickcourse.pm Wed Oct 5 13:59:46 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.118 2016/10/03 18:46:29 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.119 2016/10/05 13:59:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -404,29 +404,70 @@
.'<fieldset>'
.'<legend>'.&mt('Pick action').'</legend>'
.'<span class="LC_nobreak"><label>'
- .'<input type="radio" name="phase" value="ccrole"'.$ccrolechk.'/>'
+ .'<input type="radio" name="phase" value="adhocrole"'.$ccrolechk.'/>'
.' ');
- if ($type eq 'Community') {
- $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
- } elsif ($type eq 'Placement') {
- $r->print(&mt('Enter the placement test with the role of [_1].',$cctitle));
- } else {
- $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
+ if (&Apache::lonnet::allowed('ccc',$crsdom)) {
+ if ($type eq 'Community') {
+ $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
+ } elsif ($type eq 'Placement') {
+ $r->print(&mt('Enter the placement test with the role of [_1].',$cctitle));
+ } else {
+ $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
+ }
+ } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
+ my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
+ 'adhocroles.'.$crsdom);
+ if (keys(%adhocroles)) {
+ 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') {
+ $r->print(&mt('Enter the community with one of the available ad hoc roles: [_1].',
+ $selector));
+ } elsif ($type eq 'Placement') {
+ $r->print(&mt('Enter the placement test with one of the available ad hoc roles: [_1].',
+ $selector));
+ } else {
+ $r->print(&mt('Enter the course with one of the available ad hoc roles: [_1].',
+ $selector));
+ }
+ } else {
+ if ($type eq 'Community') {
+ $r->print(&mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0]));
+ } elsif ($type eq 'Placement') {
+ $r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0]));
+ } else {
+ $r->print(&mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0]));
+ }
+ }
+ }
}
$r->print('</label></span><br />'
.'<span class="LC_nobreak"><label>'
.'<input type="radio" name="phase" value="menu"'.$menuchk.'/> ');
- if ($type eq 'Community') {
- $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
- } elsif ($type eq 'Placement') {
- $r->print(&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle));
- } else {
- $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
+ if (&Apache::lonnet::allowed('ccc',$crsdom)) {
+ if ($type eq 'Community') {
+ $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
+ } elsif ($type eq 'Placement') {
+ $r->print(&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle));
+ } else {
+ $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
+ }
+ } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
+ if ($type eq 'Community') {
+ $r->print(&mt('View community settings which only a [_1] may modify.',$dctitle));
+ } elsif ($type eq 'Placement') {
+ $r->print(&mt('View placement test settings which only a [_1] may modify.',$dctitle));
+ } else {
+ $r->print(&mt('View course settings which only a [_1] may modify.',$dctitle));
+ }
}
$r->print('</label></span>'
- .'</fieldset></div>'
- .'<br clear="all" />'
- );
+ .'</fieldset></div>'
+ .'<br clear="all" />'
+ );
}
}
my %by_descrip;
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.166 loncom/interface/mydesk.tab:1.167
--- loncom/interface/mydesk.tab:1.166 Sat May 21 21:16:25 2016
+++ loncom/interface/mydesk.tab Wed Oct 5 13:59:46 2016
@@ -221,6 +221,7 @@
6:2:author:rca:res.png:co res[_1]:space[_4]:go('/res/$udom/$uname/?launch=1');:Browse published resources:cnt
6:3:clear
6:3:pccc:$requested_domain:mcrs.png:modify[_1]:course[_15]:go('/adm/modifycourse');:View or modify a course or community:ccm
+6:3:prar:$requested_domain:mcrs.png:view[_2]:course[_17]:go('/adm/modifycourse');:View a course or community:ccm
7:1:clear
7:1:pmau:$requested_domain:srvr.png:server[_1]:status[_1]:go('/adm/domainstatus');:Status of domain servers:dom
7:1:pwhn:$crs:new.png:what is[_1]:new[_1]:go('/adm/whatsnew');:What's New?:cmn
More information about the LON-CAPA-cvs
mailing list