[LON-CAPA-cvs] cvs: loncom /interface loncoursegroups.pm
raeburn
raeburn@source.lon-capa.org
Tue, 16 Dec 2008 19:33:37 -0000
raeburn Tue Dec 16 19:33:37 2008 EDT
Modified files:
/loncom/interface loncoursegroups.pm
Log:
- Provide warning messages in cases where a $navmap object is unavailable.
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.84 loncom/interface/loncoursegroups.pm:1.85
--- loncom/interface/loncoursegroups.pm:1.84 Tue Dec 16 16:44:28 2008
+++ loncom/interface/loncoursegroups.pm Tue Dec 16 19:33:36 2008
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.84 2008/12/16 16:44:28 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.85 2008/12/16 19:33:36 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">'
@@ -3827,6 +3846,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') {
@@ -3932,6 +3955,10 @@
sub parm_setter {
my ($navmap,$cdom,$url,$groupname) = @_;
my $allresults;
+ if (!defined($navmap)) {
+ $allresults = &mt('Parameters not set for [_1] because the contents of the course could not be retrieved.',$url).' '.
+ &mt('You need to reinitialize the course.').'<br />';
+ }
my %hide_settings = (
'course' => {
'num' => 13,