version 1.61, 2001/08/20 15:47:22
|
version 1.66, 2001/08/22 19:21:36
|
Line 63 sub page_start {
|
Line 63 sub page_start {
|
return ($result,$head_tag_start,$body_tag_start); |
return ($result,$head_tag_start,$body_tag_start); |
} |
} |
|
|
|
sub initialize_storage { |
|
%Apache::lonhomework::results=(); |
|
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
|
%Apache::lonhomework::history= |
|
&Apache::lonnet::restore($symb,$courseid,$domain,$name); |
|
#ignore error conditions |
|
my ($temp)=keys %Apache::lonhomework::history ; |
|
if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); } |
|
} |
|
|
|
# -------------------------------------------------------------finalize_storage |
|
# Stores away the result has to a student's environment |
|
# checks form.grade_ for specific values, other wises stores |
|
# to the running users environment |
|
sub finalize_storage { |
|
my $result; |
|
my ($temp) = keys %Apache::lonhomework::results; |
|
if ( $temp ne '' ) { |
|
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
|
$result=&Apache::lonnet::cstore(\%Apache::lonhomework::results, |
|
$symb,$courseid,$domain,$name); |
|
&Apache::lonxml::debug("Store return message:".$result); |
|
} |
|
return $result; |
|
} |
|
|
|
sub checkout_msg { |
|
return (<<ENDCHECKOUT); |
|
<h2>The resource needs to be checked out</h2> |
|
As a resource gets checked out, a unique timestamped ID is given to it, and a |
|
permanent record is left in the system.<p /> |
|
<font color=red> |
|
Checking out resources is subject to course policies, and may exclude future |
|
credit even if done erroneously.<p /> |
|
</font> |
|
<form method=post> |
|
<input type=button name="doescheckout" |
|
value="Check out Exam for Viewing" |
|
onClick="if (confirm('Check out Exam?')) { this.form.submit(); }" /> |
|
</form> |
|
ENDCHECKOUT |
|
} |
|
|
sub start_problem { |
sub start_problem { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
|
Line 70 sub start_problem {
|
Line 113 sub start_problem {
|
$Apache::inputtags::part='0'; |
$Apache::inputtags::part='0'; |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::responselist = (); |
@Apache::inputtags::previous=(); |
@Apache::inputtags::previous=(); |
|
&initialize_storage(); |
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); |
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); |
&Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:"); |
&Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:"); |
if ($Apache::lonhomework::type eq '') { |
if ($Apache::lonhomework::type eq '') { |
Line 83 sub start_problem {
|
Line 127 sub start_problem {
|
} |
} |
} |
} |
|
|
#adeed vars to the scripting enviroment |
#added vars to the scripting enviroment |
my $expression='$external::part='.$Apache::inputtags::part.';'; |
my $expression='$external::part='.$Apache::inputtags::part.';'; |
&Apache::run::run($expression,$safeeval); |
&Apache::run::run($expression,$safeeval); |
my $status; |
my $status; |
Line 98 sub start_problem {
|
Line 142 sub start_problem {
|
my $token=$Apache::lonhomework::history{"resource.0.outtoken"}; |
my $token=$Apache::lonhomework::history{"resource.0.outtoken"}; |
if (($ENV{'form.doescheckout'}) && (!$token)) { |
if (($ENV{'form.doescheckout'}) && (!$token)) { |
$token=&Apache::lonxml::maketoken(); |
$token=&Apache::lonxml::maketoken(); |
$Apache::lonhomework.history{"resource.0.outtoken"}=$token; |
$Apache::lonhomework::history{"resource.0.outtoken"}=$token; |
} |
} |
$body_tag_start.=&Apache::lonxml::printtokenheader($target,$token); |
$body_tag_start.=&Apache::lonxml::printtokenheader($target,$token); |
} |
} |
if ($target eq 'meta') { |
|
|
|
return (<<ENDSTORES); |
|
<stores part="0" name="outtoken" type="string" |
|
display="Document ID checked out"></stores> |
|
<stores part="0" name="checkouttime" type="date" |
|
display="Time checked out"></stores> |
|
<stores part="0" name="outremote" type="string" |
|
display="Client IP checked out from"></stores> |
|
|
|
<stores part="0" name="intoken" type="string" |
|
display="Document ID checked in"></stores> |
|
<stores part="0" name="checkintime" type="date" |
|
display="Time checked in"></stores> |
|
<stores part="0" name="inremote" type="string" |
|
display="Client IP checked in from"></stores> |
|
ENDSTORES |
|
} |
|
} |
} |
if ($target eq 'web' || $target eq 'grade') { |
if ($target eq 'web' || $target eq 'grade') { |
($status,$accessmsg) = &Apache::lonhomework::check_access('0'); |
($status,$accessmsg) = &Apache::lonhomework::check_access('0'); |
Line 138 ENDSTORES
|
Line 164 ENDSTORES
|
if ($status eq 'CLOSED') { |
if ($status eq 'CLOSED') { |
$msg.='The problem '.$accessmsg; |
$msg.='The problem '.$accessmsg; |
} elsif ($status eq 'UNCHECKEDOUT') { |
} elsif ($status eq 'UNCHECKEDOUT') { |
$msg.=(<<ENDCHECKOUT); |
$msg.=&checkout_msg; |
<h2>The resource needs to be checked out</h2> |
|
As a resource gets checked out, a unique timestamped ID is given to it, and a |
|
permanent record is left in the system.<p /> |
|
<font color=red> |
|
Checking out resources is subject to course policies, and may exclude future |
|
credit even if done erroneously.<p /> |
|
</font> |
|
<form method=post> |
|
<input type=button name="doescheckout" |
|
value="Check out Exam for Viewing" |
|
onClick="if (confirm('Check out Exam?')) { this.form.submit(); }" /> |
|
</form> |
|
ENDCHECKOUT |
|
} |
} |
return $result.$msg.'<br />'; |
return $result.$msg.'<br />'; |
} |
} |
Line 174 ENDCHECKOUT
|
Line 187 ENDCHECKOUT
|
$result.='<input type="hidden" name="problemmode" value="View" /> |
$result.='<input type="hidden" name="problemmode" value="View" /> |
<input type="submit" name="problemmode" value="Edit" /><hr />'; |
<input type="submit" name="problemmode" value="Edit" /><hr />'; |
} |
} |
|
# if we are viewing someone else preserve that info |
|
if (defined $ENV{'form.grade_symb'}) { |
|
foreach my $field ('symb','courseid','domain','username') { |
|
$result .= '<input type="hidden" name="grade_'.$field. |
|
'" value="'.$ENV{"form.grade_$field"}.'" />'."\n"; |
|
} |
|
} |
return $result; |
return $result; |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'CLOSED') { |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'CLOSED') { |
return $result.$head_tag_start."<title>$name</title></head>\n$body_tag_start\n"; |
return $result.$head_tag_start."<title>$name</title></head>\n$body_tag_start\n"; |
Line 222 sub end_problem {
|
Line 242 sub end_problem {
|
} |
} |
$result.=&Apache::lonxml::xmlend(); |
$result.=&Apache::lonxml::xmlend(); |
} |
} |
} |
if ($target eq 'grade') { |
if ($target eq 'meta') { |
&Apache::lonhomework::showhash(%Apache::lonhomework::results); |
|
&finalize_storage(); |
|
} |
|
} elsif ($target eq 'meta') { |
if ($Apache::inputtags::part eq '0') { |
if ($Apache::inputtags::part eq '0') { |
$result=&Apache::response::mandatory_part_meta; |
$result=&Apache::response::mandatory_part_meta; |
} |
} |
} |
} elsif ($target eq 'edit') { |
if ($target eq 'edit') { |
|
&Apache::lonxml::debug("in end_problem with $target, edit"); |
&Apache::lonxml::debug("in end_problem with $target, edit"); |
$result='<br /><input type="submit" name="submit" value="Submit Changes" />'; |
$result='<br /><input type="submit" name="submit" value="Submit Changes" />'; |
} |
} |