version 1.17, 2004/04/30 23:13:52
|
version 1.44, 2006/07/08 01:12:53
|
Line 37 use Apache::lonfeedback;
|
Line 37 use Apache::lonfeedback;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonprintout; |
use Apache::lonprintout; |
use Apache::lonxml; |
use Apache::lonxml; |
|
use Apache::longroup; |
|
use LONCAPA; |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
|
my $target=$env{'form.grade_target'}; |
# ------------------------------------------------------------ Print the screen |
# ------------------------------------------------------------ Print the screen |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($target eq 'tex') { |
$r->print(<<ENDDOCUMENT); |
$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); |
<html> |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
ENDDOCUMENT |
|
} else { |
|
$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'})); |
|
} |
} |
my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri); |
my (undef,undef,$udom,$uname,$marker,$caller)=split(/\//,$r->uri); |
# Is this even in a course? |
# Is this even in a course? |
unless ($ENV{'request.course.id'}) { |
unless ($env{'request.course.id'}) { |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($target ne 'tex') { |
$r->print('</head><body>Not in a course</body></html>'); |
&Apache::loncommon::simple_error_page($r,'','Not in a course'); |
return OK; |
|
} else { |
} else { |
$r->print('\textbf{Not in a course}\end{document}'); |
$r->print('\textbf{Not in a course}\end{document}'); |
} |
} |
|
return OK; |
} |
} |
|
|
$marker=~s/\D//g; |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
unless ($marker) { |
my $grp_view_permission = &Apache::lonnet::allowed('vcg', |
$r->print('<body>Invalid call</body>'); |
$env{'request.course.id'}); |
return OK; |
my ($namespace,$group,$grp_desc); |
|
|
|
my %curr_group = (); |
|
my %groupinfo = (); |
|
if ($dom && $crs && ($udom eq $dom) && ($uname eq $crs)) { |
|
$marker =~ s/\W//g; |
|
$group = $marker; |
|
my %curr_groups = &Apache::longroup::coursegroups($dom,$crs,$group); |
|
if (!%curr_groups) { |
|
&Apache::loncommon::simple_error_page($r,'','Invalid group name'); |
|
return OK; |
|
} |
|
%groupinfo = |
|
&Apache::longroup::get_group_settings($curr_groups{$group}); |
|
$grp_desc = &unescape($groupinfo{'description'}); |
|
$namespace = 'grppage_'.$group; |
|
} else { |
|
$marker=~s/\D//g; |
|
$namespace = 'smppage_'.$marker; |
} |
} |
|
|
my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
if (!$marker) { |
my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
&Apache::loncommon::simple_error_page($r,'','Invalid call'); |
|
return OK; |
|
} |
|
|
# --------------------------------------------------------- The syllabus fields |
# --------------------------------------------------------- The syllabus fields |
my %syllabusfields=&Apache::lonlocal::texthash( |
my %syllabusfields=&Apache::lonlocal::texthash( |
'aaa_title' => 'Page Title', |
'aaa_title' => 'Page Title', |
'bbb_content' => 'Content', |
'bbb_content' => 'Content', |
'ccc_webreferences' => 'Web References'); |
'ccc_webreferences' => 'Web References'); |
|
if ($group ne '') { |
|
$syllabusfields{'abb_links'} = &mt('Functionality'); |
|
} |
|
|
|
|
# ------------------------------------------------------------ Get query string |
# ------------------------------------------------------------ Get query string |
&Apache::loncommon::get_unprocessed_cgi |
&Apache::loncommon::get_unprocessed_cgi |
($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']); |
($ENV{'QUERY_STRING'},['forcestudent','forceedit', |
# ----------------------------------------------------- Force menu registration |
'register','ref']); |
my $addentries=''; |
|
if ($ENV{'form.register'}) { |
|
$addentries=' onLoad="'.&Apache::lonmenu::loadevents(). |
|
'" onUnload="'.&Apache::lonmenu::unloadevents().'"'; |
|
$r->print(&Apache::lonmenu::registerurl(1)); |
|
} |
|
# --------------------------------------------------------------- Force Student |
# --------------------------------------------------------------- Force Student |
my $forcestudent=''; |
my $forcestudent=''; |
if ($ENV{'form.forcestudent'} ||$ENV{'form.grade_target'} eq 'tex' ) { $forcestudent='student'; }; |
if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; }; |
my $forceedit=''; |
my $forceedit=''; |
if ($ENV{'form.forceedit'}) { $forceedit='edit'; } |
if ($env{'form.forceedit'}) { $forceedit='edit'; } |
|
|
|
|
my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs); |
|
|
my %syllabus=&Apache::lonnet::dump($namespace,$dom,$crs); |
|
|
# --------------------------------------- There is such a user, get environment |
# --------------------------------------- There is such a user, get environment |
|
|
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($target ne 'tex') { |
$r->print('</head>'.&Apache::loncommon::bodytag |
my $title = 'Course Page'; |
("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'})); |
if ($group ne '') { |
|
$title = 'Group Page'; |
|
} |
|
my $start_page = |
|
&Apache::loncommon::start_page($title,undef, |
|
{'function' => $forcestudent, |
|
'domain' => $dom, |
|
'force_register' => |
|
$env{'form.register'},}); |
|
$r->print($start_page); |
} |
} |
|
|
my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'}); |
if ($group ne '') { |
|
if (($grp_view_permission) || |
|
(&Apache::longroup::check_group_access($caller))) { |
|
if ((!&Apache::lonnet::allowed('vgh', |
|
$env{'request.course.id'}.'/'.$marker)) |
|
&& (!&Apache::lonnet::allowed('mdg', |
|
$env{'request.course.id'}.'/'.$marker))) { |
|
if ($env{'form.ref'} eq 'grouplist') { |
|
my $gpterm = &Apache::loncommon::group_term(); |
|
my $ucgpterm = $gpterm; |
|
$ucgpterm =~ s/^(\w)/uc($1)/e; |
|
$r->print(&grouppage_breadcrumbs($dom,$crs,$group,$gpterm, |
|
$ucgpterm,$grp_desc)); |
|
} |
|
&display_group_links($r,$target,$marker,'view',%groupinfo); |
|
return OK; |
|
} |
|
} else { |
|
my $msg = |
|
&mt('You do not currently have rights to view this group.'); |
|
if ($target ne 'tex') { |
|
$r->print("<p>$msg</p>". |
|
&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print('\textbf{'.$msg.'}\end{document}'); |
|
} |
|
return OK; |
|
} |
|
} |
|
|
|
my $allowed; |
|
if ($group ne '') { |
|
$allowed = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); |
|
if (!$allowed) { |
|
$allowed = &Apache::lonnet::allowed('mgh',$env{'request.course.id'}. |
|
'/'.$marker); |
|
} |
|
} else { |
|
$allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
|
} |
my $privileged=$allowed; |
my $privileged=$allowed; |
if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) { |
if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) { |
$forcestudent='student'; |
$forcestudent='student'; |
} |
} |
|
|
if ($forcestudent) { $allowed=0; } |
if ($forcestudent or $target eq 'tex') { $allowed=0; } |
|
|
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($allowed) { |
if ($allowed) { |
$r->print('<p>'. |
$r->print('<p>'. |
&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'. |
&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'. |
&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>'); |
&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>'); |
} elsif ($privileged and $target ne 'tex') { |
} elsif ($privileged) { |
$r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>'); |
$r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>'); |
} |
} |
if (($env{'form.uploaddoc.filename'} and $target ne 'tex') && |
} |
($env{'form.storeupl'}) && ($allowed)) { |
if (($ENV{'form.uploaddoc.filename'}) && |
if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { |
($ENV{'form.storeupl'}) && ($allowed)) { |
if ($syllabus{'uploaded.photourl'}) { |
if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { |
&Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); |
if ($syllabus{'uploaded.photourl'}) { |
} |
&Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); |
if ($caller eq 'grppage') { |
} |
$syllabus{'uploaded.photourl'}=&Apache::lonnet::userfileupload( |
$syllabus{'uploaded.photourl'}= |
'uploaddoc',1,"grouppage/$marker"); |
&Apache::lonnet::userfileupload('uploaddoc',1,'simplepage'); |
} else { |
} |
$syllabus{'uploaded.photourl'}= |
$syllabus{'uploaded.lastmodified'}=time; |
&Apache::lonnet::userfileupload('uploaddoc',1,'simplepage'); |
&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); |
} |
} |
} |
if (($allowed) && ($ENV{'form.storesyl'})) { |
$syllabus{'uploaded.lastmodified'}=time; |
foreach (keys %syllabusfields) { |
&Apache::lonnet::put($namespace,\%syllabus,$dom,$crs); |
my $field=$ENV{'form.'.$_}; |
} |
$field=~s/\s+$//s; |
if (($allowed) && ($env{'form.storesyl'})) { |
$field=&Apache::lonfeedback::clear_out_html($field,1); |
foreach (keys %syllabusfields) { |
$syllabus{$_}=$field; |
my $field=$env{'form.'.$_}; |
} |
chomp($field); |
$syllabus{'uploaded.lastmodified'}=time; |
$field=~s/\s+$//s; |
&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); |
$field=~s/^\s+//s; |
} |
$field=~s/\<br\s*\/*\>$//s; |
|
$field=&Apache::lonfeedback::clear_out_html($field,1); |
|
$syllabus{$_}=$field; |
|
} |
|
$syllabus{'uploaded.lastmodified'}=time; |
|
&Apache::lonnet::put($namespace,\%syllabus,$dom,$crs); |
|
} |
|
|
# ---------------------------------------------------------------- Get syllabus |
# ---------------------------------------------------------------- Get syllabus |
if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) { |
if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) { |
if ($syllabus{'uploaded.photourl'}) { |
if ($syllabus{'uploaded.photourl'}) { |
if ($ENV{'form.grade_target'} ne 'tex') { |
&Apache::lonnet::allowuploaded('/adm/'.$caller, |
&Apache::lonnet::allowuploaded('/adm/smppg', |
$syllabus{'uploaded.photourl'}); |
$syllabus{'uploaded.photourl'}); |
|
$r->print('<img src="'.$syllabus{'uploaded.photourl'}. |
my $image='<img src="'.$syllabus{'uploaded.photourl'}.'" |
'" align="right" />'); |
align="right" />'; |
} |
if ($target eq 'tex') { |
} |
$image=&Apache::lonxml::xmlparse($r,'tex',$image); |
if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) { |
} |
$r->print( |
$r->print($image); |
'<form method="post" enctype="multipart/form-data">'. |
} |
'<input type="hidden" name="forceedit" value="edit" />'. |
if ($allowed) { |
'<h3>Upload a Photo</h3>'. |
$r->print( |
'<input type="file" name="uploaddoc" size="50">'. |
'<form method="post" enctype="multipart/form-data">'. |
'<input type="submit" name="storeupl" value="Upload">'. |
'<input type="hidden" name="forceedit" value="edit" />'. |
'</form><form method="post">'); |
'<h3>Upload a Photo</h3>'. |
} |
'<input type="file" name="uploaddoc" size="50">'. |
foreach (sort keys %syllabusfields) { |
'<input type="submit" name="storeupl" value="Upload">'. |
if (($syllabus{$_}) || ($allowed)) { |
'</form><form method="post">'); |
my $message=$syllabus{$_}; |
} |
$message=~s/\n/\<br \/\>/g; |
foreach (sort keys %syllabusfields) { |
$message |
if (($syllabus{$_}) || ($allowed)) { |
=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g; |
my $message=$syllabus{$_}; |
$message=&Apache::lontexconvert::msgtexconverted($message); |
&Apache::lonfeedback::newline_to_br(\$message); |
unless ($_ eq 'aaa_title') { |
$message |
if (($_ ne 'bbb_content') || ($allowed)) { |
=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g; |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($allowed) { |
$r->print('<h3>'.$syllabusfields{$_}.'</h3>'); |
$message=&Apache::lonspeller::markeduptext($message); |
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>')); |
|
} |
|
} |
|
if ($ENV{'form.grade_target'} ne 'tex') { |
|
$r->print('<blockquote>'. |
|
$message.'</blockquote>'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex',$message)); |
|
} |
|
if ($allowed) { |
|
if ($ENV{'form.grade_target'} ne 'tex') { |
|
$r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'. |
|
$syllabus{$_}. |
|
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
|
} |
|
} |
|
} else { |
|
if ($ENV{'form.grade_target'} ne 'tex') { |
|
$r->print('<h1>'.$message.'</h1>'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>')); |
|
} |
} |
if ($allowed) { |
$message=&Apache::lontexconvert::msgtexconverted($message); |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($_ eq 'abb_links' && $group ne '') { |
$r->print( |
$r->print('<br /><input type="hidden" name="'.$_. |
'<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'. |
'" value="'.$syllabus{$_}.'" />'); |
$syllabus{$_}. |
&display_group_links($r,$target,$marker,'edit',%groupinfo); |
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
$r->print('<br />'); |
|
} elsif ($_ eq 'aaa_title') { |
|
if ($target ne 'tex') { |
|
$r->print('<h1>'.$message.'</h1>'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>')); |
|
} |
|
if ($allowed) { |
|
if ($env{'form.grade_target'} ne 'tex') { |
|
$r->print( |
|
'<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'. |
|
$syllabus{$_}. |
|
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
|
} |
|
} |
|
} else { |
|
if (($_ ne 'bbb_content') || ($allowed)) { |
|
if ($target ne 'tex') { |
|
$r->print('<h3>'.$syllabusfields{$_}.'</h3>'); |
|
} else { |
|
my $safeinit; |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>')); |
|
} |
|
} |
|
if ($target ne 'tex') { |
|
$r->print('<blockquote>'. |
|
$message.'</blockquote>'); |
} else { |
} else { |
my $safeinit; |
my $safeinit; |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$message)); |
} |
} |
} |
if ($allowed) { |
} |
if ($target ne 'tex') { |
} |
$r->print('<br /><textarea cols="80" rows="24" name="'.$_.'" id="'.$_.'">'. |
} |
$syllabus{$_}. |
if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) { |
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
$r->print('</form>'); |
} else { |
} |
my $safeinit; |
if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');} |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($allowed && ($env{'form.grade_target'} ne 'tex')) { |
|
$r->print(&Apache::lonhtmlcommon::htmlareaselectactive |
|
('bbb_content').'</form>'); |
|
} |
|
if ($env{'form.grade_target'} ne 'tex') {$r->print('</p>');} |
} else { |
} else { |
$r->print('<p>No page information provided.</p>'); |
$r->print('<p>No page information provided.</p>'); |
} |
} |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($env{'form.grade_target'} ne 'tex') { |
$r->print('</body></html>'); |
$r->print(&Apache::loncommon::end_page()); |
} else { |
} else { |
$r->print('\end{document}'); |
$r->print('\end{document}'); |
} |
} |
return OK; |
return OK; |
} |
} |
|
|
|
sub display_group_links { |
|
my ($r,$target,$marker,$context,%groupinfo) = @_; |
|
my $refarg; |
|
if ($env{'form.ref'} eq 'grouplist') { |
|
$refarg = '&ref=grouplist'; |
|
} |
|
my @available = (); |
|
my %menu = (); |
|
%{$menu{'email'}} = ( |
|
text => 'Group e-mail', |
|
href => '/adm/email?compose=group&group='.$marker. |
|
$refarg, |
|
); |
|
%{$menu{'discussion'}} = ( |
|
text => 'Discussion Boards', |
|
href => '/adm/groupboards?group='.$marker.$refarg, |
|
); |
|
%{$menu{'chat'}} = ( |
|
text => 'Group chat', |
|
href => "javascript:group_chat('$marker')", |
|
); |
|
%{$menu{'files'}} = ( |
|
text => 'File repository', |
|
href => '/adm/coursegrp_portfolio?group='.$marker.$refarg, |
|
); |
|
%{$menu{'roster'}} = ( |
|
text => 'Membership roster', |
|
href => '/adm/grouproster?group='.$marker.$refarg, |
|
); |
|
foreach my $tool (sort(keys(%menu))) { |
|
if ($groupinfo{functions}{$tool} eq 'on') { |
|
push(@available,$tool); |
|
} |
|
} |
|
if (@available > 0) { |
|
my $output = '<table cellspacing="4" cellpadding="4"><tr>'; |
|
foreach my $tool (@available) { |
|
if ($target eq 'tex') { |
|
$output .= '<td>'.$menu{$tool}{text}.'</td>'; |
|
} else { |
|
$output .= '<td><a href="'.$menu{$tool}{href}.'">'. |
|
$menu{$tool}{text}.'</a></td>'; |
|
} |
|
} |
|
$output .= '</tr></table>'; |
|
if ($target eq 'tex') { |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex','Available functions<br /><br />'.$output)); |
|
} else { |
|
$r->print('<h3>Functions</h3>'.$output); |
|
} |
|
} else { |
|
my $output; |
|
if ($context eq 'edit') { |
|
$output = 'No group functionality'; |
|
} else { |
|
$output = 'No group functionality (e.g., e-mail, discussion, chat or file upload) is currently available to you in this group: '.$marker; |
|
} |
|
if ($target eq 'tex') { |
|
$r->print(&Apache::lonxml::xmlparse($r,'tex',$output)); |
|
} else { |
|
$r->print($output); |
|
} |
|
} |
|
} |
|
|
|
sub grouppage_breadcrumbs { |
|
my ($cdom,$cnum,$group,$gpterm,$ucgpterm,$description) = @_; |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"/adm/coursegroups", |
|
text=>"$ucgpterm".'s', |
|
title=>"Display $ucgpterm".'s'}, |
|
{href=>"/adm/$cdom/$cnum/$group/smppg?ref=grouplist", |
|
text=>"$ucgpterm: $description", |
|
title=>"Go to group's home page"}, |
|
); |
|
my $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] page - [_2]',$gpterm,$description)); |
|
return $output; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |