version 1.372, 2018/08/14 18:24:04
|
version 1.376, 2023/06/02 01:20:27
|
Line 50 use Apache::chemresponse();
|
Line 50 use Apache::chemresponse();
|
use Apache::functionplotresponse(); |
use Apache::functionplotresponse(); |
use Apache::drawimage(); |
use Apache::drawimage(); |
use Apache::loncapamath(); |
use Apache::loncapamath(); |
|
use Apache::loncourseuser(); |
|
use Apache::grades(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonparmset(); |
use Apache::lonparmset(); |
Line 242 sub check_slot_access {
|
Line 244 sub check_slot_access {
|
$consumed_uniq = $slot{'uniqueperiod'}; |
$consumed_uniq = $slot{'uniqueperiod'}; |
if ($slot{'iptied'}) { |
if ($slot{'iptied'}) { |
$ipused = $Apache::lonhomework::history{"$checkin.ip"}; |
$ipused = $Apache::lonhomework::history{"$checkin.ip"}; |
unless (($ip ne '') && ($ipused eq $ip)) { |
unless (($ip ne '') && |
|
(($ipused eq $ip) || ($ENV{'REMOTE_ADDR'} eq '127.0.0.1'))) { |
$blockip = $slot{'iptied'}; |
$blockip = $slot{'iptied'}; |
$slot_name = $checkinslot; |
$slot_name = $checkinslot; |
$returned_slot = \%slot; |
$returned_slot = \%slot; |
Line 276 sub check_slot_access {
|
Line 279 sub check_slot_access {
|
return ('SHOW_ANSWER'); |
return ('SHOW_ANSWER'); |
} |
} |
} |
} |
|
} elsif (($type eq 'problem') && |
|
($Apache::lonhomework::browse eq 'F') && |
|
($ENV{'REMOTE_ADDR'} eq '127.0.0.1') && |
|
($env{'form.grade_courseid'} eq $env{'request.course.id'}) && |
|
(&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) { |
|
return ($status,$datemsg); |
} |
} |
|
|
my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent",$symb); |
my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent",$symb); |
Line 369 sub check_slot_access {
|
Line 378 sub check_slot_access {
|
$earlyout = 1; |
$earlyout = 1; |
} |
} |
} |
} |
if (($currtries == $maxtries) || ($is_correct)) { |
if ($currtries == $maxtries) { |
$earlyout = 1; |
$earlyout = 1; |
} else { |
} else { |
$numgraded ++; |
$numgraded ++; |
Line 788 sub setuppermissions {
|
Line 797 sub setuppermissions {
|
$env{'request.course.sec'} !~ /^\s*$/) { |
$env{'request.course.sec'} !~ /^\s*$/) { |
$viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}. |
$viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}. |
'/'.$env{'request.course.sec'}); |
'/'.$env{'request.course.sec'}); |
|
if ($viewgrades) { |
|
$Apache::lonhomework::viewgradessec = $env{'request.course.sec'}; |
|
} |
} |
} |
$Apache::lonhomework::viewgrades = $viewgrades; |
$Apache::lonhomework::viewgrades = $viewgrades; |
|
|
Line 805 sub setuppermissions {
|
Line 817 sub setuppermissions {
|
$modifygrades = |
$modifygrades = |
&Apache::lonnet::allowed('mgr',$env{'request.course.id'}. |
&Apache::lonnet::allowed('mgr',$env{'request.course.id'}. |
'/'.$env{'request.course.sec'}); |
'/'.$env{'request.course.sec'}); |
|
if ($modifygrades) { |
|
$Apache::lonhomework::modifygradessec = $env{'request.course.sec'}; |
|
} |
} |
} |
$Apache::lonhomework::modifygrades = $modifygrades; |
$Apache::lonhomework::modifygrades = $modifygrades; |
|
|
Line 823 sub setuppermissions {
|
Line 838 sub setuppermissions {
|
sub unset_permissions { |
sub unset_permissions { |
undef($Apache::lonhomework::queuegrade); |
undef($Apache::lonhomework::queuegrade); |
undef($Apache::lonhomework::modifygrades); |
undef($Apache::lonhomework::modifygrades); |
|
undef($Apache::lonhomework::modifygradessec); |
undef($Apache::lonhomework::viewgrades); |
undef($Apache::lonhomework::viewgrades); |
|
undef($Apache::lonhomework::viewgradessec); |
undef($Apache::lonhomework::browse); |
undef($Apache::lonhomework::browse); |
} |
} |
|
|
Line 1271 sub editxmlmode {
|
Line 1288 sub editxmlmode {
|
# Render the page in whatever target desired. |
# Render the page in whatever target desired. |
# |
# |
sub renderpage { |
sub renderpage { |
my ($request,$file,$targets,$return_string,$donebuttonmsg) = @_; |
my ($request,$file,$targets,$return_string,$donebuttonmsg,$viewasuser,$symb) = @_; |
|
|
my @targets = @{$targets || [&get_target()]}; |
my @targets = @{$targets || [&get_target()]}; |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
Line 1312 sub renderpage {
|
Line 1329 sub renderpage {
|
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');} |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');} |
|
|
|
if (($target eq 'web') && ($viewasuser ne '') && ($symb ne '')) { |
|
$env{'request.user_in_effect'} = $viewasuser; |
|
} |
|
|
&Apache::lonxml::debug("Should be parsing now"); |
&Apache::lonxml::debug("Should be parsing now"); |
$result .= &Apache::lonxml::xmlparse($request, $target, $problem, |
$result .= &Apache::lonxml::xmlparse($request, $target, $problem, |
&setup_vars($target),%mystyle); |
&setup_vars($target),%mystyle); |
Line 1337 sub renderpage {
|
Line 1358 sub renderpage {
|
#} |
#} |
# $request->print($result); |
# $request->print($result); |
$overall_result.=$result; |
$overall_result.=$result; |
|
if (($target eq 'web') && ($viewasuser ne '') && ($symb ne '')) { |
|
my ($vuname,$vudom) = split(/:/,$viewasuser); |
|
$overall_result .= &Apache::grades::view_as_user($symb,$vuname,$vudom). |
|
'</body></html>'; |
|
} |
# $request->rflush(); |
# $request->rflush(); |
} |
} |
|
if (($target eq 'web') && ($viewasuser ne '') && ($symb ne '')) { |
|
undef($env{'request.user_in_effect'}); |
|
} |
#$request->print(":Result ends"); |
#$request->print(":Result ends"); |
#my $td=&tv_interval($t0); |
#my $td=&tv_interval($t0); |
} |
} |
if (!$return_string) { |
if (!$return_string) { |
&Apache::lonxml::add_messages(\$overall_result); |
&Apache::lonxml::add_messages(\$overall_result); |
$request->print($overall_result); |
$request->print($overall_result); |
$request->rflush(); |
$request->rflush(); |
} else { |
} else { |
return $overall_result; |
return $overall_result; |
} |
} |
Line 1667 sub handler {
|
Line 1696 sub handler {
|
} else { |
} else { |
# Set the event timer to zero if the "done button" was clicked. The button is |
# Set the event timer to zero if the "done button" was clicked. The button is |
# part of the doneButton form created in lonmenu.pm |
# part of the doneButton form created in lonmenu.pm |
my ($donebuttonresult,$donemsg); |
my ($donebuttonresult,$donemsg,$viewasuser); |
if ($symb && $env{'form.LC_interval_done'} eq 'true') { |
if ($symb && $env{'form.LC_interval_done'} eq 'true') { |
($donebuttonresult,$donemsg) = &zero_timer($symb); |
($donebuttonresult,$donemsg) = &zero_timer($symb); |
undef($env{'form.LC_interval_done'}); |
undef($env{'form.LC_interval_done'}); |
undef($env{'form.LC_interval_done_proctorpass'}); |
undef($env{'form.LC_interval_done_proctorpass'}); |
} |
} |
|
if (($env{'form.LC_viewas'} ne '') && $symb && $env{'request.course.id'} && |
|
($Apache::lonhomework::viewgrades || $Apache::lonhomework::modifygrades)) { |
|
if ($env{'form.LC_viewas'} =~ /^($match_username):($match_domain)$/) { |
|
my ($possuname,$possudom) = ($1,$2); |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my ($canview,$posssec); |
|
if ($env{'request.course.sec'} ne '') { |
|
if ($Apache::lonhomework::modifygradessec eq $env{'request.course.sec'}) { |
|
$canview = 'section'; |
|
$posssec = $env{'request.course.sec'}; |
|
} elsif ($Apache::lonhomework::viewgradessec eq $env{'request.course.sec'}) { |
|
$canview = 'section'; |
|
$posssec = $env{'request.course.sec'}; |
|
} |
|
} |
|
my $crstype = &Apache::loncommon::course_type(); |
|
if (&Apache::loncourseuser::is_course_user($possudom,$possuname,$cdom,$cnum, |
|
$canview,$crstype,$posssec)) { |
|
$viewasuser = $possuname.':'.$possudom; |
|
} |
|
} |
|
undef($env{'form.LC_viewas'}); |
|
} |
# just render the page normally outside of construction space |
# just render the page normally outside of construction space |
&Apache::lonxml::debug("not construct"); |
&Apache::lonxml::debug("not construct"); |
undef(@Apache::lonhomework::ltipassback); |
undef(@Apache::lonhomework::ltipassback); |
&renderpage($request,$file,undef,undef,$donemsg); |
&renderpage($request,$file,undef,undef,$donemsg,$viewasuser,$symb); |
if (@Apache::lonhomework::ltipassback) { |
if (@Apache::lonhomework::ltipassback) { |
unless ($registered_cleanup) { |
unless ($registered_cleanup) { |
my $handlers = $request->get_handlers('PerlCleanupHandler'); |
my $handlers = $request->get_handlers('PerlCleanupHandler'); |
Line 1877 sub do_ltipassback {
|
Line 1930 sub do_ltipassback {
|
if (ref($item) eq 'HASH') { |
if (ref($item) eq 'HASH') { |
if ((ref($item->{'lti'}) eq 'HASH') && ($item->{'cid'} =~ /^($match_domain)_($match_courseid)$/)) { |
if ((ref($item->{'lti'}) eq 'HASH') && ($item->{'cid'} =~ /^($match_domain)_($match_courseid)$/)) { |
my ($cdom,$cnum) = ($1,$2); |
my ($cdom,$cnum) = ($1,$2); |
my $ckey = $item->{'lti'}->{'key'}; |
my $msgformat = $item->{'lti'}->{'passbackformat'}; |
my $secret = $item->{'lti'}->{'secret'}; |
my $sigmethod = 'HMAC-SHA1'; |
|
my $ltinum = $item->{'ltinum'}; |
my $id = $item->{'pbid'}; |
my $id = $item->{'pbid'}; |
my $url = $item->{'pburl'}; |
my $url = $item->{'pburl'}; |
|
my $type = $item->{'pbtype'}; |
my $scope = $item->{'scope'}; |
my $scope = $item->{'scope'}; |
my $map = $item->{'ltimap'}; |
my $map = $item->{'ltimap'}; |
my $symb = $item->{'ltisymb'}; |
my $symb = $item->{'ltisymb'}; |
my $uname = $item->{'uname'}; |
my $uname = $item->{'uname'}; |
my $udom = $item->{'udom'}; |
my $udom = $item->{'udom'}; |
|
my $keynum = $item->{'lti'}->{'cipher'}; |
|
my $crsdef = $item->{'crsdef'}; |
my $scoretype = $item->{'format'}; |
my $scoretype = $item->{'format'}; |
my ($total,$possible); |
my ($total,$possible); |
if ($scope eq 'resource') { |
if ($scope eq 'resource') { |
Line 1896 sub do_ltipassback {
|
Line 1953 sub do_ltipassback {
|
} elsif ($scope eq 'course') { |
} elsif ($scope eq 'course') { |
($total,$possible) = &get_lti_score($uname,$udom); |
($total,$possible) = &get_lti_score($uname,$udom); |
} |
} |
if (($ckey ne '') && ($secret ne '') && ($id ne '') && ($url ne '') && ($possible)) { |
if (($id ne '') && ($url ne '') && ($possible)) { |
&LONCAPA::ltiutils::send_grade($id,$url,$ckey,$secret,$scoretype,$total,$possible); |
&LONCAPA::ltiutils::send_grade($cdom,$cnum,$crsdef,$type,$ltinum,$keynum,$id,$url,$scoretype,$sigmethod,$msgformat,$total,$possible); |
} |
} |
} |
} |
} |
} |