version 1.371, 2018/05/15 04:59:14
|
version 1.378, 2023/07/23 16:11:52
|
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 256 sub check_slot_access {
|
Line 259 sub check_slot_access {
|
} else { |
} else { |
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
} |
} |
|
|
if ($status eq 'CLOSED' || |
if ($status eq 'CLOSED' || |
$status eq 'INVALID_ACCESS' || |
$status eq 'INVALID_ACCESS' || |
Line 266 sub check_slot_access {
|
Line 269 sub check_slot_access {
|
if ($env{'request.state'} eq "construct") { |
if ($env{'request.state'} eq "construct") { |
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
|
|
if ($type eq 'Task') { |
if ($type eq 'Task') { |
if ($checkedin && |
if ($checkedin && |
$Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass') { |
$Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass') { |
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 362 sub check_slot_access {
|
Line 371 sub check_slot_access {
|
my $probstatus = &Apache::structuretags::get_problem_status($part); |
my $probstatus = &Apache::structuretags::get_problem_status($part); |
my $earlyout; |
my $earlyout; |
unless (($probstatus eq 'no') || |
unless (($probstatus eq 'no') || |
($probstatus eq 'no_feedback_ever')) { |
($probstatus eq 'no_feedback_ever')) { |
if ($Apache::lonhomework::history{"resource.$part.solved"} =~/^correct_/) { |
if ($Apache::lonhomework::history{"resource.$part.solved"} =~/^correct_/) { |
$numcorrect ++; |
$numcorrect ++; |
} else { |
} else { |
$earlyout = 1; |
$earlyout = 1; |
} |
} |
} |
} |
if (($currtries == $maxtries) || ($is_correct)) { |
if ($currtries == $maxtries) { |
$earlyout = 1; |
$earlyout = 1; |
} else { |
} else { |
$numgraded ++; |
$numgraded ++; |
} |
} |
last if ($earlyout); |
last if ($earlyout); |
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 925 sub analyze_header {
|
Line 942 sub analyze_header {
|
my $js = &Apache::structuretags::setmode_javascript(); |
my $js = &Apache::structuretags::setmode_javascript(); |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
my $text = 'Authoring Space'; |
'text' => 'Authoring Space'}, |
my $href = &Apache::loncommon::authorspace($request->uri); |
|
if ($env{'request.course.id'}) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($href eq "/priv/$cdom/$cnum/") { |
|
$text = 'Course Authoring Space'; |
|
} |
|
} |
|
my $brcrum = [{'href' => $href, |
|
'text' => $text}, |
{'href' => '', |
{'href' => '', |
'text' => 'Problem Testing'}, |
'text' => 'Problem Testing'}, |
{'href' => '', |
{'href' => '', |
Line 1158 sub editxmlmode {
|
Line 1184 sub editxmlmode {
|
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); |
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
my $text = 'Authoring Space'; |
'text' => 'Authoring Space'}, |
my $href = &Apache::loncommon::authorspace($request->uri); |
|
if ($env{'request.course.id'}) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($href eq "/priv/$cdom/$cnum/") { |
|
$text = 'Course Authoring Space'; |
|
} |
|
} |
|
my $brcrum = [{'href' => $href, |
|
'text' => $text}, |
{'href' => '', |
{'href' => '', |
'text' => 'Problem Editing'}]; |
'text' => 'Problem Editing'}]; |
|
|
Line 1194 sub editxmlmode {
|
Line 1229 sub editxmlmode {
|
|
|
unless ($env{'environment.nocodemirror'}) { |
unless ($env{'environment.nocodemirror'}) { |
# dropdown menus |
# dropdown menus |
$result .= Apache::lonmenu::create_submenu("#", "", |
$result .= Apache::lonmenu::create_submenu("#", "", |
&mt("Problem Templates"), template_dropdown_datastructure()); |
&mt("Problem Templates"), template_dropdown_datastructure()); |
|
|
$result .= Apache::lonmenu::create_submenu("#", "", |
$result .= Apache::lonmenu::create_submenu("#", "", |
&mt("Response Types"), responseblock_dropdown_datastructure()); |
&mt("Response Types"), responseblock_dropdown_datastructure()); |
|
|
$result .= Apache::lonmenu::create_submenu("#", "", |
$result .= Apache::lonmenu::create_submenu("#", "", |
&mt("Conditional Blocks"), conditional_scripting_datastructure()); |
&mt("Conditional Blocks"), conditional_scripting_datastructure()); |
|
|
$result .= Apache::lonmenu::create_submenu("#", "", |
$result .= Apache::lonmenu::create_submenu("#", "", |
&mt("Miscellaneous"), misc_datastructure()); |
&mt("Miscellaneous"), misc_datastructure()); |
} |
} |
|
|
$result .= Apache::lonmenu::create_submenu("#", "", |
$result .= Apache::lonmenu::create_submenu("#", "", |
&mt("Help") . ' <img src="/adm/help/help.png" alt="' . &mt("Help") . |
&mt("Help") . ' <img src="/adm/help/help.png" alt="' . &mt("Help") . |
'" style="vertical-align:text-bottom; height: auto; margin:0; "/>', |
'" style="vertical-align:text-bottom; height: auto; margin:0; "/>', |
helpmenu_datastructure(),""); |
helpmenu_datastructure(),""); |
|
|
$result.="</ol></div>"; |
$result.="</ol></div>"; |
|
|
$result .= '</div></div>' . |
$result .= '</div></div>' . |
&Apache::lonxml::message_location() . |
&Apache::lonxml::message_location() . |
&Apache::loncommon::xmleditor_js() . |
&Apache::loncommon::xmleditor_js() . |
'<textarea ' . &Apache::edit::element_change_detection() . |
'<textarea ' . &Apache::edit::element_change_detection() . |
Line 1250 sub editxmlmode {
|
Line 1285 sub editxmlmode {
|
autoCloseBrackets: true, |
autoCloseBrackets: true, |
height: "auto", |
height: "auto", |
styleActiveLine: true, |
styleActiveLine: true, |
|
|
extraKeys: { |
extraKeys: { |
"Tab": "indentMore", |
"Tab": "indentMore", |
"Shift-Tab": "indentLess", |
"Shift-Tab": "indentLess", |
Line 1271 sub editxmlmode {
|
Line 1306 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 1347 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 1376 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 1364 sub finished_parsing {
|
Line 1411 sub finished_parsing {
|
# value 3: name of help topic ??? |
# value 3: name of help topic ??? |
sub get_template_list{ |
sub get_template_list{ |
my ($extension) = @_; |
my ($extension) = @_; |
|
|
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
'/templates/*.'.$extension); |
'/templates/*.'.$extension); |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
Line 1495 sub newproblem {
|
Line 1542 sub newproblem {
|
my $url=&HTML::Entities::encode($request->uri,'<>&"'); |
my $url=&HTML::Entities::encode($request->uri,'<>&"'); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $instructions; |
my $instructions; |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
my $text = 'Authoring Space'; |
'text' => 'Authoring Space'}, |
my $href = &Apache::loncommon::authorspace($request->uri); |
|
if ($env{'request.course.id'}) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($href eq "/priv/$cdom/$cnum/") { |
|
$text = 'Course Authoring Space'; |
|
} |
|
} |
|
my $brcrum = [{'href' => $href, |
|
'text' => $text}, |
{'href' => '', |
{'href' => '', |
'text' => "Create New $extension"}]; |
'text' => "Create New $extension"}]; |
my $start_page = |
my $start_page = |
Line 1544 sub update_construct_style {
|
Line 1600 sub update_construct_style {
|
} |
} |
|
|
# |
# |
# Sets interval for current user so time left will be zero, either for the entire folder |
# Sets interval for current user so time left will be zero, either for the entire folder |
# containing the current resource, or just the resource, depending on value of first item |
# containing the current resource, or just the resource, depending on value of first item |
# in interval array retrieved from EXT("resource.0.interval"); |
# in interval array retrieved from EXT("resource.0.interval"); |
# |
# |
Line 1568 sub zero_timer {
|
Line 1624 sub zero_timer {
|
$key =~ s/\s+$//; |
$key =~ s/\s+$//; |
if ($env{'form.LC_interval_done_proctorpass'} ne $secret) { |
if ($env{'form.LC_interval_done_proctorpass'} ne $secret) { |
return ('fail', |
return ('fail', |
&mt('Incorrect key entered by proctor')); |
&mt('Incorrect key entered by proctor')); |
} |
} |
} |
} |
if ($first_access+$timelimit > $now) { |
if ($first_access+$timelimit > $now) { |
Line 1591 sub zero_timer {
|
Line 1647 sub zero_timer {
|
return ('ok'); |
return ('ok'); |
} else { |
} else { |
return ('fail',&mt('Error ending timed event: [_1]',$result)); |
return ('fail',&mt('Error ending timed event: [_1]',$result)); |
} |
} |
} else { |
} else { |
return ('fail',&mt('Timed event already ended')); |
return ('fail',&mt('Timed event already ended')); |
} |
} |
Line 1622 sub handler {
|
Line 1678 sub handler {
|
#check if we know where we are |
#check if we know where we are |
if ($env{'request.course.fn'} && !&Apache::lonnet::symbread('','',1,1)) { |
if ($env{'request.course.fn'} && !&Apache::lonnet::symbread('','',1,1)) { |
# if we are browsing we might not be able to know where we are |
# if we are browsing we might not be able to know where we are |
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 |
&unset_permissions(); |
&unset_permissions(); |
Line 1667 sub handler {
|
Line 1723 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 1957 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 1980 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); |
} |
} |
} |
} |
} |
} |