File:
[LON-CAPA] /
loncom /
interface /
spreadsheet /
assesscalc.pm
Revision
1.8:
download - view:
text,
annotated -
select for diffs
Fri May 23 19:36:04 2003 UTC (21 years, 3 months ago) by
matthew
Branches:
MAIN
CVS tags:
HEAD
Added output selector and implemented excel output.
Moved $spreadsheet->display() to Spreadsheet.pm instead of having it reside
three times in the descendents of the spreadsheet object.
Moved $spreadsheet->outsheet_excel() to Spreadsheet.pm for the same reason.
Created Spreadsheet::output_selector, which allows the user to select the
output mode they desire.
Created $spreadsheet->excel_output_row which takes care of writing a row
to an excel worksheet.
classcalc.pm, studentcalc.pm, and assesscalc.pm each had the same work done
on them:
Created &excel_rows(), which writes the body of the spreadsheets to
an excel file.
Rewrote &get_title to return an array of title lines.
Created &get_html_title to return an HTML version of the results of
&get_title.
classcalc.pm and Spreadsheet.pm each have the following change:
Created &html_header to return appropriate HTML for the spreadsheet.
1: #
2: # $Id: assesscalc.pm,v 1.8 2003/05/23 19:36:04 matthew Exp $
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: assesscalc
34:
35: =head1 SYNOPSIS
36:
37: =head1 DESCRIPTION
38:
39: =cut
40:
41: ###################################################
42: ### AssessSheet ###
43: ###################################################
44: package Apache::assesscalc;
45:
46: use strict;
47: use Apache::Constants qw(:common :http);
48: use Apache::lonnet;
49: use Apache::loncommon;
50: use Apache::Spreadsheet;
51: use HTML::Entities();
52: use Spreadsheet::WriteExcel;
53: use GDBM_File;
54: use Time::HiRes;
55:
56: @Apache::assesscalc::ISA = ('Apache::Spreadsheet');
57:
58: ########################################################
59: ########################################################
60:
61: =pod
62:
63: =head2 Package Variables
64:
65: =over 4
66:
67: =item %Exportrows
68:
69: =item $current_name
70:
71: =item $current_domain
72:
73: =item $current_course
74:
75: =item %parmhash
76:
77: =item %nice_parameter_name
78:
79: =item %useropt
80:
81: =item %courseopt
82:
83: =back
84:
85: =cut
86:
87: ########################################################
88: ########################################################
89:
90: my %Exportrows;
91:
92: my $current_name;
93: my $current_domain;
94: my $current_course;
95:
96: my %parmhash;
97: my %nice_parameter_name;
98:
99: my %useropt;
100: my %courseopt;
101:
102: ########################################################
103: ########################################################
104:
105: =pod
106:
107: =head2 Package Subroutines
108:
109: =item &clear_package()
110:
111: Reset all package variables.
112:
113: =cut
114:
115: ########################################################
116: ########################################################
117: sub clear_package {
118: undef(%Exportrows);
119: undef($current_name);
120: undef($current_domain);
121: undef($current_course);
122: undef(%useropt);
123: undef(%courseopt);
124: }
125:
126: ########################################################
127: ########################################################
128:
129: =pod
130:
131: =item &initialize_package()
132:
133: =cut
134:
135: ########################################################
136: ########################################################
137: sub initialize_package {
138: my ($sname,$sdomain) = @_;
139: $current_course = $ENV{'request.course.id'};
140: $current_name = $sname;
141: $current_domain = $sdomain;
142: undef(%courseopt);
143: &load_cached_export_rows();
144: &load_parameter_caches();
145: }
146:
147: ########################################################
148: ########################################################
149:
150: =pod
151:
152: =item &load_parameter_caches()
153:
154: =cut
155:
156: ########################################################
157: ########################################################
158: sub load_parameter_caches {
159: my $userprefix = $current_name.':'.$current_domain.'_';
160: $userprefix =~ s/:/_/g;
161: #
162: # Course Parameters Cache
163: if (! %courseopt) {
164: &Apache::lonnet::logthis("loading course options");
165: $current_course = $ENV{'request.course.id'};
166: undef(%courseopt);
167: if (! defined($current_name) || ! defined($current_domain)) {
168: &Apache::lonnet::logthis('bad call to setup_parameter_caches');
169: return;
170: }
171: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
172: my $id = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
173: my %Tmp = &Apache::lonnet::dump('resourcedata',$dom,$id);
174: while (my ($name,$value) = each(%Tmp)) {
175: $courseopt{$name}=$value;
176: }
177: }
178: if (! %useropt) {
179: my %Tmp = &Apache::lonnet::dump('resourcedata',
180: $current_domain,$current_name);
181: while (my ($name,$value) = each(%Tmp)) {
182: if ($name =~ /^error: 2/ || $name =~ /no such file/) {
183: undef(%useropt);
184: last;
185: }
186: $useropt{$userprefix.$name}=$value;
187: }
188: }
189: }
190:
191: ########################################################
192: ########################################################
193:
194: =pod
195:
196: =head2 assesscalc object methods
197:
198: =cut
199:
200: ########################################################
201: ########################################################
202: sub ensure_current_parameter_caches {
203: my $self = shift;
204: if (! defined($current_course) ||
205: $current_course ne $ENV{'request.course.id'} ) {
206: $current_course = $ENV{'request.course.id'};
207: undef(%courseopt);
208: }
209: if (! defined($current_name) || $current_name ne $self->{'name'} ||
210: ! defined($current_domain) || $current_domain ne $self->{'domain'}) {
211: $current_domain = $self->{'domain'};
212: $current_name = $self->{'name'};
213: undef(%useropt);
214: }
215: &load_parameter_caches();
216: }
217:
218: ##################################################
219: ##################################################
220:
221: =pod
222:
223: =item &parmval()
224:
225: Determine the value of a parameter.
226:
227: Inputs: $what, the parameter needed, $symb, $uname, $udom, $csec
228:
229: Returns: The value of a parameter, or '' if none.
230:
231: This function cascades through the possible levels searching for a value for
232: a parameter. The levels are checked in the following order:
233: user, course (at section level and course level), map, and lonnet::metadata.
234: This function uses %parmhash, which must be tied prior to calling it.
235: This function also requires %courseopt and %useropt to be initialized for
236: this user and course.
237:
238: =cut
239:
240: ##################################################
241: ##################################################
242: sub parmval {
243: my $self = shift;
244: my ($what,$symb,$uname,$udom,$csec)=@_;
245: $uname = $self->{'name'} if (! defined($uname));
246: $udom = $self->{'domain'} if (! defined($udom));
247: $csec = $self->{'section'} if (! defined($csec));
248: $symb = $self->{'symb'} if (! defined($symb));
249: #
250: my $result='';
251: #
252: # This should be a
253: my ($mapname,$id,$fn)=split(/___/,$symb);
254: # Cascading lookup scheme
255: my $rwhat=$what;
256: $what =~ s/^parameter\_//;
257: $what =~ s/\_([^\_]+)$/\.$1/;
258: #
259: my $symbparm = $symb.'.'.$what;
260: my $mapparm = $mapname.'___(all).'.$what;
261: my $courseprefix = $self->{'cid'};
262: my $usercourseprefix = $uname.'_'.$udom.'_'.$self->{'cid'};
263: #
264: my $seclevel = $courseprefix.'.['.$csec.'].'.$what;
265: my $seclevelr = $courseprefix.'.['.$csec.'].'.$symbparm;
266: my $seclevelm = $courseprefix.'.['.$csec.'].'.$mapparm;
267: #
268: my $courselevel = $courseprefix.'.'.$what;
269: my $courselevelr = $courseprefix.'.'.$symbparm;
270: my $courselevelm = $courseprefix.'.'.$mapparm;
271: #
272: my $ucourselevel = $usercourseprefix.'.'.$what;
273: my $ucourselevelr = $usercourseprefix.'.'.$symbparm;
274: my $ucourselevelm = $usercourseprefix.'.'.$mapparm;
275: # check user
276: if (defined($uname)) {
277: return $useropt{$ucourselevelr} if (defined($useropt{$ucourselevelr}));
278: return $useropt{$ucourselevelm} if (defined($useropt{$ucourselevelm}));
279: return $useropt{$ucourselevel} if (defined($useropt{$ucourselevel}));
280: }
281: # check section
282: if (defined($csec)) {
283: return $courseopt{$seclevelr} if (defined($courseopt{$seclevelr}));
284: return $courseopt{$seclevelm} if (defined($courseopt{$seclevelm}));
285: return $courseopt{$seclevel} if (defined($courseopt{$seclevel}));
286: }
287: #
288: # check course
289: return $courseopt{$courselevelr} if (defined($courseopt{$courselevelr}));
290: return $courseopt{$courselevelm} if (defined($courseopt{$courselevelm}));
291: return $courseopt{$courselevel} if (defined($courseopt{$courselevel}));
292: # check map parms
293: my $thisparm = $parmhash{$symbparm};
294: return $thisparm if (defined($thisparm));
295: # check default
296: $thisparm = &Apache::lonnet::metadata($fn,$rwhat.'.default');
297: return $thisparm if (defined($thisparm));
298: #
299: # Cascade Up
300: my $space=$what;
301: $space=~s/\.\w+$//;
302: if ($space ne '0') {
303: my @parts=split(/_/,$space);
304: my $id=pop(@parts);
305: my $part=join('_',@parts);
306: if ($part eq '') { $part='0'; }
307: my $newwhat=$rwhat;
308: $newwhat=~s/\Q$space\E/$part/;
309: my $partgeneral=$self->parmval($newwhat,$symb,$uname,$udom,$csec);
310: if (defined($partgeneral)) { return $partgeneral; }
311: }
312: #nothing defined
313: return '';
314: }
315:
316: sub get_html_title {
317: my $self = shift;
318: my ($assess_title,$name,$time) = $self->get_title();
319: my $title = '<h1>'.$assess_title.'</h1>'.
320: '<h2>'.$name.', '.
321: &Apache::loncommon::aboutmewrapper
322: ($self->{'name'}.'@'.$self->{'domain'},
323: $self->{'name'},$self->{'domain'});
324: $title .= '<h3>'.$time.'</h3>';
325: return $title;
326: }
327:
328: sub get_title {
329: my $self = shift;
330: my @title = ();
331: if (($self->{'usymb'} eq '_feedback') ||
332: ($self->{'usymb'} eq '_evaluation') ||
333: ($self->{'usymb'} eq '_discussion') ||
334: ($self->{'usymb'} eq '_tutoring')) {
335: my $assess_title = ucfirst($self->{'usymb'});
336: $assess_title =~ s/^_//;
337: push(@title,$assess_title);
338: } else {
339: push(@title,&Apache::lonnet::gettitle($self->{'symb'}));
340: }
341: # Look up the users identifying information
342: # Get the users information
343: my %userenv = &Apache::loncoursedata::GetUserName($self->{'name'},
344: $self->{'domain'});
345: my $name =
346: join(' ',@userenv{'firstname','middlename','lastname','generation'});
347: $name =~ s/\s+$//;
348: push (@title,$name);
349: push (@title,scalar(localtime(time)));
350: return @title;
351: }
352:
353: sub parent_link {
354: my $self = shift;
355: my $link .= '<p><a href="/adm/studentcalc?'.
356: 'sname='.$self->{'name'}.
357: '&sdomain='.$self->{'domain'}.'">'.
358: 'Student level sheet</a></p>'."\n";
359: return $link;
360: }
361:
362: sub outsheet_html {
363: my $self = shift;
364: my ($r) = @_;
365: ###################################
366: # Determine table structure
367: ###################################
368: my $num_uneditable = 1;
369: my $num_left = 52-$num_uneditable;
370: my $tableheader =<<"END";
371: <table border="2">
372: <tr>
373: <th colspan="2" rowspan="2"><font size="+2">Assessment</font></th>
374: <td bgcolor="#FFDDDD" colspan="$num_uneditable"> </td>
375: <td colspan="$num_left">
376: <b><font size="+1">Calculations</font></b></td>
377: </tr><tr>
378: END
379: my $label_num = 0;
380: foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
381: if ($label_num<$num_uneditable) {
382: $tableheader .= '<td bgcolor="#FFDDDD">';
383: } else {
384: $tableheader .= '<td>';
385: }
386: $tableheader .= "<b><font size=+1>$_</font></b></td>";
387: $label_num++;
388: }
389: $tableheader.="</tr>\n";
390: #
391: $r->print($tableheader);
392: #
393: # Print out template row
394: $r->print('<tr><td>Template</td><td> </td>'.
395: $self->html_template_row($num_uneditable)."</tr>\n");
396: #
397: # Print out summary/export row
398: $r->print('<tr><td>Export</td><td>0</td>'.
399: $self->html_export_row()."</tr>\n");
400: #
401: # Prepare to output rows
402: $tableheader =<<"END";
403: <table border="2">
404: <tr><th>row</th><th>Item</th>
405: END
406: foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
407: if ($label_num<$num_uneditable) {
408: $tableheader.='<th bgcolor="#FFDDDD">';
409: } else {
410: $tableheader.='<th>';
411: }
412: $tableheader.="<b><font size=+1>$_</font></b></th>";
413: }
414: #
415: my $num_output = 0;
416: foreach my $rownum (sort {$a <=> $b} ($self->rows())) {
417: if ($num_output++ % 50 == 0) {
418: $r->print("</table>\n".$tableheader);
419: }
420: $r->print('<tr><td>'.$rownum.'</td>'.
421: $self->assess_html_row($num_uneditable,$rownum)."</tr>\n");
422: }
423: $r->print("</table>\n");
424: return;
425: }
426:
427: sub assess_html_row {
428: my $self = shift();
429: my ($num_uneditable,$row) = @_;
430: my $parameter_name = $self->{'formulas'}->{'A'.$row};
431: my @rowdata = $self->get_row($row);
432: my $num_cols_output = 0;
433: my $row_html;
434: if (exists($nice_parameter_name{$parameter_name})) {
435: my $name = $nice_parameter_name{$parameter_name};
436: $name =~ s/ /\ /g;
437: $row_html .= '<td>'.$name.'<br />'.$parameter_name.'</td>';
438: } else {
439: $row_html .= '<td>'.$parameter_name.'</td>';
440: }
441: foreach my $cell (@rowdata) {
442: $row_html .= '<td bgcolor="#EOFFDD">';
443: $row_html .= &Apache::Spreadsheet::html_editable_cell($cell,'#E0FFDD');
444: $row_html .= '</td>';
445: }
446: return $row_html;
447: }
448:
449: sub outsheet_csv {
450: my $self = shift;
451: my ($r) = @_;
452: $r->print('<h1>csv output is not supported yet</h1>');
453: }
454:
455: sub excel_rows {
456: # writes the meat of the spreadsheet to an excel worksheet. Called
457: # by Spreadsheet::outsheet_excel;
458: my $self = shift;
459: my ($worksheet,$cols_output,$rows_output) = @_;
460: #
461: # Write a header row
462: $cols_output = 0;
463: foreach my $value ('Parameter','Description','Value') {
464: $worksheet->write($rows_output,$cols_output++,$value);
465: }
466: $rows_output++;
467: #
468: # Write each row
469: foreach my $rownum (sort {$a <=> $b} ($self->rows())) {
470: my $parameter_name = $self->{'formulas'}->{'A'.$rownum};
471: my $description = '';
472: if (exists($nice_parameter_name{$parameter_name})) {
473: $description = $nice_parameter_name{$parameter_name};
474: }
475: $self->excel_output_row($worksheet,$rownum,$rows_output++,
476: $parameter_name,$description);
477: }
478: return;
479: }
480:
481: sub compute {
482: my $self = shift;
483: $self->logthis('computing');
484: $self->initialize_safe_space();
485: #
486: # Definitions
487: undef(%nice_parameter_name);
488: my %parameters; # holds underscored parameters by name
489: #
490: # Get the metadata fields and determine their proper names
491: my ($symap,$syid,$srcf)=split(/___/,$self->{'symb'});
492: my @Metadata = split(/\,/,&Apache::lonnet::metadata($srcf,'keys'));
493: foreach my $parm (@Metadata) {
494: next if ($parm !~ /^(resource\.|stores|parameter)_/);
495: my $cleaned_name = $parm;
496: $cleaned_name =~ s/^resource\./stores_/;
497: $cleaned_name =~ s/\./_/g;
498: my $display = &Apache::lonnet::metadata($srcf,
499: $cleaned_name.'.display');
500: if (! $display) {
501: $display .= &Apache::lonnet::metadata($srcf,$cleaned_name.'.name');
502: }
503: $parameters{$cleaned_name}++;
504: $nice_parameter_name{$cleaned_name} = $display;
505: }
506: #
507: # Get the values of the metadata fields
508: $self->ensure_current_parameter_caches();
509: my $filename = $self->{'coursefilename'}.'_parms.db';
510: if (tie(%parmhash,'GDBM_File',
511: $self->{'coursefilename'}.'_parms.db',&GDBM_READER(),0640)) {
512: foreach my $parmname (keys(%parameters)) {
513: my $value = $self->parmval($parmname);
514: $parameters{$parmname} =$value;
515: }
516: untie(%parmhash);
517: } else {
518: $self->logthis('unable to tie '.$filename);
519: }
520: #
521: # Clean out unnecessary parameters
522: foreach (keys(%parameters)) {
523: delete($parameters{$_}) if (! /(resource\.|stores_|parameter_)/);
524: }
525: #
526: # Get the students performance data
527: my %student_parameters =
528: &Apache::loncoursedata::get_current_state($self->{'name'},
529: $self->{'domain'},
530: $self->{'symb'},
531: $self->{'cid'});
532: while (my ($parm,$value) = each(%student_parameters)) {
533: $parm =~ s/^resource\./stores_/;
534: $parm =~ s/\./_/g;
535: $parameters{$parm} = $value;
536: }
537: #
538: # Set up the formulas and parameter values
539: my %f=$self->formulas();
540: my %c;
541: #
542: # Check for blackout requirements
543: if ((!exists($ENV{'request.role.adv'}) || !$ENV{'request.role.adv'})) {
544: while (my ($parm,$value) = each(%parameters)) {
545: last if ($self->blackout());
546: next if ($parm !~ /^(parameter_.*)_problemstatus$/);
547: next if ($parameters{$1.'_answerdate'}<time);
548: if (lc($value) eq 'no') {
549: # We must blackout this sheet
550: $self->blackout(1);
551: }
552: }
553: }
554: #
555: # Move the parameters into the spreadsheet
556: while (my ($parm,$value) = each(%parameters)) {
557: my $cell = 'A'.$self->get_row_number_from_key($parm);
558: $f{$cell} = $parm;
559: $value = '"'.$value.'"' if ($value =~/[^0-9.]/);
560: $c{$parm} = $value;
561: }
562: $self->formulas(\%f);
563: $self->constants(\%c);
564: $self->calcsheet();
565: #
566: # Store export row in cache
567: my @exportarray = $self->exportrow();
568: $Exportrows{$self->{'symb'}}->{'time'} = time;
569: $Exportrows{$self->{'symb'}}->{$self->{'filename'}} = \@exportarray;
570: #
571: # Save the export data
572: $self->save_export_data();
573: return;
574: }
575:
576: ##
577: ## sett overrides Spreadsheet::sett
578: ##
579: sub sett {
580: my $self = shift;
581: my %t=();
582: #
583: # Deal with the template row by copying the template formulas into each
584: # row.
585: foreach my $col ($self->template_cells()) {
586: next if ($col=~/^A/);
587: foreach my $row ($self->rows()) {
588: # Get the name of this cell
589: my $cell=$col.$row;
590: # Grab the template declaration
591: $t{$cell}=$self->formula('template_'.$col);
592: # Replace '#' with the row number
593: $t{$cell}=~s/\#/$row/g;
594: # Replace '....' with ','
595: $t{$cell}=~s/\.\.+/\,/g;
596: # Replace 'A0' with the value from 'A0'
597: $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;
598: # Replace parameters
599: $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge;
600: }
601: }
602: #
603: # Deal with the cells which have formulas
604: while (my ($cell,$formula) = each(%{$self->{'formulas'}})) {
605: next if ($cell =~ /template_/);
606: if ($cell =~ /^A/ && $cell ne 'A0') {
607: if ($formula !~ /^\!/) {
608: $t{$cell}=$self->{'constants'}->{$formula};
609: }
610: } else {
611: $t{$cell}=$formula;
612: $t{$cell}=~s/\.\.+/\,/g;
613: $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;
614: $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge;
615: }
616: }
617: # Put %t into the safe space
618: %{$self->{'safe'}->varglob('t')}=%t;
619: }
620:
621:
622: ########################################################
623: ########################################################
624:
625: =pod
626:
627: =item &load_cached_export_rows()
628:
629: Retrieves and parsers the export rows of the assessment spreadsheets.
630: These rows are saved in the students directory in the format:
631:
632: sname:sdom:assesscalc:symb.time => time
633:
634: sname:sdom:assesscalc:symb => filename___=___Adata___;___Bdata___;___ ...
635:
636: =cut
637:
638: ########################################################
639: ########################################################
640: sub load_cached_export_rows {
641: %Exportrows = undef;
642: my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets_'.
643: $ENV{'request.course.id'},
644: $current_domain,$current_name,undef);
645: if ($tmp[0]!~/^error/) {
646: my %tmp = @tmp;
647: my $default_filename = $ENV{'course.'.$ENV{'request.course.id'}.
648: '.spreadsheet_default_assesscalc'};
649: # We only got one key, so we will access it directly.
650: while (my ($key,$sheetdata) = each(%tmp)) {
651: my ($sname,$sdom,$sheettype,$symb) = split(':',$key);
652: if ($symb =~ /\.time$/) {
653: $symb =~ s/\.time$//;
654: $Exportrows{$symb}->{'time'} = $sheetdata;
655: } else {
656: $sheetdata =~ s/^(.*)___=___//;
657: my $filename = $1;
658: $filename = $default_filename if (! defined($filename));
659: my @Data = split('___;___',$sheetdata);
660: $Exportrows{$symb}->{$filename} = \@Data;
661: }
662: }
663: }
664: }
665:
666: #############################################
667: #############################################
668:
669: =pod
670:
671: =item &export_data
672:
673: Returns the export data associated with the spreadsheet. Computes the
674: spreadsheet only if necessary.
675:
676: =cut
677:
678: #############################################
679: #############################################
680: sub export_data {
681: my $self = shift;
682: my $symb = $self->{'symb'};
683: if (! exists($ENV{'request.role.adv'}) || ! $ENV{'request.role.adv'} ||
684: ! exists($Exportrows{$symb}) || ! defined($Exportrows{$symb}) ||
685: ! $self->check_expiration_time($Exportrows{$symb}->{'time'}) ||
686: ! exists($Exportrows{$symb}->{$self->{'filename'}}) ||
687: ! defined($Exportrows{$symb}->{$self->{'filename'}})) {
688: $self->compute();
689: }
690: my @Data = @{$Exportrows{$symb}->{$self->{'filename'}}};
691: if ($Data[0] =~ /^(.*)___=___/) {
692: $self->{'sheetname'} = $1;
693: $Data[0] =~ s/^(.*)___=___//;
694: }
695: for (my $i=0;$i<$#Data;$i++) {
696: $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i]));
697: }
698: return @Data;
699: }
700:
701: #############################################
702: #############################################
703:
704: =pod
705:
706: =item &save_export_data()
707:
708: Writes the export data for this spreadsheet to the students cache.
709:
710: =cut
711:
712: #############################################
713: #############################################
714: sub save_export_data {
715: my $self = shift;
716: return if ($self->temporary());
717: my $student = $self->{'name'}.':'.$self->{'domain'};
718: my $symb = $self->{'symb'};
719: if (! exists($Exportrows{$symb}) ||
720: ! exists($Exportrows{$symb}->{$self->{'filename'}})) {
721: return;
722: }
723: my $key = join(':',($self->{'name'},$self->{'domain'},'assesscalc',$symb));
724: my $timekey = $key.'.time';
725: my $newstore= join('___;___',@{$Exportrows{$symb}->{$self->{'filename'}}});
726: $newstore = $self->{'filename'}.'___=___'.$newstore;
727: my $result = &Apache::lonnet::put
728: ('nohist_calculatedsheets_'.$ENV{'request.course.id'},
729: { $key => $newstore,
730: $timekey => $Exportrows{$symb}->{'time'} },
731: $self->{'domain'},
732: $self->{'name'});
733:
734: return;
735: }
736:
737: 1;
738:
739: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>