version 1.24, 2003/09/16 15:41:16
|
version 1.31.2.1, 2004/02/24 21:03:09
|
Line 62 use Apache::assesscalc();
|
Line 62 use Apache::assesscalc();
|
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
|
use Apache::lonlocal; |
|
use Apache::loncoursedata(); |
use HTML::Entities(); |
use HTML::Entities(); |
|
|
## |
## |
Line 70 use HTML::Entities();
|
Line 72 use HTML::Entities();
|
|
|
sub textfield { |
sub textfield { |
my ($title,$name,$value)=@_; |
my ($title,$name,$value)=@_; |
return "\n<p><b>$title:</b><br>". |
return "\n<p><b>$title:</b><br />". |
'<input type=text name="'.$name.'" size=80 value="'.$value.'">'; |
'<input type=text name="'.$name.'" size=80 value="'.$value.'" />'; |
} |
} |
|
|
sub hiddenfield { |
sub hiddenfield { |
Line 81 sub hiddenfield {
|
Line 83 sub hiddenfield {
|
|
|
sub selectbox { |
sub selectbox { |
my ($title,$name,$value,%options)=@_; |
my ($title,$name,$value,%options)=@_; |
my $selout="\n<p><b>$title:</b><br>".'<select name="'.$name.'">'; |
my $selout="\n<p><b>$title:</b><br />".'<select name="'.$name.'">'; |
foreach (sort keys(%options)) { |
foreach (sort keys(%options)) { |
$selout.='<option value="'.$_.'"'; |
$selout.='<option value="'.$_.'"'; |
if ($_ eq $value) { $selout.=' selected'; } |
if ($_ eq $value) { $selout.=' selected'; } |
$selout.='>'.$options{$_}.'</option>'; |
$selout.='>'.&mt($options{$_}).'</option>'; |
} |
} |
return $selout.'</select>'; |
return $selout.'</select>'; |
} |
} |
Line 120 sub file_dialogs {
|
Line 122 sub file_dialogs {
|
$result .=&hiddenfield('workcopy',$sheettype); |
$result .=&hiddenfield('workcopy',$sheettype); |
if ($ENV{'form.newformula'} !~ /^\s*$/) { |
if ($ENV{'form.newformula'} !~ /^\s*$/) { |
$message .='<table><tr>'. |
$message .='<table><tr>'. |
'<td valign="top"><pre>Cell '.$ENV{'form.cell'}.' = </pre></td>'. |
'<td valign="top"><pre>'.&mt('Cell').' '.$ENV{'form.cell'}.' = </pre></td>'. |
'<td><pre>'.$ENV{'form.newformula'}."</pre></td></tr></table>\n"; |
'<td><pre>'.$ENV{'form.newformula'}."</pre></td></tr></table>\n"; |
} else { |
} else { |
$message .= 'Deleted contents of cell '.$ENV{'form.cell'}.'.'; |
$message .= &mt('Deleted contents of cell').' '.$ENV{'form.cell'}.'.'; |
} |
} |
} |
} |
## |
## |
Line 138 sub file_dialogs {
|
Line 140 sub file_dialogs {
|
$filename = 'Default'; |
$filename = 'Default'; |
} |
} |
my $save_dialog = '<nobr>'. |
my $save_dialog = '<nobr>'. |
'<input type="submit" name="save" value="Save as" /> '. |
'<input type="submit" name="save" value="'.&mt('Save as').'" /> '. |
'<input type="text" name="savefilename" size="30" value="'. |
'<input type="text" name="savefilename" size="30" value="'. |
$truefilename.'" />'. |
$truefilename.'" />'. |
'</nobr>'; |
'</nobr>'; |
my $makedefault_dialog = '<input type="submit" name="makedefault" '. |
my $makedefault_dialog = '<input type="submit" name="makedefault" '. |
'value="Save as & Make This Sheet the Default"/>'; |
'value="'.&mt('Save as & Make This Sheet the Default').'"/>'; |
# |
# |
my $link = '<a href="javascript:openbrowser'. |
my $link = '<a href="javascript:openbrowser'. |
"('sheet','loadfilename','spreadsheet')\">Select Spreadsheet File</a>"; |
"('sheet','loadfilename','spreadsheet')\">".&mt('Select Spreadsheet File')."</a>"; |
|
my $load=&mt('Load:'); |
my $load_dialog = <<END; |
my $load_dialog = <<END; |
<table bgcolor="$bgcolor"> |
<table bgcolor="$bgcolor"> |
<tr><td><input type="submit" name="load" value="Load" /></td> |
<tr><td><input type="submit" name="load" value="$load" /></td> |
<td><nobr> |
<td><nobr> |
<input type="text" name="loadfilename" size="20" value="$filename" /> |
<input type="text" name="loadfilename" size="20" value="$filename" /> |
$link</nobr> |
$link</nobr> |
Line 159 sub file_dialogs {
|
Line 162 sub file_dialogs {
|
END |
END |
my $default_filename_set = 0; |
my $default_filename_set = 0; |
foreach my $sheetfilename ($spreadsheet->othersheets()) { |
foreach my $sheetfilename ($spreadsheet->othersheets()) { |
$load_dialog .= ' <option name="'.$sheetfilename.'"'; |
$load_dialog .= ' <option value="'.$sheetfilename.'"'; |
if ($filename eq $sheetfilename) { |
if ($filename eq $sheetfilename) { |
$load_dialog .= ' selected'; |
$load_dialog .= ' selected'; |
$default_filename_set = 1; |
$default_filename_set = 1; |
Line 208 sub handler {
|
Line 211 sub handler {
|
# HTML Header |
# HTML Header |
# |
# |
if ($r->header_only) { |
if ($r->header_only) { |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
Line 224 sub handler {
|
Line 227 sub handler {
|
} |
} |
my $courseid = $ENV{'request.course.id'}; |
my $courseid = $ENV{'request.course.id'}; |
# |
# |
# Do not allow students to continue if standard grading is in effect. |
# Do not allow students to continue if standard or external grading is in |
|
# effect. |
|
# |
if ($ENV{'request.role'} =~ /^st\./) { |
if ($ENV{'request.role'} =~ /^st\./) { |
if ($ENV{'course.'.$courseid.'.grading'} eq 'standard') { |
if ($ENV{'course.'.$courseid.'.grading'} eq 'standard' || |
|
$ENV{'course.'.$courseid.'.grading'} eq 'external' ) { |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
} |
} |
Line 250 sub handler {
|
Line 256 sub handler {
|
$symb = $ENV{'form.usymb'} if (exists($ENV{'form.usymb'})); |
$symb = $ENV{'form.usymb'} if (exists($ENV{'form.usymb'})); |
my $name = $ENV{'user.name'}; |
my $name = $ENV{'user.name'}; |
my $domain = $ENV{'user.domain'}; |
my $domain = $ENV{'user.domain'}; |
if (exists($ENV{'form.sname'})) { |
if (exists($ENV{'form.sname'}) && $ENV{'form.sname'} ne '') { |
$name = $ENV{'form.sname'}; |
$name = $ENV{'form.sname'}; |
$domain = $ENV{'form.sdomain'}; |
$domain = $ENV{'form.sdomain'}; |
} |
} |
|
$ENV{'form.sname'} = $name; |
|
$ENV{'form.sdomain'} = $domain; |
## |
## |
## Check permissions |
## Check permissions |
my $allowed_to_edit = &Apache::lonnet::allowed('mgr', |
my $allowed_to_edit = &Apache::lonnet::allowed('mgr', |
Line 297 sub handler {
|
Line 305 sub handler {
|
# |
# |
# Open page, try to prevent browser cache. |
# Open page, try to prevent browser cache. |
# |
# |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
|
|
Line 310 sub handler {
|
Line 318 sub handler {
|
## Spit out the javascript required for editing |
## Spit out the javascript required for editing |
## |
## |
if ($allowed_to_edit) { |
if ($allowed_to_edit) { |
|
my %lt=( |
|
'ce' => 'Cell', |
|
'ac' => 'Accept', |
|
'dc' => 'Discard Changes' |
|
); |
my $extra_javascript = |
my $extra_javascript = |
&Apache::loncommon::browser_and_searcher_javascript(); |
&Apache::loncommon::browser_and_searcher_javascript(); |
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script language="JavaScript"> |
<script type="text/javascript"> |
|
//<!-- |
$extra_javascript |
$extra_javascript |
|
|
var editwin; |
var editwin; |
Line 325 sub handler {
|
Line 338 sub handler {
|
// we need to escape them? |
// we need to escape them? |
edit_text +='<html><head><title>Cell Edit Window</title></head><body>'; |
edit_text +='<html><head><title>Cell Edit Window</title></head><body>'; |
edit_text += '<form name="editwinform">'; |
edit_text += '<form name="editwinform">'; |
edit_text += '<center><h3>Cell '+cellname+'</h3>'; |
edit_text += '<center><h3>$lt{'ce'} '+cellname+'</h3>'; |
edit_text += '<textarea name="newformula" cols="60" rows="12"'; |
edit_text += '<textarea name="newformula" cols="60" rows="12"'; |
edit_text += ' wrap="off" >'+cellformula+'</textarea>'; |
edit_text += ' wrap="off" >'+cellformula+'</textarea>'; |
edit_text += '</br>'; |
edit_text += '</br>'; |
edit_text += '<input type="button" name="accept" value="Accept"'; |
edit_text += '<input type="button" name="accept" value="$lt{'ac'}"'; |
edit_text += ' onClick=\\\'javascript:'; |
edit_text += ' onClick=\\\'javascript:'; |
edit_text += 'opener.document.sheet.cell.value='; |
edit_text += 'opener.document.sheet.cell.value='; |
edit_text += '"'+cellname+'";'; |
edit_text += '"'+cellname+'";'; |
Line 339 sub handler {
|
Line 352 sub handler {
|
edit_text += 'self.close()\\\' />'; |
edit_text += 'self.close()\\\' />'; |
edit_text += ' '; |
edit_text += ' '; |
edit_text += '<input type="button" name="abort" '; |
edit_text += '<input type="button" name="abort" '; |
edit_text += 'value="Discard Changes"'; |
edit_text += 'value="$lt{'dc'}"'; |
edit_text += ' onClick="javascript:self.close()" />'; |
edit_text += ' onClick="javascript:self.close()" />'; |
edit_text += '</center></body></html>'; |
edit_text += '</center></body></html>'; |
|
|
Line 347 sub handler {
|
Line 360 sub handler {
|
editwin.close(); |
editwin.close(); |
} |
} |
|
|
editwin = window.open($nothing,'CellEditWin','height=280,width=480,scrollbars=no,resizeable=yes,alwaysRaised=yes,dependent=yes',true); |
editwin = window.open($nothing,'CellEditWin','height=280,width=480,scrollbars=no,resizable=yes,alwaysRaised=yes,dependent=yes',true); |
editwin.document.write(edit_text); |
editwin.document.write(edit_text); |
} |
} |
|
//--> |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
} |
} |
Line 373 ENDSCRIPT
|
Line 387 ENDSCRIPT
|
## |
## |
## Take care of "backdoor" spreadsheet expiration / recalc stuff |
## Take care of "backdoor" spreadsheet expiration / recalc stuff |
if ($allowed_to_edit && exists($ENV{'form.recalc'})) { |
if ($allowed_to_edit && exists($ENV{'form.recalc'})) { |
|
if (exists($ENV{'form.recalc'})) { |
|
&Apache::loncoursedata::delete_caches($ENV{'requres.course.id'}); |
|
} |
if ($ENV{'form.recalc'} eq 'ilovewastingtime') { |
if ($ENV{'form.recalc'} eq 'ilovewastingtime') { |
&Apache::lonnet::logthis('ilovewastingtime'); |
&Apache::lonnet::logthis('ilovewastingtime'); |
# expire ALL spreadsheets |
# expire ALL spreadsheets |
Line 425 ENDSCRIPT
|
Line 442 ENDSCRIPT
|
if ($action_message) { |
if ($action_message) { |
$action_message .= '<br />'; |
$action_message .= '<br />'; |
} |
} |
$action_message .= 'Made this spreadsheet the default'; |
$action_message .= &mt('Made this spreadsheet the default'); |
if ($sheettype eq 'classcalc') { |
if ($sheettype eq 'classcalc') { |
$action_message .= ' for the course'; |
$action_message .= ' '.&mt('for the course'); |
} elsif ($sheettype eq 'studentcalc') { |
} elsif ($sheettype eq 'studentcalc') { |
$action_message .= ' for all students'; |
$action_message .= ' '.&mt('for all students'); |
} elsif ($sheettype eq 'assesscalc') { |
} elsif ($sheettype eq 'assesscalc') { |
$action_message .= ' for all assessments'; |
$action_message .= ' '.&mt('for all assessments'); |
} |
} |
$action_message .= '.'; |
$action_message .= '.'; |
} |
} |
Line 455 END
|
Line 472 END
|
$r->rflush(); |
$r->rflush(); |
# |
# |
$r->print("<table><tr>"); |
$r->print("<table><tr>"); |
if ($sheettype eq 'classcalc') { |
$r->print('<td><input type="submit" value="'. |
$r->print('<td><input type="submit" value="Generate Spreadsheet" />'. |
&mt('Generate Spreadsheet').'" />'. |
'</td>'); |
'</td>'); |
} |
|
if ($allowed_to_view) { |
if ($allowed_to_view) { |
$r->print('<td>'. |
$r->print('<td>'. |
&Apache::loncommon::help_open_topic("Spreadsheet_About", |
&Apache::loncommon::help_open_topic("Spreadsheet_About", |