version 1.246, 2006/05/12 03:46:54
|
version 1.256, 2006/06/30 17:42:38
|
Line 161 sub proctor_checked_in {
|
Line 161 sub proctor_checked_in {
|
my ($slot_name,$slot,$type)=@_; |
my ($slot_name,$slot,$type)=@_; |
my @possible_proctors=split(",",$slot->{'proctor'}); |
my @possible_proctors=split(",",$slot->{'proctor'}); |
|
|
|
return 1 if (!@possible_proctors); |
|
|
my $key; |
my $key; |
if ($type eq 'Task') { |
if ($type eq 'Task') { |
my $version=$Apache::lonhomework::history{'resource.0.version'}; |
my $version=$Apache::lonhomework::history{'resource.0.version'}; |
Line 168 sub proctor_checked_in {
|
Line 170 sub proctor_checked_in {
|
} elsif ($type eq 'problem') { |
} elsif ($type eq 'problem') { |
$key ='resource.0.checkedin'; |
$key ='resource.0.checkedin'; |
} |
} |
|
# backward compatability, used to be username@domain, |
|
# now is username:domain |
|
my $who = $Apache::lonhomework::history{$key}; |
|
if ($who !~ /:/) { |
|
$who =~ tr/@/:/; |
|
} |
foreach my $possible (@possible_proctors) { |
foreach my $possible (@possible_proctors) { |
if ($Apache::lonhomework::history{$key} eq $possible |
if ($who eq $possible |
&& $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) { |
&& $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) { |
return 1; |
return 1; |
} |
} |
Line 237 sub check_slot_access {
|
Line 244 sub check_slot_access {
|
# does it pass normal muster |
# does it pass normal muster |
my ($status,$datemsg)=&check_access($id); |
my ($status,$datemsg)=&check_access($id); |
|
|
my $useslots = &Apache::lonnet::EXT("resource.$id.useslots"); |
my $useslots = &Apache::lonnet::EXT("resource.0.useslots"); |
if ($useslots ne 'resource' && $useslots ne 'map') { |
if ($useslots ne 'resource' && $useslots ne 'map' |
|
&& $useslots ne 'map_map') { |
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
|
|
Line 261 sub check_slot_access {
|
Line 269 sub check_slot_access {
|
} |
} |
|
|
my @slots= |
my @slots= |
(split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")), |
(split(':',&Apache::lonnet::EXT("resource.0.availablestudent")), |
split(':',&Apache::lonnet::EXT("resource.$id.available"))); |
split(':',&Apache::lonnet::EXT("resource.0.available"))); |
|
|
# if (!@slots) { |
# if (!@slots) { |
# return ($status,$datemsg); |
# return ($status,$datemsg); |
Line 302 sub check_slot_access {
|
Line 310 sub check_slot_access {
|
$checkedin = |
$checkedin = |
$Apache::lonhomework::history{"resource.$version.0.checkedin"}; |
$Apache::lonhomework::history{"resource.$version.0.checkedin"}; |
} elsif ($type eq 'problem') { |
} elsif ($type eq 'problem') { |
$got_grade = 1; |
$got_grade = 1; |
$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"}; |
$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"}; |
|
$is_correct = |
|
($Apache::lonhomework::history{"resource.0.solved"} =~/^correct_/); |
} |
} |
|
|
&Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)"); |
&Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)"); |
Line 316 sub check_slot_access {
|
Line 326 sub check_slot_access {
|
return ('WAITING_FOR_GRADE'); |
return ('WAITING_FOR_GRADE'); |
} |
} |
|
|
|
# no slot is currently open, and has been checked in for this version |
|
# previous slot is therefore CLOSED, so therefore the problem is |
|
if (!defined($slot_name) |
|
&& $checkedin |
|
&& $type eq 'problem') { |
|
return ('CLOSED',$datemsg); |
|
} |
|
|
if ($slotstatus eq 'NOT_IN_A_SLOT' |
if ($slotstatus eq 'NOT_IN_A_SLOT' |
&& $checkedin ) { |
&& $checkedin ) { |
|
|
Line 326 sub check_slot_access {
|
Line 344 sub check_slot_access {
|
} |
} |
|
|
} |
} |
|
|
if ( $is_correct) { |
if ( $is_correct) { |
|
if ($type eq 'problem') { |
|
return ($status); |
|
} |
return ('SHOW_ANSWER'); |
return ('SHOW_ANSWER'); |
} |
} |
|
|
if ( $status eq 'CANNOT_ANSWER' && |
if ( $status eq 'CANNOT_ANSWER' && |
($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) { |
($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) { |
return ($status,$datemsg); |
return ($status,$datemsg); |
Line 383 sub check_access {
|
Line 406 sub check_access {
|
|
|
foreach my $temp ("opendate","duedate","answerdate") { |
foreach my $temp ("opendate","duedate","answerdate") { |
$lastdate = $date; |
$lastdate = $date; |
$date = &Apache::lonnet::EXT("resource.$id.$temp"); |
if ($temp eq 'duedate') { |
|
$date = &due_date($id); |
|
} else { |
|
$date = &Apache::lonnet::EXT("resource.$id.$temp"); |
|
} |
|
|
my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type"); |
my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type"); |
if ($thistype =~ /^(con_lost|no_such_host)/ || |
if ($thistype =~ /^(con_lost|no_such_host)/ || |
$date =~ /^(con_lost|no_such_host)/) { |
$date =~ /^(con_lost|no_such_host)/) { |
Line 451 sub check_access {
|
Line 479 sub check_access {
|
&Apache::lonxml::debug("looking for accesstime $first_access"); |
&Apache::lonxml::debug("looking for accesstime $first_access"); |
if (!$first_access) { |
if (!$first_access) { |
$status='NOT_YET_VIEWED'; |
$status='NOT_YET_VIEWED'; |
$datemsg=&seconds_to_human_length($interval); |
my $due_date = &due_date($id); |
} else { |
my $seconds_left = $due_date - time; |
my $newdate=localtime($first_access+$interval); |
if ($seconds_left > $interval || $due_date eq '') { |
if (time > ($first_access+$interval)) { |
$seconds_left = $interval; |
$status='CLOSED'; |
|
$datemsg = &mt("was due on")." $newdate".&mt(", and answers will be available on")." $date"; |
|
} else { |
|
$datemsg = &mt("is due at")." $newdate"; |
|
} |
} |
|
$datemsg=&seconds_to_human_length($seconds_left); |
} |
} |
} |
} |
} |
} |
|
|
#if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && |
#if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && |
# (!$Apache::lonhomework::history{"resource.0.outtoken"})) { |
# (!$Apache::lonhomework::history{"resource.0.outtoken"})) { |
# return ('UNCHECKEDOUT','needs to be checked out'); |
# return ('UNCHECKEDOUT','needs to be checked out'); |
Line 478 sub check_access {
|
Line 504 sub check_access {
|
|
|
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
|
# this should work exactly like the copy in lonnavmaps.pm |
sub due_date { |
sub due_date { |
my ($part_id,$symb)=@_; |
my ($part_id,$symb,$udom,$uname)=@_; |
my $date; |
my $date; |
my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb); |
my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb, |
if ($interval) { |
$udom,$uname); |
|
&Apache::lonxml::debug("looking for interval $part_id $symb $interval"); |
|
my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb, |
|
$udom,$uname); |
|
&Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); |
|
if (defined($interval)) { |
my $first_access=&Apache::lonnet::get_first_access('map',$symb); |
my $first_access=&Apache::lonnet::get_first_access('map',$symb); |
if ($first_access) { $date = $first_access+$interval; } |
if (defined($first_access)) { |
} |
$interval = $first_access+$interval; |
if (!defined($date)) { |
$date = ($interval < $due_date)? $interval : $due_date; |
$date = &Apache::lonnet::EXT("resource.$part_id.duedate",$symb); |
} else { |
|
$date = $due_date; |
|
} |
|
} else { |
|
$date = $due_date; |
} |
} |
return $date |
return $date |
} |
} |
Line 595 sub setuppermissions {
|
Line 630 sub setuppermissions {
|
return ''; |
return ''; |
} |
} |
|
|
|
sub unset_permissions { |
|
undef($Apache::lonhomework::queuegrade); |
|
undef($Apache::lonhomework::modifygrades); |
|
undef($Apache::lonhomework::viewgrades); |
|
undef($Apache::lonhomework::browse); |
|
} |
|
|
sub setupheader { |
sub setupheader { |
my $request=$_[0]; |
my $request=$_[0]; |
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::content_type($request,'text/html'); |
Line 781 sub editxmlmode {
|
Line 823 sub editxmlmode {
|
&Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", |
&Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", |
"Problem Editing Help"). |
"Problem Editing Help"). |
'</td><td>'. |
'</td><td>'. |
&Apache::loncommon::help_open_menu('',undef,undef,undef,5,'Authoring'). |
&Apache::loncommon::help_open_menu(undef,undef,5,'Authoring'). |
'</td></tr></table>'; |
'</td></tr></table>'; |
if ($cols > 80) { $cols = 80; } |
if ($cols > 80) { $cols = 80; } |
if ($cols < 70) { $cols = 70; } |
if ($cols < 70) { $cols = 70; } |
Line 994 sub handler {
|
Line 1036 sub handler {
|
if ($Apache::lonhomework::browse ne 'F' && |
if ($Apache::lonhomework::browse ne 'F' && |
$env{'request.state'} ne "construct") { |
$env{'request.state'} ne "construct") { |
#should know where we are, so ask |
#should know where we are, so ask |
$request->internal_redirect('/adm/ambiguous'); return OK; |
&unset_permissions(); |
|
$request->internal_redirect('/adm/ambiguous'); |
|
return OK; |
} |
} |
} |
} |
if (&setupheader($request)) { return OK; } |
if (&setupheader($request)) { |
|
&unset_permissions(); |
|
return OK; |
|
} |
&Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade"); |
&Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade"); |
&Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'}); |
&Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'}); |
my ($symb) = &Apache::lonxml::whichuser(); |
my ($symb) = &Apache::lonxml::whichuser(); |
Line 1031 sub handler {
|
Line 1078 sub handler {
|
#&Apache::lonxml::debug("Spent $td seconds processing"); |
#&Apache::lonxml::debug("Spent $td seconds processing"); |
# always turn off debug messages |
# always turn off debug messages |
$Apache::lonxml::debug=0; |
$Apache::lonxml::debug=0; |
|
&unset_permissions(); |
return OK; |
return OK; |
|
|
} |
} |