--- loncom/interface/groupboards.pm 2006/07/17 14:52:00 1.7
+++ loncom/interface/groupboards.pm 2012/11/11 17:33:18 1.16
@@ -1,6 +1,8 @@
# The LearningOnline Network
# Group Bulletin Boards Manager
#
+# $Id: groupboards.pm,v 1.16 2012/11/11 17:33:18 raeburn Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -28,10 +30,10 @@ package Apache::groupboards;
use strict;
use Apache::Constants qw(:common :http);
-use Apache::loncommon;
+use Apache::loncommon();
use Apache::lonnet;
-use Apache::lonuserstate;
-use Apache::lonratedt;
+use Apache::lonuserstate();
+use LONCAPA::map();
use Apache::lonlocal;
use LONCAPA;
@@ -59,7 +61,7 @@ sub handler {
my $gpterm = &Apache::loncommon::group_term();
my $ucgpterm = $gpterm;
$ucgpterm =~ s/^(\w)/uc($1)/e;
- my $bodytitle = &mt('[_1] Discussion Boards',$crstype);
+ my $bodytitle = $ucgpterm.' Discussion Boards';
my $group = $env{'form.group'};
$group =~ s/\W//g;
my ($description,$earlyout,$refarg);
@@ -77,7 +79,7 @@ sub handler {
}
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
if (!defined($curr_groups{$group})) {
- $earlyout = &mt('Invalid [_1]',$gpterm);
+ $earlyout = &mt('Invalid group');
$r->print(&display_error($cdom,$cnum,$group,$description,$gpterm,
$ucgpterm,$bodytitle,$earlyout,$refarg));
return OK;
@@ -103,7 +105,7 @@ sub handler {
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
$r->print(&boards_header($cdom,$cnum,$group,$description,$gpterm,
$ucgpterm,$bodytitle,$refarg));
- my ($outcome,$newurl,$bbtitle) =
+ my ($outcome,$newurl,$bbtitle,$lockfreed) =
&create_board($cdom,$cnum,$group,$env{'form.newbul'});
if ($outcome eq 'ok') {
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
@@ -115,6 +117,11 @@ sub handler {
''.&mt('View all group discussion boards').
'');
+ if ($lockfreed ne 'ok') {
+ $r->print(&mt('There was a problem removing a lockfile for the group ([_1]).',$description).'
'.
+ &mt('This may prevent creation of additional bulletin boards in this group.').'
'.
+ &mt('Please contact the domain coordinator for your LON-CAPA domain.'));
+ }
} else {
$r->print(&mt('There was a problem creating the new discussion board - [_1]',''.$outcome.'').'
'.
&mt('Return to discussion boards').'');
@@ -130,8 +137,7 @@ sub handler {
function makebulboard() {
var title=prompt('Discussion Board Title');
if (title) {
- this.document.forms.newbb.newbul.value=
- title+'=/adm/$cdom/$cnum/$now/bulletinboard';
+ this.document.forms.newbb.newbul.value=title;
this.document.forms.newbb.submit();
}
}
@@ -153,7 +159,12 @@ function makebulboard() {
"\n".'
');
}
if (@{$groupboards} > 0) {
- $r->print('
');
+ $r->print('
'
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row()
+ .'
' + .&mt('There are currently no discussion boards in this '.$gpterm.'.',) + .'
' + ); } $r->print(&Apache::loncommon::end_page()); return OK; } sub create_board { - my ($cdom,$cnum,$group,$newboard) = @_; - my ($bbtitle,$newurl)=split(/\=/,$newboard); - my $outcome; - my ($boardid) = ($newurl =~ m-/adm/\Q$cdom\E/\Q$cnum\E/(\d+)/bulletinboard-); - if (!$boardid) { - $outcome = ('error: the URL for new board was invalid'); - return ($outcome,$newurl,$bbtitle); - } + my ($cdom,$cnum,$group,$bbtitle) = @_; + my ($outcome,$newurl,$idtype); $bbtitle=&unescape($bbtitle); - $newurl=&unescape($newurl); + $idtype = 'inc'; + my ($boardid,$dellock,$error) = + &Apache::lonnet::get_timebased_id($group,'boardids','groupboards', + $cdom,$cnum); + if ($boardid) { + $newurl = '/adm/'.$cdom.'/'.$cnum.'/'.$boardid.'/bulletinboard'; + } else { + return ($error,$newurl,$bbtitle,$dellock); + } + + # need to check here if group_boards_$group.sequence is in the course + # if not - add it as an item in group_folder_$group.sequence my $allbbsmap = &Apache::longroup::get_bbfolder_url($cdom,$cnum,$group); if ($allbbsmap =~ m|^/uploaded|) { - my ($errtext,$fatal)=&Apache::lonratedt::mapread($allbbsmap); + my ($errtext,$fatal)=&LONCAPA::map::mapread($allbbsmap); if (!$fatal) { - my $newidx=&Apache::lonratedt::getresidx($newurl); - $Apache::lonratedt::resources[$newidx]=$bbtitle.':'.$newurl. + my $newidx=&LONCAPA::map::getresidx($newurl); + $LONCAPA::map::resources[$newidx]=$bbtitle.':'.$newurl. ':false:normal:res'; - push(@Apache::lonratedt::order,$newidx); - my ($errtext,$fatal)=&Apache::lonratedt::storemap($allbbsmap,1); + push(@LONCAPA::map::order,$newidx); + my ($errtext,$fatal)=&LONCAPA::map::storemap($allbbsmap,1,1); if ($fatal) { - $outcome = "error: failed to store discussion boards map - $errtext\n"; + $outcome = "error: failed to save discussion boards map - $errtext\n"; } else { my %boardinfo = ( 'group' => $group, @@ -208,7 +232,7 @@ sub create_board { $outcome = 'error: discussion boards folder absent, '. 'or in unexpected location - '.$allbbsmap."\n"; } - return ($outcome,$newurl,$bbtitle); + return ($outcome,$newurl,$bbtitle,$dellock); } sub display_error {