@@ -1262,110 +1576,111 @@ ENDSCRIPT
&hiddenfield('usymb',$ENV{'form.usymb'}).
&hiddenfield('unewfield','').
&hiddenfield('unewformula',''));
- }
+
+# ---------------------- Make sure that this gets out, even if user hits "stop"
+
$r->rflush();
+
# ---------------------------------------- Read new sheet or modified worksheet
- my $sheetone=initsheet();
$r->uri=~/\/(\w+)$/;
- &settype($sheetone,$1);
+
+ my $asheet=&makenewsheet($aname,$adom,$1,$ENV{'form.usymb'});
+
+# ------------------------ If a new formula had been entered, go from work copy
+
if ($ENV{'form.unewfield'}) {
$r->print('Modified Workcopy
');
$ENV{'form.unewformula'}=~s/\'/\"/g;
$r->print('New formula: '.$ENV{'form.unewfield'}.'='.
$ENV{'form.unewformula'}.'
');
- &setfilename($sheetone,$ENV{'form.ufn'});
- &tmpread($sheetone,$r->dir_config('lonDaemons').'/tmp/',
- $ENV{'form.usymb'},
+ &setfilename($asheet,$ENV{'form.ufn'});
+ &tmpread($asheet,
$ENV{'form.unewfield'},$ENV{'form.unewformula'});
- } elsif ($ENV{'form.saveas'}) {
- &setfilename($sheetone,$ENV{'form.ufn'});
- &tmpread($sheetone,$r->dir_config('lonDaemons').'/tmp/',
- $ENV{'form.usymb'});
+
+ } elsif ($ENV{'form.saveas'}) {
+ &setfilename($asheet,$ENV{'form.ufn'});
+ &tmpread($asheet);
} else {
- &readsheet($sheetone,$ENV{'form.ufn'},$r);
- $ENV{'form.ufn'}=&getfilename($sheetone);
+ &readsheet($asheet,$ENV{'form.ufn'});
}
- if (&gettype($sheetone) eq 'classcalc') {
-# ---------------------------------- For course view: get courselist and update
- &updatestudentrows($sheetone);
- } else {
-# ----------------- For assessment and student: See if all import rows uptodate
+# -------------------------------------------------- Print out user information
+
+ unless (&gettype($asheet) eq 'classcalc') {
+ $r->print('
User: '.&getuname($asheet).
+ '
Domain: '.&getudom($asheet));
+ if (&getcsec($asheet) eq '-1') {
+ $r->print('
'.
+ 'Not a student in this course
');
+ } else {
+ $r->print('
Section/Group: '.&getcsec($asheet));
+ }
+ }
+
+# ---------------------------------------------------------------- Course title
+
+ $r->print(''.
+ $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'
');
+
- if (tie(%parmhash,'GDBM_File',
- $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640)) {
- $csec=&Apache::lonnet::usection($udom,$uname,$ENV{'request.course.id'});
- if ($csec eq '-1') {
- $r->print(''.
- "User '$uname' at domain '$udom' not a student in this course
");
- }
- &updaterows($sheetone);
- untie(%parmhash);
- } else {
- $r->print(''.
- 'Could not initialize import fields (not in a course)
');
- }
- }
# ---------------------------------------------------- See if something to save
+
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
my $fname='';
if ($ENV{'form.saveas'} && ($fname=$ENV{'form.newfn'})) {
$fname=~s/\W/\_/g;
if ($fname eq 'default') { $fname='course_default'; }
- $fname.='_'.&gettype($sheetone);
- &setfilename($sheetone,$fname);
+ $fname.='_'.&gettype($asheet);
+ &setfilename($asheet,$fname);
$ENV{'form.ufn'}=$fname;
- my $reply=&writesheet($sheetone);
- unless ($reroute) {
- $r->print('Saving spreadsheet: '.$reply.'
');
- }
- }
+ $r->print('
Saving spreadsheet: '.
+ &writesheet($asheet,$ENV{'form.makedefufn'}).'
');
+ }
}
+
# ------------------------------------------------ Write the modified worksheet
- &tmpwrite($sheetone,$r->dir_config('lonDaemons').'/tmp/',
- $ENV{'form.usymb'});
+ $r->print('Current sheet: '.&getfilename($asheet).'
');
+
+ &tmpwrite($asheet);
+
+# ----------------------------------------------------------------- Save dialog
+
-# ----------------------------------------------------- Print user, course, etc
- unless ($reroute) {
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
my $fname=$ENV{'form.ufn'};
$fname=~s/\_[^\_]+$//;
if ($fname eq 'default') { $fname='course_default'; }
$r->print(''.
- '
');
- }
- $r->print(&hiddenfield('ufn',$ENV{'form.ufn'}));
- unless (&gettype($sheetone) eq 'classcalc') {
- $r->print('
User: '.$uname.'
Domain: '.$udom);
+ ' (make default: )
');
}
- $r->print('
'.
- $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'
');
- if ($csec) {
- $r->print('Group/Section: '.$csec.'
');
- }
- }
-# -------------------------------------------------------- Import and calculate
- if (&gettype($sheetone) eq 'assesscalc') {
- &rowaassess($sheetone,$ENV{'form.usymb'});
- } elsif (&gettype($sheetone) eq 'studentcalc') {
- &rowazstudent($sheetone);
- }
- my $calcoutput=&calcsheet($sheetone);
- unless ($reroute) {
- $r->print(''.$calcoutput.'
');
- }
+ $r->print(&hiddenfield('ufn',&getfilename($asheet)));
+
+
+# ----------------------------------------------------- Update sheet, load rows
+
+ $r->print("Loaded sheet, updating rows ...
\n");
+ $r->rflush();
+
+ &updatesheet($asheet);
+
+ $r->print("Updated rows, loading row data ...
\n");
+ $r->rflush();
-# ------------------------------------------------------- Print or export sheet
- unless ($reroute) {
- &outsheet($r,$sheetone);
+ &loadrows($asheet,$r);
+ $r->print("Loaded row data, calculating sheet ...
\n");
+ $r->rflush();
+
+ my $calcoutput=&calcsheet($asheet);
+ $r->print(''.$calcoutput.'
');
+
+ &outsheet($r,$asheet);
$r->print('');
- } else {
- $r->print(&exportrow($sheetone));
- }
+
# ------------------------------------------------------------------------ Done
} else {
# ----------------------------- Not in a course, or not allowed to modify parms
@@ -1374,6 +1689,7 @@ ENDSCRIPT
return HTTP_NOT_ACCEPTABLE;
}
return OK;
+
}
1;