--- loncom/homework/structuretags.pm 2023/07/05 20:57:30 1.512.2.24.2.3
+++ loncom/homework/structuretags.pm 2024/03/01 17:05:45 1.512.2.24.2.14
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.512.2.24.2.3 2023/07/05 20:57:30 raeburn Exp $
+# $Id: structuretags.pm,v 1.512.2.24.2.14 2024/03/01 17:05:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -273,7 +273,7 @@ sub homework_js {
}
return &Apache::loncommon::resize_textarea_js().
&Apache::loncommon::colorfuleditor_js().
- &setmode_javascript().
+ &Apache::lonxml::setmode_javascript().
<<"JS";
-ENDSCRIPT
-}
-
sub page_start {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,
$extra_head)=@_;
@@ -421,7 +406,7 @@ sub page_start {
if (&Apache::lonhtmlcommon::htmlareabrowser()) {
my %textarea_args;
if (($env{'request.state'} ne 'construct') ||
- ($env{'environment.nocodemirror'})) {
+ (&Apache::loncommon::nocodemirror())) {
%textarea_args = (
dragmath => 'math',
);
@@ -529,23 +514,25 @@ sub page_start {
} elsif (!defined($found{'body'})
&& $env{'request.state'} eq 'construct') {
if ($target eq 'web' || $target eq 'edit') {
- # Breadcrumbs for Authoring Space
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Authoring Space',
- 'href' => &Apache::loncommon::authorspace($env{'request.uri'}),
- });
- # breadcrumbs (and tools) will be created
- # in start_page->bodytag->innerregister
+ unless ($env{'form.inhibitmenu'} eq 'yes') {
+ # Breadcrumbs for Authoring Space
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Authoring Space',
+ 'href' => &Apache::loncommon::authorspace($env{'request.uri'}),
+ });
+ # breadcrumbs (and tools) will be created
+ # in start_page->bodytag->innerregister
# FIXME Where are we?
-# &Apache::lonhtmlcommon::add_breadcrumb({
-# 'text' => 'Problem Editing', # 'Problem Testing'
-# 'href' => '',
-# });
- $pageheader =&Apache::loncommon::head_subbox(
- &Apache::loncommon::CSTR_pageheader());
- }
+# &Apache::lonhtmlcommon::add_breadcrumb({
+# 'text' => 'Problem Editing', # 'Problem Testing'
+# 'href' => '',
+# });
+ $pageheader = &Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader());
+ }
+ }
} elsif (!defined($found{'body'})) {
my %add_entries;
my $background=&Apache::lonxml::get_param('background',$parstack,
@@ -600,7 +587,9 @@ sub page_start {
my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
my ($path,$multiresp) =
&Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom);
- if (($is_task) || ($needs_upload)) {
+ if ($env{'request.user_in_effect'}) {
+ $form_tag_start .= ' onsubmit="preventDefault();"';
+ } elsif (($is_task) || ($needs_upload)) {
$form_tag_start .= ' onsubmit="return file_submission_check(this,'."'$path','$multiresp'".');"';
}
$form_tag_start.='>'."\n";
@@ -706,7 +695,7 @@ sub setup_rndseed {
}
$env{'form.'.$Apache::inputtags::part.'.rndseed'}=$rndseed;
}
- if ( ($env{'form.resetdata'} eq &mt('New Problem Variation')
+ if ( ($env{'form.resetdata'} eq 'new_problem_variation'
&& $env{'form.submitted'} eq 'yes') ||
$env{'form.newrandomization'} eq &mt('New Randomization')) {
srand(time);
@@ -789,13 +778,18 @@ sub problem_edit_action_button {
sub problem_edit_buttons {
my ($mode)=@_;
+ my %editors = &Apache::loncommon::permitted_editors();
# Buttons that save
my $result = '
';
if ($mode eq 'editxml') {
- $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML');
+ if ($editors{'xml'}) {
+ $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML');
+ }
$result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View');
} else {
- $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit');
+ if ($editors{'edit'}) {
+ $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit');
+ }
$result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View');
}
$result.="\n
'.
- &mt('A problem occurred when trying to start the timer.').'
';
- }
- $msg.=&firstaccess_msg($accessmsg,$symb);
- } elsif ($status eq 'NOT_IN_A_SLOT') {
- $msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work");
- } elsif ($status eq 'RESERVABLE') {
- $msg.=&mt('Available to make a reservation.').' '.&mt('Reservation window closes [_1].',
- &Apache::lonnavmaps::timeToHumanString($accessmsg,'end')).
- ' '.
- &Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work");
- } elsif ($status eq 'RESERVABLE_LATER') {
- $msg.=&mt('Window to make a reservation will open [_1].',
- &Apache::lonnavmaps::timeToHumanString($accessmsg,'start'));
- } elsif ($status eq 'NOTRESERVABLE') {
- $msg.=&mt('Not available to make a reservation.');
- }
- $result.=$msg.' ';
- } elsif ($target eq 'tex') {
- my $startminipage = ($env{'form.problem_split'}=~/yes/i)? ''
- : '\begin{minipage}{\textwidth}';
- $result.='\noindent \vskip 1 mm '.
- $startminipage.'\vskip 0 mm';
- if ($status eq 'UNAVAILABLE') {
- $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
- } else {
- $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
- }
- }
+ if (($status eq 'NOT_YET_VIEWED') && ($firstaccres)) {
+ $result .= '
'.
+ &mt('A problem occurred when trying to start the timer.').'
';
+ }
+ $result .= &access_status_msg('problem',$status,$symb,$target,'',$accessmsg);
} elsif ($status eq 'NEEDS_CHECKIN') {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
- if ($target eq 'web') {
- $result .=
- &Apache::bridgetask::proctor_validation_screen($slot);
- } elsif ($target eq 'grade') {
- &Apache::bridgetask::proctor_check_auth($slot_name,$slot,
- 'problem');
- }
+ $result .= &checkin_prompt($target,$slot_name,$slot,'problem');
} elsif ($target eq 'web') {
if ($status eq 'CAN_ANSWER') {
$resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
if ($slot_name ne '') {
- my $checked_in =
- $Apache::lonhomework::history{'resource.0.checkedin'};
- if ($checked_in eq '') {
- # unproctored slot access, self checkin
- &Apache::bridgetask::check_in('problem',undef,undef,
- $slot_name);
- $checked_in =
- $Apache::lonhomework::results{"resource.0.checkedin"};
- }
- if ((ref($slot) eq 'HASH') && ($checked_in ne '')) {
- if ($slot->{'starttime'} < time()) {
- if (!$resource_due) {
- $resource_due = $slot->{'endtime'};
- } elsif ($slot->{'endtime'} < $resource_due) {
- $resource_due = $slot->{'endtime'};
- }
- }
- }
+ $resource_due = &selfcheckin_resource($resource_due,$slot_name,$slot,
+ $env{'request.symb'});
}
if ($resource_due) {
my $time_left = $resource_due - time();
@@ -1962,10 +2029,15 @@ sub start_problem {
'';
# create a page header and exit
if ($env{'request.state'} eq "construct") {
- $result.= &problem_web_to_edit_header($env{'form.rndseed'});
+ if ($env{'form.inhibitmenu'} eq 'yes') {
+ # error messages can be useful in any case
+ $result.= &Apache::lonxml::message_location();
+ } else {
+ $result.= &problem_web_to_edit_header($env{'form.rndseed'});
+ }
if ($Apache::lonhomework::type eq 'practice') {
- $result.= ''.
+ $result.= ''.
&practice_problem_header().'';
} elsif ($Apache::lonhomework::type eq 'randomizetry') {
my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
@@ -1992,8 +2064,6 @@ sub start_problem {
} elsif ($target eq 'tex') {
$result .= 'INSERTTEXFRONTMATTERHERE';
$result .= &select_metadata_hyphenation();
-
-
}
} elsif ($target eq 'edit') {
$result .= $form_tag_start.&problem_edit_header();
@@ -2113,6 +2183,12 @@ sub end_problem {
}
}
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/;
+ } elsif ($target eq 'web') {
+ if ($env{'request.user_in_effect'}) {
+ &reset_problem_globals('problem');
+ $result .= &Apache::lonhtmlcommon::set_compute_end_time();
+ return $result;
+ }
}
my $status=$Apache::inputtags::status['-1'];
@@ -2227,7 +2303,8 @@ ENDJS
# computation:
#
if ($target eq 'web') {
- $result .= &Apache::lonhtmlcommon::set_compute_end_time();
+ $result .= &Apache::lonhtmlcommon::dash_to_minus_js().
+ &Apache::lonhtmlcommon::set_compute_end_time();
#
# Closing tags delayed so any tags
# not in head can appear inside body, for valid xhtml.
@@ -2266,8 +2343,8 @@ sub start_library {
'';
$result.=&problem_web_to_edit_header($rndseed);
if ($Apache::lonhomework::type eq 'practice') {
- $result.= ''.
+ $result.= ''.
&practice_problem_header().'';
}
}
@@ -3219,7 +3296,7 @@ sub end_startouttext {
.&Apache::edit::deletelist($target,$token)
.''
.'
';
- if ($env{'environment.nocodemirror'}) {
+ if (&Apache::loncommon::nocodemirror()) {
$result.=&Apache::lonhtmlcommon::dragmath_button($areaid,1);
} else {
$result.=' ';