[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm lonhtmlcommon.pm lonpickcourse.pm lonuserutils.pm
raeburn
raeburn@source.lon-capa.org
Sat, 31 Oct 2009 14:27:49 -0000
This is a MIME encoded message
--raeburn1256999269
Content-Type: text/plain
raeburn Sat Oct 31 14:27:49 2009 EDT
Modified files:
/loncom/interface loncreateuser.pm lonuserutils.pm lonhtmlcommon.pm
lonpickcourse.pm
Log:
- Accommodate Communities
- (C)course(s) -> (C)community(ies)
- ad hoc role for DC - "co" role assigned for communities.
--raeburn1256999269
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091031142749.txt"
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.320 loncom/interface/loncreateuser.pm:1.321
--- loncom/interface/loncreateuser.pm:1.320 Fri Oct 30 18:32:25 2009
+++ loncom/interface/loncreateuser.pm Sat Oct 31 14:27:48 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.320 2009/10/30 18:32:25 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.321 2009/10/31 14:27:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3957,10 +3957,22 @@
text=>"List Users"});
my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
my $formname = 'studentform';
- if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
- ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
- &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
- $formname);
+ if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community'))) {
+ if ($env{'form.roletype'} eq 'course') {
+ ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
+ &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
+ $formname);
+ } elsif ($env{'form.roletype'} eq 'community') {
+ $cb_jscript =
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
+ my %elements = (
+ coursepick => 'radio',
+ coursetotal => 'text',
+ courselist => 'text',
+ );
+ $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
+ }
$jscript .= &verify_user_display();
my $js = &add_script($jscript).$cb_jscript;
my $loadcode =
@@ -5840,7 +5852,7 @@
$thiscourse=~s:_:/:g;
my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
my $area=$coursedata{'description'};
- my $type=$coursedata{'type'};
+ my $crstype=$coursedata{'type'};
if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
my ($domain,$cnum)=split(/\//,$thiscourse);
my %sections_count;
@@ -5850,9 +5862,9 @@
&Apache::loncommon::get_sections($domain,$cnum);
}
}
- my @roles = &Apache::lonuserutils::roles_by_context('course');
+ my @roles = &Apache::lonuserutils::roles_by_context('course','',$crstype);
foreach my $role (@roles) {
- my $plrole=&Apache::lonnet::plaintext($role,$type);
+ my $plrole=&Apache::lonnet::plaintext($role,$crstype);
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
$plrole,\%sections_count,\%lt);
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.101 loncom/interface/lonuserutils.pm:1.102
--- loncom/interface/lonuserutils.pm:1.101 Fri Oct 30 03:57:35 2009
+++ loncom/interface/lonuserutils.pm Sat Oct 31 14:27:48 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.101 2009/10/30 03:57:35 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.102 2009/10/31 14:27:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -247,6 +247,10 @@
foreach my $roletype (@roletypes) {
# set up the text for this domain
$select_menus{$roletype}->{'text'}= $lt{$roletype};
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community';
+ }
# we want a choice of 'default' as the default in the second menu
if ($env{'form.roletype'} ne '') {
$select_menus{$roletype}->{'default'} = $env{'form.showrole'};
@@ -271,7 +275,7 @@
&mt('Custom role');
} else {
$select_menus{$roletype}->{'select2'}->{$role} =
- &Apache::lonnet::plaintext($role);
+ &Apache::lonnet::plaintext($role,$crstype);
}
}
$select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any');
@@ -1290,7 +1294,13 @@
sub course_roles {
my ($context,$checkpriv,$custom,$roletype) = @_;
- my @allroles = &roles_by_context('course',$custom,$roletype);
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community' ;
+ } else {
+ $crstype = 'Course';
+ }
+ my @allroles = &roles_by_context('course',$custom,$crstype);
my @roles;
if ($context eq 'domain') {
@roles = @allroles;
@@ -1437,19 +1447,32 @@
}
my ($indexhash,$keylist) = &make_keylist_array();
my (%userlist,%userinfo);
- if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+ if (($context eq 'domain') &&
+ ($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
+ my ($crstype,$numcodes,$title,$warning);
+ if ($env{'form.roletype'} eq 'course') {
+ $crstype = 'Course';
+ $numcodes = $totcodes;
+ $title = &mt('Select Courses');
+ $warning = &mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.');
+ } elsif ($env{'form.roletype'} eq 'community') {
+ $crstype = 'Community';
+ $numcodes = 0;
+ $title = &mt('Select Communities');
+ $warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.');
+ }
my $courseform =
- &Apache::lonhtmlcommon::course_selection($formname,$totcodes,
- $codetitles,$idlist,$idlist_titles);
+ &Apache::lonhtmlcommon::course_selection($formname,$numcodes,
+ $codetitles,$idlist,$idlist_titles,$crstype);
$r->print('<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n".
&Apache::lonhtmlcommon::start_pick_box()."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Select Course(s)'),
- 'LC_oddrow_value')."\n".
+ &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n".
$courseform."\n".
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().'</p>'.
'<p>'.&list_submit_button(&mt('Update Display')).
- "\n".'</p><span class="LC_warning">'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').'</span>'."\n");
+ "\n".'</p><span class="LC_warning">'.$warning.'</span>'."\n");
if ($env{'form.coursepick'}) {
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />');
}
@@ -1761,7 +1784,8 @@
$indexhash,$uniqid,$userlist);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
split(/:/,$item);
if (ref($rolehash->{$item}) eq 'HASH') {
@@ -1811,7 +1835,8 @@
sub build_user_record {
my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
- if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community')))) {
&process_date_info($userdata);
}
my $username = $userdata->{'username'};
@@ -2114,6 +2139,12 @@
<input type="hidden" name="displayclickers" value="$displayclickers" />
END
}
+ } elsif ($context eq 'domain') {
+ if ($setting eq 'community') {
+ $crstype = 'Community';
+ } elsif ($crstype eq 'course') {
+ $crstype = 'Course';
+ }
}
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
@@ -2210,6 +2241,8 @@
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
+ } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
+ $lt{'extent'} = &mt('Communities: description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
@@ -2221,18 +2254,21 @@
if ($context eq 'course') {
push(@cols,'section');
}
- if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
+ if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community'))) {
push(@cols,('start','end'));
}
if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
push(@cols,'role');
}
if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
- $env{'form.roletype'} eq 'course')) {
+ $env{'form.roletype'} eq 'course' ||
+ $env{'form.roletype'} eq 'community')) {
push (@cols,'extent');
}
if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
+ (!($context eq 'domain' && (($env{'form.roletype'} eq 'course')
+ || ($env{'form.roletype'} eq 'community'))))) {
push(@cols,'status');
}
if ($context eq 'course') {
@@ -2250,7 +2286,7 @@
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission,$mode);
+ $context,$permission,$mode,$crstype);
$r->print('<b>'.$results_description.'</b><br /><br />');
}
my ($output,$actionselect,%canchange,%canchangesec);
@@ -2486,7 +2522,8 @@
}
} elsif ($env{'form.roletype'} eq 'author') {
($uname,$udom,$role) = split(/:/,$user,-1);
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($uname,$udom,$role) = split(/:/,$user);
}
} else {
@@ -2593,7 +2630,7 @@
if ($clickers!~/\w/) { $clickers='-'; }
$in{'clicker'} = $clickers;
my $role = $in{'role'};
- $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
+ $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
if (! defined($in{'start'}) || $in{'start'} == 0) {
$in{'start'} = &mt('none');
} else {
@@ -3200,26 +3237,50 @@
}
sub results_header_row {
- my ($rolefilter,$statusmode,$context,$permission,$mode) = @_;
+ my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_;
my ($description,$showfilter);
if ($rolefilter ne 'Any') {
$showfilter = $rolefilter;
}
if ($context eq 'course') {
if ($mode eq 'csv' || $mode eq 'excel') {
- $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ if ($crstype eq 'Community') {
+ $description = &mt('Community - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ } else {
+ $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ }
}
if ($statusmode eq 'Expired') {
- $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with expired [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Future') {
- $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with future [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Active') {
- $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with active [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ }
} else {
if ($rolefilter eq 'Any') {
- $description .= &mt('All users in course');
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community');
+ } else {
+ $description .= &mt('All users in course');
+ }
} else {
- $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community with [_1] roles',$rolefilter);
+ } else {
+ $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ }
}
}
my $constraint;
@@ -3315,19 +3376,28 @@
$description .= &mt('All co-authors in domain with [_1] roles',$rolefilter);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
my $coursefilter = $env{'form.coursepick'};
- if ($coursefilter eq 'category') {
- my $instcode = &instcode_from_coursefilter();
- if ($instcode eq '.') {
+ if ($env{'form.roletype'} eq 'course') {
+ if ($coursefilter eq 'category') {
+ my $instcode = &instcode_from_coursefilter();
+ if ($instcode eq '.') {
+ $description .= &mt('All courses in domain').' - ';
+ } else {
+ $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
+ }
+ } elsif ($coursefilter eq 'selected') {
+ $description .= &mt('Selected courses in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
$description .= &mt('All courses in domain').' - ';
- } else {
- $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
}
- } elsif ($coursefilter eq 'selected') {
- $description .= &mt('Selected courses in domain').' - ';
- } elsif ($coursefilter eq 'all') {
- $description .= &mt('All courses in domain').' - ';
+ } elsif ($env{'form.roletype'} eq 'community') {
+ if ($coursefilter eq 'selected') {
+ $description .= &mt('Selected communities in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
+ $description .= &mt('All communities in domain').' - ';
+ }
}
if ($statusmode eq 'Expired') {
$description .= &mt('users with expired [_1] roles',$showfilter);
@@ -3731,7 +3801,7 @@
}
my (%userlist,%modifiable_fields,@poss_roles);
my $secidx = &Apache::loncoursedata::CL_SECTION();
- my @courseroles = &roles_by_context('course',1,'',$crstype);
+ my @courseroles = &roles_by_context('course',1,$crstype);
if (!&Apache::lonnet::allowed('mau',$domain)) {
if ($context eq 'course' || $context eq 'author') {
@poss_roles = &curr_role_permissions($context,'','',$crstype);
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.236 loncom/interface/lonhtmlcommon.pm:1.237
--- loncom/interface/lonhtmlcommon.pm:1.236 Fri Oct 30 05:10:03 2009
+++ loncom/interface/lonhtmlcommon.pm Sat Oct 31 14:27:48 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.236 2009/10/30 05:10:03 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.237 2009/10/31 14:27:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1633,15 +1633,15 @@
sub course_select_row {
my ($title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles,
- $css_class) = @_;
+ $css_class,$crstype) = @_;
my $output = &row_title($title,$css_class);
- $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+ $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype);
$output .= &row_closure();
return $output;
}
sub course_selection {
- my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_;
+ my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype) = @_;
my $output = qq|
<script type="text/javascript">
// <![CDATA[
@@ -1670,9 +1670,19 @@
// ]]>
</script>
|;
+
+ my ($allcrs,$pickspec);
+ if ($crstype eq 'Community') {
+ $allcrs = &mt('All communities');
+ $pickspec = &mt('Pick specific communities:');
+ } else {
+ $allcrs = &mt('All courses');
+ $pickspec = &mt('Pick specific course(s):');
+ }
+
my $courseform='<b>'.&Apache::loncommon::selectcourse_link
- ($formname,'pickcourse','pickdomain','coursedesc','',1).'</b>';
- $output .= '<input type="radio" name="coursepick" value="all" onclick="coursePick(this.form)" />'.&mt('All courses').'<br />';
+ ($formname,'pickcourse','pickdomain','coursedesc','',1,$crstype).'</b>';
+ $output .= '<input type="radio" name="coursepick" value="all" onclick="coursePick(this.form)" />'.$allcrs.'<br />';
if ($totcodes > 0) {
my $numtitles = @$codetitles;
if ($numtitles > 0) {
@@ -1717,7 +1727,7 @@
$output .= '</tr></table><br />';
}
}
- $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."','dccourse','dcdomain','coursedesc','','1'".')" />'.&mt('Pick specific course(s):').' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n";
+ $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."','dccourse','dcdomain','coursedesc','','1'".')" />'.$pickspec.' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n";
return $output;
}
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.87 loncom/interface/lonpickcourse.pm:1.88
--- loncom/interface/lonpickcourse.pm:1.87 Fri Oct 30 04:44:56 2009
+++ loncom/interface/lonpickcourse.pm Sat Oct 31 14:27:48 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.87 2009/10/30 04:44:56 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.88 2009/10/31 14:27:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -223,7 +223,12 @@
$process_pick .= <<"ENDTWO";
if (pickedDomain == dom) {
if (pickedCourse != '') {
- var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
+ var ccrole = "cc";
+ var pickedType = "$env{'form.type'}";
+ if (pickedType == "Community") {
+ ccrole = "co";
+ }
+ var courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse
opener.document.title='Role selected. Please stand by.';
opener.status='Role selected. Please stand by.';
opener.document.rolechoice.newrole.value=courseTarget
@@ -891,9 +896,9 @@
list => 'courselist',
},
'Community' => {
- name => 'grouppick',
- total => 'grouptotal',
- list => 'grouplist',
+ name => 'coursepick',
+ total => 'coursetotal',
+ list => 'courselist',
},
);
my $output .= qq|
--raeburn1256999269--