--- loncom/homework/lonhomework.pm 2024/02/28 21:03:29 1.344.2.10.4.8 +++ loncom/homework/lonhomework.pm 2024/07/08 01:13:59 1.344.2.11 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.344.2.10.4.8 2024/02/28 21:03:29 raeburn Exp $ +# $Id: lonhomework.pm,v 1.344.2.11 2024/07/08 01:13:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,23 +49,15 @@ use Apache::matchresponse(); use Apache::chemresponse(); use Apache::functionplotresponse(); use Apache::drawimage(); -use Apache::loncapamath(); -use Apache::loncourseuser(); -use Apache::grades(); use Apache::Constants qw(:common); use Apache::loncommon(); -use Apache::lonparmset(); -use Apache::lonnavmaps(); use Apache::lonlocal; -use LONCAPA qw(:DEFAULT :match); -use LONCAPA::ltiutils(); use Time::HiRes qw( gettimeofday tv_interval ); use HTML::Entities(); use File::Copy(); # FIXME - improve commenting -my $registered_cleanup; BEGIN { &Apache::lonxml::register_insert(); @@ -163,19 +155,9 @@ sub get_target { return ('web','answer'); } elsif (($env{'form.problemmode'} eq 'saveedit') || ($env{'form.problemmode'} eq 'undo')) { - my %editors = &Apache::loncommon::permitted_editors(); - if ($editors{'edit'}) { - return ('modified','no_output_web','edit'); - } else { - return ('web'); - } + return ('modified','no_output_web','edit'); } elsif ($env{'form.problemmode'} eq 'edit') { - my %editors = &Apache::loncommon::permitted_editors(); - if ($editors{'edit'}) { - return ('no_output_web','edit'); - } else { - return ('web'); - } + return ('no_output_web','edit'); } else { return ('web'); } @@ -206,7 +188,7 @@ sub proctor_checked_in { if ($type eq 'Task') { my $version=$Apache::lonhomework::history{'resource.0.version'}; $key ="resource.$version.0.checkedin"; - } elsif (($type eq 'problem') || ($type eq 'tool')) { + } elsif ($type eq 'problem') { $key ='resource.0.checkedin'; } # backward compatability, used to be username@domain, @@ -221,6 +203,7 @@ sub proctor_checked_in { return 1; } } + return 0; } @@ -229,7 +212,7 @@ sub check_slot_access { # does it pass normal muster my ($status,$datemsg)=&check_access($id,$symb); - + my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb); if ($useslots ne 'resource' && $useslots ne 'map' && $useslots ne 'map_map') { @@ -309,7 +292,7 @@ sub check_slot_access { || $Apache::lonhomework::history{"resource.0.solved"} =~ /^correct_/ ); $checkedin = $Apache::lonhomework::history{"resource.$version.0.checkedin"}; - } elsif (($type eq 'problem') || ($type eq 'tool')) { + } elsif ($type eq 'problem') { $checkin = 'resource.0.checkedin'; $checkedin = $Apache::lonhomework::history{$checkin}; } @@ -318,7 +301,7 @@ sub check_slot_access { my %slot=&Apache::lonnet::get_slot($checkinslot); $consumed_uniq = $slot{'uniqueperiod'}; } - if (($type eq 'problem') || ($type eq 'tool')) { + if ($type eq 'problem') { if ((ref($partlist) eq 'ARRAY') && (@{$partlist} > 0)) { my ($numcorrect,$numgraded) = (0,0); foreach my $part (@{$partlist}) { @@ -377,9 +360,8 @@ sub check_slot_access { # However, the problem is not closed, and potentially, another slot might be # used to gain access to it to work on it, until the due date is reached, and the # problem then becomes CLOSED. Therefore return the slotstatus - - # (which will be one of: NOT_IN_A_SLOT, RESERVABLE, RESERVABLE_LATER, or NOTRESERVABLE). - - if (!defined($slot_name) && (($type eq 'problem') || ($type eq 'tool'))) { + # (which will be one of: NOT_IN_A_SLOT, RESERVABLE, RESERVABLE_LATER, or NOTRESERVABLE. + if (!defined($slot_name) && $type eq 'problem') { if ($slotstatus eq 'NOT_IN_A_SLOT') { if (!$num_usable_slots) { if ($env{'request.course.id'}) { @@ -463,7 +445,7 @@ sub check_slot_access { } if ( $is_correct) { - if (($type eq 'problem') || ($type eq 'tool')) { + if ($type eq 'problem') { return ($status); } return ('SHOW_ANSWER'); @@ -734,9 +716,6 @@ sub setuppermissions { $env{'request.course.sec'} !~ /^\s*$/) { $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}. '/'.$env{'request.course.sec'}); - if ($viewgrades) { - $Apache::lonhomework::viewgradessec = $env{'request.course.sec'}; - } } $Apache::lonhomework::viewgrades = $viewgrades; @@ -754,9 +733,6 @@ sub setuppermissions { $modifygrades = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}. '/'.$env{'request.course.sec'}); - if ($modifygrades) { - $Apache::lonhomework::modifygradessec = $env{'request.course.sec'}; - } } $Apache::lonhomework::modifygrades = $modifygrades; @@ -775,9 +751,7 @@ sub setuppermissions { sub unset_permissions { undef($Apache::lonhomework::queuegrade); undef($Apache::lonhomework::modifygrades); - undef($Apache::lonhomework::modifygradessec); undef($Apache::lonhomework::viewgrades); - undef($Apache::lonhomework::viewgradessec); undef($Apache::lonhomework::browse); } @@ -892,26 +866,18 @@ sub analyze_header { {'bread_crumbs' => $brcrum,}) .&Apache::loncommon::head_subbox( &Apache::loncommon::CSTR_pageheader()); - my %lt = &Apache::lonlocal::texthash( - edit => 'Edit', - editxml => 'EditXML', - ); $result .= '
'. ''. &Apache::structuretags::remember_problem_state().' -
'; - my %editors = &Apache::loncommon::permitted_editors(); - foreach my $item ('editxml','edit') { - next unless ($editors{$item}); - $result .= ''. - "\n"; - } - $result .= - '
+
+ + +

@@ -1096,8 +1062,9 @@ sub editxmlmode { $problem=''; } + if (($env{'form.problemmode'} eq 'saveeditxml') || - ($env{'form.problemmode'} eq 'saveviewxml') || + ($env{'form.problemmode'} eq 'saveviewxml') || ($env{'form.problemmode'} eq 'undoxml')) { my $error=&handle_save_or_undo($request,\$problem, \$env{'form.editxmltext'}); @@ -1154,8 +1121,7 @@ sub editxmlmode { $result .= '
    '; - my $nocodemirror = &Apache::loncommon::nocodemirror(); - unless ($nocodemirror) { + unless ($env{'environment.nocodemirror'}) { # dropdown menus $result .= Apache::lonmenu::create_submenu("#", "", &mt("Problem Templates"), template_dropdown_datastructure()); @@ -1187,7 +1153,7 @@ sub editxmlmode { '
    '; my $resource = $env{'request.ambiguous'}; - unless ($nocodemirror) { + unless($env{'environment.nocodemirror'}){ $result .= '