[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /interface loncoursegroups.pm
raeburn
raeburn@source.lon-capa.org
Tue, 16 Dec 2008 23:52:08 -0000
raeburn Tue Dec 16 23:52:08 2008 EDT
Modified files: (Branch: version_2_8_X)
/loncom/interface loncoursegroups.pm
Log:
- Backport 1.85, 1.86. and a part of 1.87.
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.80.2.2 loncom/interface/loncoursegroups.pm:1.80.2.3
--- loncom/interface/loncoursegroups.pm:1.80.2.2 Tue Dec 16 23:19:19 2008
+++ loncom/interface/loncoursegroups.pm Tue Dec 16 23:52:08 2008
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.80.2.2 2008/12/16 23:19:19 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.80.2.3 2008/12/16 23:52:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1259,12 +1259,18 @@
sub modify_folders {
my ($cdom,$cnum,$groupname) = @_;
- my $outcome;
+ my ($outcome,$groupmap,$groupmapres,$map,$id,$src);
my $navmap = Apache::lonnavmaps::navmap->new();
- my $groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'.
+ if (!defined($navmap)) {
+ $outcome = '<div class="LC_error">'.
+ &mt('Error reading course contents.').' '.
+ &mt('You need to re-initialize the course.').
+ '</div>';
+ return $outcome;
+ }
+ $groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'.
$groupname.'.sequence';
- my $groupmapres = $navmap->getResourceByUrl($groupmap);
- my ($map,$id,$src);
+ $groupmapres = $navmap->getResourceByUrl($groupmap);
if ($groupmapres) {
($map,$id,$src)=&Apache::lonnet::decode_symb($groupmapres->symb());
}
@@ -3222,36 +3228,49 @@
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
my $boardsmap = $crspath.'group_boards_'.$groupname.'.sequence';
my $navmap = Apache::lonnavmaps::navmap->new();
- my $bbmapres = $navmap->getResourceByUrl($boardsmap);
- undef($navmap);
- if (!$bbmapres) {
- my $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
- my $disctitle = &mt('Discussion Boards');
- my $outcome = &map_updater($cdom,$cnum,'group_boards_'.
- $groupname.'.sequence','bbseq',
- $disctitle,$grpmap);
- my ($furl,$ferr) =
- &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
- $navmap = Apache::lonnavmaps::navmap->new();
- # modify parameter
- if ($outcome eq 'ok') {
- my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
- $groupname);
- if ($parm_result) {
- $r->print('<div class="LC_error">'
- .&mt('An error occurred while setting parameters '
- .'for Discussion Boards folder: '
- .'[_1]',$parm_result)
- .'</div>');
+ my ($bbmapres,$error);
+ if (defined($navmap)) {
+ $bbmapres = $navmap->getResourceByUrl($boardsmap);
+ undef($navmap);
+ if (!$bbmapres) {
+ my $grpmap = $crspath.'group_folder_'.$groupname.'.sequence';
+ my $disctitle = &mt('Discussion Boards');
+ my $outcome = &map_updater($cdom,$cnum,'group_boards_'.
+ $groupname.'.sequence','bbseq',
+ $disctitle,$grpmap);
+ my ($furl,$ferr) =
+ &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+ # modify parameter
+ if ($outcome eq 'ok') {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
+ $groupname);
+ if ($parm_result) {
+ $error = &mt('An error occurred while setting parameters '
+ .'for Discussion Boards folder: '
+ .'[_1]',$parm_result);
+ } else {
+ $r->print('<div class="LC_success">'.
+ &mt('Discussion Boards Folder created.')
+ .'</div>');
+ }
+ undef($navmap);
+ } else {
+ $error = &mt('An error occurred while setting parameters '.
+ 'for Discussion Boards folder: '.
+ 'Could not retrieve course information' );
+ }
} else {
- $r->print('<div class="LC_success">'
- .&mt('Discussion Boards Folder created.')
- .'</div>');
+ $r->print($outcome);
}
- } else {
- $r->print($outcome);
}
- undef($navmap);
+ } else {
+ $error = &mt("An error occurred while retrieving the contents of the group's folder.").'<br />'.
+ &mt('You need to re-initialize the course.');
+ }
+ if ($error ne '') {
+ $r->print('<div class="LC_error">'.$error.'</div>');
}
}
$r->print('<div class="LC_success">'
@@ -3828,6 +3847,10 @@
}
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
my $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ return $warning.'<span class="LC_error">'.&mt('Error retrieving course contents').
+ ' '.&mt('You need to re-initialize the course.').'</span>';
+ }
# modify parameters
my $parm_result;
if ($action eq 'create') {
@@ -3933,6 +3956,13 @@
sub parm_setter {
my ($navmap,$cdom,$url,$groupname) = @_;
my $allresults;
+ if (!defined($navmap)) {
+ $allresults = '<div class="LC_warning">'.
+ &mt('Parameters not set for [_1] because the contents of the course could not be retrieved.',$url).' '.
+ &mt('You need to reinitialize the course.').
+ '</div>';
+ return $allresults;
+ }
my %hide_settings = (
'course' => {
'num' => 13,