# # $Id: lonspreadsheet.pm,v 1.10 2003/06/18 15:32:37 matthew Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # The LearningOnline Network with CAPA # Spreadsheet/Grades Display Handler # # POD required stuff: =head1 NAME lonspreadsheet =head1 SYNOPSIS Spreadsheet interface to internal LON-CAPA data =head1 DESCRIPTION Lonspreadsheet provides course coordinators the ability to manage their students grades online. The students are able to view their own grades, but not the grades of their peers. The spreadsheet is highly customizable, offering the ability to use Perl code to manipulate data, as well as many built-in functions. =head2 Functions available to user of lonspreadsheet =over 4 =cut package Apache::lonspreadsheet; use strict; use Apache::classcalc(); use Apache::studentcalc(); use Apache::assesscalc(); use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::lonhtmlcommon; use HTML::Entities(); ## ## HTML utility subroutines really should go in lonhtmlcommon ## sub textfield { my ($title,$name,$value)=@_; return "\n

$title:
". ''; } sub hiddenfield { my ($name,$value)=@_; return ''."\n"; } sub selectbox { my ($title,$name,$value,%options)=@_; my $selout="\n

$title:
".''; } sub file_dialogs { my ($spreadsheet) = @_; my $bgcolor = "#FFFFFF"; my $sheettype = $spreadsheet->{'type'}; my $result = ''; ## ## Deal with saving the spreadsheet if (exists($ENV{'form.save'}) && exists($ENV{'form.savefilename'})) { $spreadsheet->filename($ENV{'form.savefilename'}); my $save_status = $spreadsheet->save(); if ($save_status ne 'ok') { $result .= "An error occurred while saving the spreadsheet". "There error is:".$save_status; return $result; } else { $result .= "Spreadsheet saved as ".$ENV{'form.savefilename'}; } } elsif (exists($ENV{'form.newformula'}) && exists($ENV{'form.cell'}) && $ENV{'form.cell'} ne '' ) { ## ## Make any requested modifications to the spreadsheet $spreadsheet->modify_cell($ENV{'form.cell'}, $ENV{'form.newformula'}); $spreadsheet->save_tmp(); # output that we are dealing with a temporary file $result .=&hiddenfield('workcopy',$sheettype); $result .='

'.$ENV{'form.cell'}.' = '.
                  $ENV{'form.newformula'}."
\n"; } ## ## Editing code $result .=&hiddenfield('cell',''). &hiddenfield('newformula',''); ## ## Create the save and load dialogs my $filename = $spreadsheet->filename(); my $truefilename = $filename; if ($spreadsheet->is_default()) { $filename = 'Default'; } my $save_dialog = ''. ' '. ''. ''; my $makedefault_dialog = ''; # my $link = 'Select Spreadsheet File"; my $load_dialog = < $link