version 1.264.8.2, 2024/07/02 00:33:18
|
version 1.265, 2015/10/05 02:35:40
|
Line 65 sub initialize_bridgetask {
|
Line 65 sub initialize_bridgetask {
|
sub proctor_check_auth { |
sub proctor_check_auth { |
my ($slot_name,$slot,$type)=@_; |
my ($slot_name,$slot,$type)=@_; |
my $user=$env{'form.proctorname'}; |
my $user=$env{'form.proctorname'}; |
$user =~ s/^\s+|\s+$//g; |
|
my $domain=$env{'form.proctordomain'}; |
my $domain=$env{'form.proctordomain'}; |
|
|
my @allowed=split(",",$slot->{'proctor'}); |
my @allowed=split(",",$slot->{'proctor'}); |
foreach my $possible (@allowed) { |
foreach my $possible (@allowed) { |
my ($puser,$pdom)=(split(':',$possible)); |
my ($puser,$pdom)=(split(':',$possible)); |
Line 84 sub proctor_check_auth {
|
Line 83 sub proctor_check_auth {
|
} |
} |
} |
} |
if ($authenticated) { |
if ($authenticated) { |
my $check = &check_in($type,$user,$domain,$slot_name); |
my $check = &check_in($type,$user,$domain,$slot_name,$slot->{'iptied'}); |
if ($check =~ /^error:/) { |
if ($check =~ /^error:/) { |
return 0; |
return 0; |
} |
} |
Line 96 sub proctor_check_auth {
|
Line 95 sub proctor_check_auth {
|
} |
} |
|
|
sub check_in { |
sub check_in { |
my ($type,$user,$domain,$slot_name) = @_; |
my ($type,$user,$domain,$slot_name,$needsiptied) = @_; |
my $useslots = &Apache::lonnet::EXT("resource.0.useslots"); |
my $useslots = &Apache::lonnet::EXT("resource.0.useslots"); |
|
my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; |
if ( $useslots eq 'map_map') { |
if ( $useslots eq 'map_map') { |
my $result = &check_in_sequence($user,$domain,$slot_name); |
my $result = &check_in_sequence($user,$domain,$slot_name,$ip,$needsiptied); |
if ($result =~ /^error: /) { |
if ($result =~ /^error: /) { |
return $result; |
return $result; |
} |
} |
} else { |
} else { |
&create_new_version($type,$user,$domain,$slot_name); |
my ($symb) = &Apache::lonnet::whichuser(); |
&Apache::structuretags::finalize_storage(); |
my $result = &create_new_version($type,$user,$domain,$slot_name,$symb,$ip,$needsiptied); |
|
if ($result eq 'ok') { |
|
&Apache::structuretags::finalize_storage(); |
|
} |
|
return $result; |
} |
} |
return 1; |
return 1; |
} |
} |
|
|
sub check_in_sequence { |
sub check_in_sequence { |
my ($user,$domain,$slot_name) = @_; |
my ($user,$domain,$slot_name,$ip,$needsiptied) = @_; |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
if (!defined($navmap)) { |
if (!defined($navmap)) { |
return 'error: '; |
return 'error: No navmap'; |
} |
} |
my ($symb) = &Apache::lonnet::whichuser(); |
my ($symb) = &Apache::lonnet::whichuser(); |
my ($map) = &Apache::lonnet::decode_symb($symb); |
my ($map) = &Apache::lonnet::decode_symb($symb); |
Line 123 sub check_in_sequence {
|
Line 127 sub check_in_sequence {
|
my %old_history = %Apache::lonhomework::history; |
my %old_history = %Apache::lonhomework::history; |
my %old_results = %Apache::lonhomework::results; |
my %old_results = %Apache::lonhomework::results; |
|
|
|
my $errorcount; |
foreach my $res (@resources) { |
foreach my $res (@resources) { |
&Apache::lonxml::debug("doing ".$res->src); |
&Apache::lonxml::debug("doing ".$res->src); |
&Apache::structuretags::initialize_storage($res->symb); |
&Apache::structuretags::initialize_storage($res->symb); |
my $type = ($res->is_task()) ? 'Task' : 'problem'; |
my $type = ($res->is_task()) ? 'Task' : 'problem'; |
&create_new_version($type,$user,$domain,$slot_name); |
my $result = &create_new_version($type,$user,$domain,$slot_name,$res->symb,$ip,$needsiptied); |
&Apache::structuretags::finalize_storage($res->symb); |
if ($result eq 'ok') { |
|
&Apache::structuretags::finalize_storage($res->symb); |
|
} else { |
|
$errorcount ++; |
|
} |
} |
} |
|
|
%Apache::lonhomework::history = %old_history; |
%Apache::lonhomework::history = %old_history; |
%Apache::lonhomework::results = %old_results; |
%Apache::lonhomework::results = %old_results; |
|
if ($errorcount) { |
|
return 'error: IP taken'; |
|
} |
} |
} |
|
|
sub create_new_version { |
sub create_new_version { |
my ($type,$user,$domain,$slot_name) = @_; |
my ($type,$user,$domain,$slot_name,$symb,$ip,$needsiptied) = @_; |
|
|
|
if ($needsiptied) { |
|
my $uniqkey = "$slot_name\0$symb\0$ip"; |
|
my ($cdom,$cnum); |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my %hash = ( |
|
"$slot_name\0$symb\0$ip" => $env{'user.name'}.':'.$env{'user.domain'}, |
|
); |
|
unless (&Apache::lonnet::newput('slot_uniqueips',\%hash,$cdom,$cnum) eq 'ok') { |
|
return 'error: IP taken'; |
|
} |
|
} |
|
} |
|
|
my $id = '0'; |
my $id = '0'; |
if ($type eq 'Task') { |
if ($type eq 'Task') { |
Line 170 sub create_new_version {
|
Line 197 sub create_new_version {
|
|
|
$Apache::lonhomework::results{"resource.$id.checkedin"}= |
$Apache::lonhomework::results{"resource.$id.checkedin"}= |
$user.':'.$domain; |
$user.':'.$domain; |
|
$Apache::lonhomework::results{"resource.$id.checkedin.ip"}=$ip; |
|
|
if (defined($slot_name)) { |
if (defined($slot_name)) { |
$Apache::lonhomework::results{"resource.$id.checkedin.slot"}= |
$Apache::lonhomework::results{"resource.$id.checkedin.slot"}= |
$slot_name; |
$slot_name; |
} |
} |
|
return 'ok'; |
} |
} |
|
|
sub get_version { |
sub get_version { |
Line 710 sub start_Task {
|
Line 739 sub start_Task {
|
if ((($status eq 'CAN_ANSWER') || ($status eq 'NOT_YET_VIEWED')) && ($version eq '')) { |
if ((($status eq 'CAN_ANSWER') || ($status eq 'NOT_YET_VIEWED')) && ($version eq '')) { |
# CAN_ANSWER or NOT_YET_VIEWED mode, and no current version, unproctored access |
# CAN_ANSWER or NOT_YET_VIEWED mode, and no current version, unproctored access |
# thus self-checkedin |
# thus self-checkedin |
my $check = &check_in('Task',undef,undef,$slot_name); |
my $needsiptied; |
if ($check =~ /^error: /) { |
if (ref($slot)) { |
|
$needsiptied = $slot->{'iptied'}; |
|
} |
|
my $check = &check_in('Task',undef,undef,$slot_name,$needsiptied); |
|
if ($check =~ /^error:\s+(.*)$/) { |
my $symb=&Apache::lonnet::symbread(); |
my $symb=&Apache::lonnet::symbread(); |
&Apache::lonnet::logthis("Error during self-checkin of version $version of Task (symb: $symb) using slot: $slot_name"); |
&Apache::lonnet::logthis("Error: $1 during self-checkin of version $version of Task (symb: $symb) using slot: $slot_name"); |
} |
} |
&add_to_queue('gradingqueue',{'type' => 'Task', |
&add_to_queue('gradingqueue',{'type' => 'Task', |
'time' => time, |
'time' => time, |
Line 766 sub start_Task {
|
Line 799 sub start_Task {
|
} elsif ($status eq 'NOT_YET_VIEWED') { |
} elsif ($status eq 'NOT_YET_VIEWED') { |
my $symb=&Apache::lonnet::symbread(); |
my $symb=&Apache::lonnet::symbread(); |
$msg.=&Apache::structuretags::firstaccess_msg($accessmsg,$symb); |
$msg.=&Apache::structuretags::firstaccess_msg($accessmsg,$symb); |
|
} elsif ($status eq 'NEED_DIFFERENT_IP') { |
|
#FIXME |
} else { |
} else { |
$msg.='<p class="LC_warning">'.&mt('Not open to be viewed').'</p>'; |
$msg.='<p class="LC_warning">'.&mt('Not open to be viewed').'</p>'; |
} |
} |
Line 3286 sub proctor_validation_screen {
|
Line 3321 sub proctor_validation_screen {
|
<input type="hidden" name="validate" value="yes" /> |
<input type="hidden" name="validate" value="yes" /> |
<input type="hidden" name="submitted" value="yes" /> |
<input type="hidden" name="submitted" value="yes" /> |
<table> |
<table> |
<tr><td>$lt{'prus'}</td><td><input type="text" name="proctorname" value="$env{'form.proctorname'}" autocomplete="new-password" /></td></tr> |
<tr><td>$lt{'prus'}</td><td><input type="string" name="proctorname" value="$env{'form.proctorname'}" /></td></tr> |
<tr><td>$lt{'pasw'}</td><td><input type="password" name="proctorpassword" value="" autocomplete="new-password" /></td></tr> |
<tr><td>$lt{'pasw'}</td><td><input type="password" name="proctorpassword" value="" /></td></tr> |
<tr><td>$lt{'prdo'}</td><td><input type="text" name="proctordomain" value="$env{'form.proctordomain'}" autocomplete="off" /></td></tr> |
<tr><td>$lt{'prdo'}</td><td><input type="string" name="proctordomain" value="$env{'form.proctordomain'}" /></td></tr> |
</table> |
</table> |
<input type="submit" name="checkoutbutton" value="$lt{'vali'}" /><br /> |
<input type="submit" name="checkoutbutton" value="$lt{'vali'}" /><br /> |
<table border="1"> |
<table border="1"> |