version 1.17, 2004/04/30 23:13:52
|
version 1.18, 2004/05/11 18:43:21
|
Line 43 sub handler {
|
Line 43 sub handler {
|
$r->content_type('text/html'); |
$r->content_type('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 ne 'tex') { |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<html> |
<html> |
<head> |
<head> |
Line 57 ENDDOCUMENT
|
Line 57 ENDDOCUMENT
|
my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri); |
my (undef,undef,undef,undef,$marker)=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>'); |
$r->print('</head><body>Not in a course</body></html>'); |
return OK; |
return OK; |
} else { |
} else { |
Line 94 ENDDOCUMENT
|
Line 94 ENDDOCUMENT
|
} |
} |
# --------------------------------------------------------------- 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'; } |
|
|
Line 103 ENDDOCUMENT
|
Line 103 ENDDOCUMENT
|
|
|
# --------------------------------------- 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 |
$r->print('</head>'.&Apache::loncommon::bodytag |
("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'})); |
("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'})); |
} |
} |
Line 114 ENDDOCUMENT
|
Line 114 ENDDOCUMENT
|
$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'}); |
$syllabus{'uploaded.photourl'}= |
} |
&Apache::lonnet::userfileupload('uploaddoc',1,'simplepage'); |
$syllabus{'uploaded.photourl'}= |
} |
&Apache::lonnet::userfileupload('uploaddoc',1,'simplepage'); |
$syllabus{'uploaded.lastmodified'}=time; |
} |
&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); |
$syllabus{'uploaded.lastmodified'}=time; |
} |
&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); |
if (($allowed) && ($ENV{'form.storesyl'})) { |
} |
foreach (keys %syllabusfields) { |
if (($allowed) && ($ENV{'form.storesyl'})) { |
my $field=$ENV{'form.'.$_}; |
foreach (keys %syllabusfields) { |
$field=~s/\s+$//s; |
my $field=$ENV{'form.'.$_}; |
$field=&Apache::lonfeedback::clear_out_html($field,1); |
$field=~s/\s+$//s; |
$syllabus{$_}=$field; |
$field=&Apache::lonfeedback::clear_out_html($field,1); |
} |
$syllabus{$_}=$field; |
$syllabus{'uploaded.lastmodified'}=time; |
} |
&Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); |
$syllabus{'uploaded.lastmodified'}=time; |
} |
&Apache::lonnet::put('smppage_'.$marker,\%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') { |
if ($target ne 'tex') { |
&Apache::lonnet::allowuploaded('/adm/smppg', |
&Apache::lonnet::allowuploaded('/adm/smppg', |
$syllabus{'uploaded.photourl'}); |
$syllabus{'uploaded.photourl'}); |
$r->print('<img src="'.$syllabus{'uploaded.photourl'}. |
$r->print('<img src="'.$syllabus{'uploaded.photourl'}. |
'" align="right" />'); |
'" align="right" />'); |
} |
} else { |
} |
&Apache::lonnet::allowuploaded('/adm/smppg', |
if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) { |
$syllabus{'uploaded.photourl'}); |
$r->print( |
$r->print(&Apache::lonxml::xmlparse($r,'tex','<img src="'.$syllabus{'uploaded.photourl'}. |
'<form method="post" enctype="multipart/form-data">'. |
'" align="right" />')); |
'<input type="hidden" name="forceedit" value="edit" />'. |
} |
'<h3>Upload a Photo</h3>'. |
} |
'<input type="file" name="uploaddoc" size="50">'. |
if ($allowed) { |
'<input type="submit" name="storeupl" value="Upload">'. |
$r->print( |
'</form><form method="post">'); |
'<form method="post" enctype="multipart/form-data">'. |
} |
'<input type="hidden" name="forceedit" value="edit" />'. |
foreach (sort keys %syllabusfields) { |
'<h3>Upload a Photo</h3>'. |
if (($syllabus{$_}) || ($allowed)) { |
'<input type="file" name="uploaddoc" size="50">'. |
my $message=$syllabus{$_}; |
'<input type="submit" name="storeupl" value="Upload">'. |
$message=~s/\n/\<br \/\>/g; |
'</form><form method="post">'); |
$message |
} |
=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g; |
foreach (sort keys %syllabusfields) { |
$message=&Apache::lontexconvert::msgtexconverted($message); |
if (($syllabus{$_}) || ($allowed)) { |
unless ($_ eq 'aaa_title') { |
my $message=$syllabus{$_}; |
if (($_ ne 'bbb_content') || ($allowed)) { |
$message=~s/\n/\<br \/\>/g; |
if ($ENV{'form.grade_target'} ne 'tex') { |
$message |
$r->print('<h3>'.$syllabusfields{$_}.'</h3>'); |
=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g; |
} else { |
$message=&Apache::lontexconvert::msgtexconverted($message); |
my $safeinit; |
unless ($_ eq 'aaa_title') { |
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>')); |
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') { |
if ($ENV{'form.grade_target'} ne 'tex') { |
$r->print('<blockquote>'. |
$r->print('<blockquote>'. |
$message.'</blockquote>'); |
$message.'</blockquote>'); |
} else { |
} else { |
|
my $safeinit; |
my $safeinit; |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$message)); |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$message)); |
} |
} |
if ($allowed) { |
if ($allowed) { |
if ($ENV{'form.grade_target'} ne 'tex') { |
if ($target ne 'tex') { |
$r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'. |
$r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'. |
$syllabus{$_}. |
$syllabus{$_}. |
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
'</textarea><input type="submit" name="storesyl" value="Store" />'); |
} else { |
} else { |
my $safeinit; |
my $safeinit; |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit)); |
} |
} |
} |
} |
} else { |
|
if ($ENV{'form.grade_target'} ne 'tex') { |
|
$r->print('<h1>'.$message.'</h1>'); |
|
} else { |
} else { |
my $safeinit; |
if ($target ne 'tex') { |
$r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>')); |
$r->print('<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 { |
} else { |
my $safeinit; |
my $safeinit; |
$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$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)); |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) { |
if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) { |
$r->print('</form>'); |
$r->print('</form>'); |
} |
} |
if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');} |
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('</body></html>'); |