Annotation of loncom/interface/spreadsheet/lonspreadsheet.pm, revision 1.62
1.1 matthew 1: #
1.62 ! bisitz 2: # $Id: lonspreadsheet.pm,v 1.61 2011/09/26 18:17:44 raeburn Exp $
1.1 matthew 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26: # The LearningOnline Network with CAPA
27: # Spreadsheet/Grades Display Handler
28: #
29: # POD required stuff:
30:
31: =head1 NAME
32:
33: lonspreadsheet
34:
35: =head1 SYNOPSIS
36:
37: Spreadsheet interface to internal LON-CAPA data
38:
39: =head1 DESCRIPTION
40:
41: Lonspreadsheet provides course coordinators the ability to manage their
42: students grades online. The students are able to view their own grades, but
43: not the grades of their peers. The spreadsheet is highly customizable,
44: offering the ability to use Perl code to manipulate data, as well as many
45: built-in functions.
46:
47: =head2 Functions available to user of lonspreadsheet
48:
49: =over 4
50:
51: =cut
52:
53:
54: package Apache::lonspreadsheet;
55:
56: use strict;
1.23 matthew 57: use warnings FATAL=>'all';
58: no warnings 'uninitialized';
1.1 matthew 59: use Apache::classcalc();
60: use Apache::studentcalc();
61: use Apache::assesscalc();
62: use Apache::Constants qw(:common :http);
63: use Apache::lonnet;
64: use Apache::lonhtmlcommon;
1.25 www 65: use Apache::lonlocal;
1.26 matthew 66: use Apache::loncoursedata();
1.58 www 67: use Apache::lonquickgrades();
1.1 matthew 68: use HTML::Entities();
69:
70: ##
71: ## HTML utility subroutines really should go in lonhtmlcommon
72: ##
73:
74: sub textfield {
75: my ($title,$name,$value)=@_;
1.28 matthew 76: return "\n<p><b>$title:</b><br />".
1.53 bisitz 77: '<input type="text" name="'.$name.'" size="80" value="'.$value.'" />';
1.1 matthew 78: }
79:
80: sub hiddenfield {
81: my ($name,$value)=@_;
1.53 bisitz 82: return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'."\n";
1.1 matthew 83: }
84:
85: sub selectbox {
86: my ($title,$name,$value,%options)=@_;
1.28 matthew 87: my $selout="\n<p><b>$title:</b><br />".'<select name="'.$name.'">';
1.1 matthew 88: foreach (sort keys(%options)) {
89: $selout.='<option value="'.$_.'"';
1.54 bisitz 90: if ($_ eq $value) { $selout.=' selected="selected"'; }
1.27 www 91: $selout.='>'.&mt($options{$_}).'</option>';
1.1 matthew 92: }
93: return $selout.'</select>';
94: }
95:
1.5 matthew 96: sub file_dialogs {
97: my ($spreadsheet) = @_;
98: my $bgcolor = "#FFFFFF";
99: my $sheettype = $spreadsheet->{'type'};
100: my $result = '';
1.11 matthew 101: my $message = '';
1.5 matthew 102: ##
103: ## Deal with saving the spreadsheet
1.42 albertel 104: $spreadsheet->check_formulas_loaded();
1.40 albertel 105: if ((exists($env{'form.save'}) || exists($env{'form.makedefault'})) &&
106: exists($env{'form.savefilename'})) {
107: $spreadsheet->filename($env{'form.savefilename'});
1.5 matthew 108: my $save_status = $spreadsheet->save();
109: if ($save_status ne 'ok') {
1.60 raeburn 110: $message .= '<span class="LC_error">'.
111: &mt('An error occurred while saving the spreadsheet. The error is: [_1].',
112: $save_status).'</span>';
1.5 matthew 113: } else {
1.60 raeburn 114: $message .= '<span class="LC_info">'.&mt('Spreadsheet saved as: [_1] .',
115: '<span class="LC_filename">'.$spreadsheet->filename().'</span>').
116: '</span>';
1.5 matthew 117: }
1.40 albertel 118: } elsif (exists($env{'form.newformula'}) &&
119: exists($env{'form.cell'}) &&
120: $env{'form.cell'} ne '' ) {
1.5 matthew 121: ##
122: ## Make any requested modifications to the spreadsheet
1.40 albertel 123: $spreadsheet->modify_cell($env{'form.cell'},
124: $env{'form.newformula'});
1.5 matthew 125: $spreadsheet->save_tmp();
126: # output that we are dealing with a temporary file
127: $result .=&hiddenfield('workcopy',$sheettype);
1.40 albertel 128: if ($env{'form.newformula'} !~ /^\s*$/) {
1.11 matthew 129: $message .='<table><tr>'.
1.40 albertel 130: '<td valign="top"><pre>'.&mt('Cell').' '.$env{'form.cell'}.' = </pre></td>'.
131: '<td><pre>'.$env{'form.newformula'}."</pre></td></tr></table>\n";
1.11 matthew 132: } else {
1.40 albertel 133: $message .= &mt('Deleted contents of cell').' '.$env{'form.cell'}.'.';
1.11 matthew 134: }
1.5 matthew 135: }
136: ##
137: ## Editing code
138: $result .=&hiddenfield('cell','').
139: &hiddenfield('newformula','');
140: ##
141: ## Create the save and load dialogs
142: my $filename = $spreadsheet->filename();
1.10 matthew 143: my $truefilename = $filename;
144: if ($spreadsheet->is_default()) {
145: $filename = 'Default';
146: }
1.52 bisitz 147: my $save_dialog = '<span class="LC_nobreak">'.
1.27 www 148: '<input type="submit" name="save" value="'.&mt('Save as').'" /> '.
1.5 matthew 149: '<input type="text" name="savefilename" size="30" value="'.
1.10 matthew 150: $truefilename.'" />'.
1.52 bisitz 151: '</span>';
1.5 matthew 152: my $makedefault_dialog = '<input type="submit" name="makedefault" '.
1.55 bisitz 153: 'value="'.&mt('Save as & Make This Sheet the Default').'"/>';
1.5 matthew 154: #
155: my $link = '<a href="javascript:openbrowser'.
1.27 www 156: "('sheet','loadfilename','spreadsheet')\">".&mt('Select Spreadsheet File')."</a>";
157: my $load=&mt('Load:');
1.5 matthew 158: my $load_dialog = <<END;
159: <table bgcolor="$bgcolor">
1.27 www 160: <tr><td><input type="submit" name="load" value="$load" /></td>
1.52 bisitz 161: <td><span class="LC_nobreak">
1.10 matthew 162: <input type="text" name="loadfilename" size="20" value="$filename" />
1.52 bisitz 163: $link</span>
1.5 matthew 164: </td></tr>
165: <tr><td> </td><td>
166: <select name="fileselect" onchange="document.sheet.loadfilename.value=document.sheet.fileselect.value" >
167: END
1.7 matthew 168: my $default_filename_set = 0;
1.5 matthew 169: foreach my $sheetfilename ($spreadsheet->othersheets()) {
1.28 matthew 170: $load_dialog .= ' <option value="'.$sheetfilename.'"';
1.5 matthew 171: if ($filename eq $sheetfilename) {
1.54 bisitz 172: $load_dialog .= ' selected="selected"';
1.7 matthew 173: $default_filename_set = 1;
1.5 matthew 174: }
175: $load_dialog .= '>'.$sheetfilename."</option>\n";
176: }
1.22 matthew 177: $load_dialog .= "</select>\n</td><td> </td></tr>\n</table>\n";
1.5 matthew 178: #
1.54 bisitz 179: my $headline = &mt('File Dialogs');
1.5 matthew 180: $result .=<<END;
1.23 matthew 181: <!--
182: <fieldset title="File Dialogs" >
1.54 bisitz 183: <legend>$headline</legend>
1.23 matthew 184: -->
1.5 matthew 185: <!-- load / save dialogs -->
186: <table cellspacing="2">
187: <tr>
188: <td>$load_dialog</td>
189: <td>
190: <table bgcolor="$bgcolor">
191: <tr><td>$save_dialog</td></tr>
192: <tr><td align="center">$makedefault_dialog</td></tr>
193: </table>
194: </td>
195: </tr>
196: </table>
1.23 matthew 197: <!--
198: </fieldset>
199: -->
1.5 matthew 200: END
1.11 matthew 201: return ($result,$message);
1.5 matthew 202: }
203:
1.1 matthew 204: sub handler {
205: my $r=shift;
206: #
207: # HTML Header
208: #
209: if ($r->header_only) {
1.25 www 210: &Apache::loncommon::content_type($r,'text/html');
1.1 matthew 211: $r->send_http_header;
212: return OK;
213: }
214: #
215: # Roles Checking
216: #
217: # Needs to be in a course
1.40 albertel 218: if (! $env{'request.course.fn'}) {
1.1 matthew 219: # Not in a course, or not allowed to modify parms
1.40 albertel 220: $env{'user.error.msg'}=
1.1 matthew 221: $r->uri.":opa:0:0:Cannot modify spreadsheet";
222: return HTTP_NOT_ACCEPTABLE;
1.17 matthew 223: }
1.59 raeburn 224: my ($sheettype) = ($r->uri=~/\/(\w+)$/);
1.40 albertel 225: my $courseid = $env{'request.course.id'};
1.59 raeburn 226:
227: ##
228: ## Check permissions
229: my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
230: $env{'request.course.id'});
231: # Only those instructors/tas/whatevers with complete access
232: # (not section restricted) are able to modify spreadsheets.
233: my $allowed_to_view = &Apache::lonnet::allowed('vgr',
234: $env{'request.course.id'});
235: if (! $allowed_to_view) {
236: $allowed_to_view = &Apache::lonnet::allowed('vgr',
237: $env{'request.course.id'}.'/'.$env{'request.course.sec'});
238: # Those who are restricted by section are allowed to view.
239: # The routines in lonstatistics which decide which students'
240: # will be shown take care of the restriction by section.
241: }
242:
1.17 matthew 243: #
1.59 raeburn 244: # Do not allow users without vgr or mgr priv to continue unless
245: # grading type is set to spreadsheet.
1.30 albertel 246: #
1.59 raeburn 247:
248: if ((!$allowed_to_view) && (!$allowed_to_edit)) {
249: if ($env{'course.'.$courseid.'.grading'} eq 'spreadsheet') {
250: if ($sheettype ne 'studentcalc') {
251: $r->internal_redirect('/adm/studentcalc');
252: return OK;
253: }
254: } else {
255: $r->internal_redirect('/adm/quickgrades');
256: return OK;
1.17 matthew 257: }
1.1 matthew 258: }
259: #
260: # Get query string for limited number of parameters
261: #
262: &Apache::loncommon::get_unprocessed_cgi
1.37 matthew 263: ($ENV{'QUERY_STRING'},['sname','sdomain','usymb','filename','recalc',
264: 'output_format','not_first_run']);
1.1 matthew 265: #
266: # Deal with restricted student permissions
267: #
1.40 albertel 268: if ($env{'request.role'} =~ /^st\./) {
269: delete $env{'form.cell'} if (exists($env{'form.cell'}));
270: delete $env{'form.newformula'} if (exists($env{'form.newformula'}));
1.1 matthew 271: }
272: #
273: # Determine basic information about the spreadsheet
274: #
275: my $symb = undef;
1.40 albertel 276: $symb = $env{'form.usymb'} if (exists($env{'form.usymb'}));
277: my $name = $env{'user.name'};
278: my $domain = $env{'user.domain'};
1.61 raeburn 279: my $warning;
1.40 albertel 280: if (exists($env{'form.sname'}) && $env{'form.sname'} ne '') {
1.61 raeburn 281: if (($env{'form.sname'} ne $env{'user.name'}) ||
282: ($env{'form.sdomain'} ne $env{'user.domain'})) {
283: if (($allowed_to_view) || ($allowed_to_edit)) {
284: if (&Apache::lonnet::homeserver($env{'form.sname'},$env{'form.sdomain'}) ne 'no_host') {
285: $name = $env{'form.sname'};
286: $domain = $env{'form.sdomain'};
287: } else {
288: $warning = &mt('Requested user: "[_1]" does not exist; your own sheet is displayed instead.',$env{'form.sname'}.':'.$env{'form.sdomain'});
289: }
290: } else {
291: $warning = &mt('Your current role is not permitted to display this sheet for the requested user: "[_1]"; your own sheet is displayed instead.',$env{'form.sname'}.':'.$env{'form.sdomain'});
292: }
293: }
1.1 matthew 294: }
1.40 albertel 295: $env{'form.sname'} = $name;
296: $env{'form.sdomain'} = $domain;
1.43 albertel 297: my $section = &Apache::lonnet::getsection($domain,$name,
298: $env{'request.course.id'});
1.47 raeburn 299: my @groups;
1.44 raeburn 300: if (($env{'user.name'} eq $name) && ($env{'user.domain'} eq $domain)) {
1.47 raeburn 301: @groups = &Apache::lonnet::sort_course_groups($env{'request.course.id'},
302: split(':',$env{'request.course.groups'}));
1.44 raeburn 303: } else {
1.47 raeburn 304: @groups = &Apache::lonnet::get_users_groups($domain,$name,
1.44 raeburn 305: $env{'request.course.id'});
306: }
307:
1.1 matthew 308: #
1.3 matthew 309: # Only those able to view others grades will be allowed to continue
310: # if they are not requesting their own.
1.12 matthew 311: if ($sheettype eq 'classcalc') {
1.59 raeburn 312: if (!$allowed_to_view) {
313: $r->internal_redirect('/adm/studentcalc');
314: return OK;
1.14 www 315: }
1.1 matthew 316: }
1.40 albertel 317: if ((($name ne $env{'user.name'} ) ||
318: ($domain ne $env{'user.domain'})) && $sheettype ne 'classcalc') {
1.12 matthew 319: # Check that the student is in their section?
1.40 albertel 320: if (exists($env{'request.course.sec'}) &&
321: $env{'request.course.sec'} ne '' ) {
1.39 albertel 322: my $stu_sec = &Apache::lonnet::getsection($domain,$name,
1.40 albertel 323: $env{'request.course.id'});
324: if ($stu_sec ne $env{'request.course.sec'}) {
325: $env{'user.error.msg'}=
1.14 www 326: $r->uri.":vgr:0:0:Requested student not in your section.";
327: return HTTP_NOT_ACCEPTABLE;
1.12 matthew 328: }
329: }
330: }
1.14 www 331:
332: #
333: # Open page, try to prevent browser cache.
334: #
1.25 www 335: &Apache::loncommon::content_type($r,'text/html');
1.15 matthew 336: &Apache::loncommon::no_cache($r);
1.14 www 337: $r->send_http_header;
1.12 matthew 338:
1.1 matthew 339: #
340: # Header....
341: #
342: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
343: ##
344: ## Spit out the javascript required for editing
345: ##
1.45 albertel 346: my $js;
1.5 matthew 347: if ($allowed_to_edit) {
1.27 www 348: my %lt=(
349: 'ce' => 'Cell',
350: 'ac' => 'Accept',
351: 'dc' => 'Discard Changes'
352: );
1.5 matthew 353: my $extra_javascript =
354: &Apache::loncommon::browser_and_searcher_javascript();
1.45 albertel 355:
1.51 albertel 356: my $cell_extra_js = &Apache::loncommon::resize_textarea_js();
1.45 albertel 357: my $cell_edit_start =
1.51 albertel 358: &Apache::loncommon::start_page('Cell Edit Window',$cell_extra_js,
1.45 albertel 359: {'only_body' => 1,
1.51 albertel 360: 'js_ready' => 1,
361: 'add_entries' => {
362: 'onresize' => "resize_textarea('LC_newformula','LC_aftertextarea')",
363: 'onload' => "resize_textarea('LC_newformula','LC_aftertextarea')",
364: }});
1.45 albertel 365: my $cell_edit_end =
366: &Apache::loncommon::end_page({'js_ready' => 1,});
367:
368: $js = <<ENDSCRIPT;
1.28 matthew 369: <script type="text/javascript">
370: //<!--
1.5 matthew 371: $extra_javascript
372:
1.1 matthew 373: var editwin;
374:
375: function celledit(cellname,cellformula) {
376: var edit_text = '';
377: // cellformula may contain less-than and greater-than symbols, so
378: // we need to escape them?
1.45 albertel 379: edit_text +='$cell_edit_start';
1.1 matthew 380: edit_text += '<form name="editwinform">';
1.27 www 381: edit_text += '<center><h3>$lt{'ce'} '+cellname+'</h3>';
1.51 albertel 382: edit_text += '<textarea id="LC_newformula" name="newformula" ';
383: edit_text += ' cols="60" rows="12"; wrap="off" style="width:100%">';
384: edit_text += cellformula+'</textarea>';
385: edit_text += '<div id="LC_aftertextarea"><br />';
1.27 www 386: edit_text += '<input type="button" name="accept" value="$lt{'ac'}"';
1.1 matthew 387: edit_text += ' onClick=\\\'javascript:';
388: edit_text += 'opener.document.sheet.cell.value=';
389: edit_text += '"'+cellname+'";';
390: edit_text += 'opener.document.sheet.newformula.value=';
391: edit_text += 'document.editwinform.newformula.value;';
392: edit_text += 'opener.document.sheet.submit();';
393: edit_text += 'self.close()\\\' />';
394: edit_text += ' ';
395: edit_text += '<input type="button" name="abort" ';
1.27 www 396: edit_text += 'value="$lt{'dc'}"';
1.1 matthew 397: edit_text += ' onClick="javascript:self.close()" />';
1.51 albertel 398: edit_text += '</center></div></form>$cell_edit_end';
1.1 matthew 399:
400: if (editwin != null && !(editwin.closed) ) {
401: editwin.close();
402: }
403:
1.29 albertel 404: editwin = window.open($nothing,'CellEditWin','height=280,width=480,scrollbars=no,resizable=yes,alwaysRaised=yes,dependent=yes',true);
1.1 matthew 405: editwin.document.write(edit_text);
1.50 raeburn 406: editwin.document.close();
1.1 matthew 407: }
1.28 matthew 408: //-->
1.1 matthew 409: </script>
410: ENDSCRIPT
411: }
1.33 matthew 412: &Apache::lonhtmlcommon::clear_breadcrumbs();
413: &Apache::lonhtmlcommon::add_breadcrumb
414: ({href => $r->uri,
1.36 matthew 415: title => 'Spreadsheet',
416: text => 'Spreadsheet',
1.33 matthew 417: faq => 134,
418: bug => 'Spreadsheet'});
1.45 albertel 419: $r->print(&Apache::loncommon::start_page('Grades Spreadsheet',$js).
1.49 albertel 420: &Apache::lonhtmlcommon::breadcrumbs('Spreadsheet',
1.58 www 421: 'Spreadsheet_About'));
422:
423: #
424: # Tabs
425: #
426: &Apache::lonquickgrades::startGradeScreen($r,'spreadsheet');
427:
428: #
429: # Open the form
430: #
1.61 raeburn 431: if ($warning) {
432: $r->print('<p class="LC_info">'.$warning.'</p>');
433: }
1.58 www 434: $r->print('<form action="'.$r->uri.'" name="sheet" method="post">');
1.40 albertel 435: $r->print(&hiddenfield('sname' ,$env{'form.sname'}).
436: &hiddenfield('sdomain',$env{'form.sdomain'}).
437: &hiddenfield('usymb' ,$env{'form.usymb'}));
1.1 matthew 438: $r->rflush();
439: ##
440: ## Determine the filename to use
441: my $filename = undef;
1.3 matthew 442: if ($allowed_to_edit) {
1.40 albertel 443: $filename = $env{'form.filename'} if (exists($env{'form.filename'}));
1.1 matthew 444: #
1.40 albertel 445: if (exists($env{'form.load'}) && exists($env{'form.loadfilename'})) {
446: $filename = $env{'form.loadfilename'};
447: $env{'form.workcopy'} = 'no';
1.1 matthew 448: }
449: }
450: ##
1.19 matthew 451: ## Take care of "backdoor" spreadsheet expiration / recalc stuff
1.40 albertel 452: if ($allowed_to_edit && exists($env{'form.recalc'})) {
453: if (exists($env{'form.recalc'})) {
454: &Apache::loncoursedata::delete_caches($env{'requres.course.id'});
1.26 matthew 455: }
1.58 www 456: if ($env{'form.recalc'} eq 'expireallsheets') {
1.37 matthew 457: &Apache::lonnet::logthis('spreadsheet expired: entire course');
1.19 matthew 458: # expire ALL spreadsheets
459: &Apache::lonnet::expirespread('','','studentcalc');
460: &Apache::lonnet::expirespread('','','assesscalc');
1.37 matthew 461: $r->print('<h3>'.
462: &mt('Expired spreadsheet caches for all students').
463: '</h3>');
1.40 albertel 464: } elsif ($env{'form.recalc'} =~ /^symb:/) {
1.19 matthew 465: # expire for all students on this symb
1.40 albertel 466: my ($symb) = ($env{'form.recalc'} =~ /^symb:(.*)$/);
1.37 matthew 467: &Apache::lonnet::logthis('spreadsheet expired: symb = '.$symb);
1.19 matthew 468: &Apache::lonnet::expirespread('','','assesscalc',$symb);
469: &Apache::lonnet::expirespread('','','studentcalc');
1.37 matthew 470: $r->print('<h3>'.
471: &mt('Expired spreadsheet caches for all students for symb [_1]',
472: $symb).
473: '</h3>');
1.40 albertel 474: } elsif ($env{'form.recalc'} =~ /^student:/) {
1.19 matthew 475: # expire all assessment spreadsheets for this user
1.40 albertel 476: my ($sname,$sdom) = ($env{'form.recalc'}=~/^student:(.*):(.*)$/);
1.37 matthew 477: &Apache::lonnet::logthis('spreadsheet expired: student = '.
478: $sname.'@'.$sdom);
1.19 matthew 479: if (defined($sname) && defined($sdom)) {
480: &Apache::lonnet::expirespread($sname,$sdom,'assesscalc');
481: &Apache::lonnet::expirespread($sname,$sdom,'studentcalc');
1.37 matthew 482: $r->print('<h3>'.
483: &mt('Expired spreadsheet caches for student [_1]',
484: $sname.'@'.$sdom).
485: '</h3>');
1.19 matthew 486: }
487: }
488: }
489: ##
1.1 matthew 490: ## Make the spreadsheet
491: &Apache::Spreadsheet::initialize_spreadsheet_package();
492: my $spreadsheet = undef;
493: if ($sheettype eq 'classcalc') {
1.43 albertel 494: $spreadsheet = Apache::classcalc->new($name,$domain,$filename,undef,
1.47 raeburn 495: $section,\@groups);
1.1 matthew 496: } elsif ($sheettype eq 'studentcalc') {
1.43 albertel 497: $spreadsheet = Apache::studentcalc->new($name,$domain,$filename,undef,
1.47 raeburn 498: $section,\@groups);
1.2 matthew 499: } elsif ($sheettype eq 'assesscalc' &&
500: defined($symb) &&
1.3 matthew 501: $allowed_to_edit) {
1.43 albertel 502: $spreadsheet = Apache::assesscalc->new($name,$domain,$filename,$symb,
1.47 raeburn 503: $section,\@groups);
1.1 matthew 504: } else {
1.2 matthew 505: return HTTP_NOT_ACCEPTABLE;
506: }
507: if (! defined($spreadsheet)) {
508: # error error - run in circles, scream and shout
1.1 matthew 509: return;
510: }
1.8 matthew 511: $spreadsheet->initialize();
1.5 matthew 512: #
513: # Output selector
1.1 matthew 514: ##
515: ## Editing/loading/saving
1.3 matthew 516: if ($allowed_to_edit) {
1.11 matthew 517: my ($html,$action_message) = &file_dialogs($spreadsheet);
1.40 albertel 518: if ($env{'form.makedefault'}) {
1.10 matthew 519: $spreadsheet->make_default();
1.11 matthew 520: if ($action_message) {
521: $action_message .= '<br />';
522: }
1.27 www 523: $action_message .= &mt('Made this spreadsheet the default');
1.11 matthew 524: if ($sheettype eq 'classcalc') {
1.27 www 525: $action_message .= ' '.&mt('for the course');
1.11 matthew 526: } elsif ($sheettype eq 'studentcalc') {
1.27 www 527: $action_message .= ' '.&mt('for all students');
1.11 matthew 528: } elsif ($sheettype eq 'assesscalc') {
1.27 www 529: $action_message .= ' '.&mt('for all assessments');
1.11 matthew 530: }
531: $action_message .= '.';
1.10 matthew 532: }
1.38 matthew 533: $r->print('<table><tr><td valign="top">'.
534: $spreadsheet->html_header().
535: '</td>'.
536: '<td valign="center">'.$html."</td></tr></table>\n");
1.12 matthew 537: if ($action_message ne '') {
538: $r->print(<<END);
1.11 matthew 539: <table>
540: <tr><td valign="top"><b>Last Action:</b></td>
541: <td> </td>
542: <td>$action_message</td>
543: </tr>
544: </table>
545: END
1.12 matthew 546: }
1.1 matthew 547: $r->rflush();
1.5 matthew 548: } else {
549: $r->print('<table><tr><td>'.$spreadsheet->html_header().
550: "</td></tr></table>\n");
1.1 matthew 551: }
1.11 matthew 552: $r->rflush();
1.1 matthew 553: #
1.19 matthew 554: $r->print("<table><tr>");
1.31 matthew 555: $r->print('<td><input type="submit" value="'.
556: &mt('Generate Spreadsheet').'" />'.
557: '</td>');
1.21 matthew 558: if ($allowed_to_view) {
559: $r->print('<td>'.
560: &Apache::loncommon::help_open_topic("Spreadsheet_About",
1.62 ! bisitz 561: &mt('Spreadsheet Help')).
1.21 matthew 562: '</td>');
563: }
564: if ($allowed_to_edit) {
565: $r->print('<td>'.
566: &Apache::loncommon::help_open_topic("Spreadsheet_Editing",
1.62 ! bisitz 567: &mt('Editing Help')).
1.21 matthew 568: '</td>');
569: }
1.19 matthew 570: $r->print('</tr></table>');
1.10 matthew 571: #
1.1 matthew 572: # Keep track of the filename
573: $r->print(&hiddenfield('filename',$filename));
574: #
1.5 matthew 575: # Keep track of the number of times we have been called, sort of.
1.58 www 576: $r->print(&hiddenfield('not_first_run','1'));
1.5 matthew 577: #
1.40 albertel 578: if (exists($env{'form.not_first_run'}) || $sheettype ne 'classcalc') {
1.5 matthew 579: $r->print($spreadsheet->get_html_title());
580: if ($allowed_to_view || $allowed_to_edit) {
581: $r->print($spreadsheet->parent_link());
582: }
1.16 matthew 583: $r->rflush();
1.5 matthew 584: $spreadsheet->display($r);
1.1 matthew 585: }
1.58 www 586: $r->print('</form>');
587: &Apache::lonquickgrades::endGradeScreen($r);
588: $r->print(&Apache::loncommon::end_page());
1.41 albertel 589: $spreadsheet->clear_package();
1.1 matthew 590: return OK;
591: }
592:
593: 1;
594:
595: __END__
596:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>