--- loncom/homework/structuretags.pm 2023/06/02 01:20:27 1.575 +++ loncom/homework/structuretags.pm 2023/11/28 04:48:15 1.582 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.575 2023/06/02 01:20:27 raeburn Exp $ +# $Id: structuretags.pm,v 1.582 2023/11/28 04:48:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -297,7 +297,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)=@_; @@ -445,7 +430,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', ); @@ -554,11 +539,20 @@ sub page_start { && $env{'request.state'} eq 'construct') { if ($target eq 'web' || $target eq 'edit') { unless ($env{'form.inhibitmenu'} eq 'yes') { + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($env{'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 = &mt('Course Authoring Space'); + } + } # Breadcrumbs for Authoring Space &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Authoring Space', - 'href' => &Apache::loncommon::authorspace($env{'request.uri'}), + 'text' => $text, + 'href' => $href, }); # breadcrumbs (and tools) will be created # in start_page->bodytag->innerregister @@ -722,7 +716,7 @@ sub setup_rndseed { $env{'form.rndseed'}=$rndseed; } } - if ((($env{'request.state'} eq "construct") || ($symb eq '')) && + if ((($env{'request.state'} eq "construct") || ($symb eq '')) && ($Apache::lonhomework::type eq 'randomizetry')) { if ($numtries) { if (($reqtries =~ /^\d+$/) && ($reqtries > 1)) { @@ -826,13 +820,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
\n"; @@ -840,13 +839,23 @@ sub problem_edit_buttons { $result .= '
'. &problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1); if ($mode eq 'editxml') { - $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); + if ($editors{'edit'}) { + $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); + } + if ($editors{'daxe'}) { + $result.=&problem_edit_action_button('subdaxe','daxe','w','Edit with Daxe',1); + } $result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1); - if ($env{'environment.nocodemirror'}) { + if (&Apache::loncommon::nocodemirror()) { $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); } } else { - $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); + if ($editors{'xml'}) { + $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); + } + if ($editors{'daxe'}) { + $result.=&problem_edit_action_button('subdaxe','daxe','w','Edit with Daxe',1); + } $result.=&problem_edit_action_button('subundo','undo','u','Undo',1); } $result.="\n
"; @@ -918,6 +927,7 @@ sub option { sub problem_web_to_edit_header { my ($rndseed)=@_; + my %editors = &Apache::loncommon::permitted_editors(); my $result .= '
'; if (!$Apache::lonhomework::parsing_a_task) { @@ -1047,15 +1057,20 @@ $show_all
'; $result.=''; - $result .= ''; - $result .= ''; - if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) { + if ($editors{'edit'}) { + $result .= ''; + } + if ($editors{'xml'}) { + $result .= ''; + } + if (($editors{'daxe'}) && + ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) { my $uri = $env{'request.uri'}; my $daxeurl = '/daxepage'.$uri; - $result .= ''; + $result .= ''; } $result.='
@@ -1092,7 +1107,7 @@ sub initialize_storage { } %Apache::lonhomework::history= &Apache::lonnet::tmprestore($namespace,'',$domain,$name); - my ($temp)=keys(%Apache::lonhomework::history) ; + my ($temp)=keys(%Apache::lonhomework::history); &Apache::lonxml::debug("Return message of $temp"); } else { %Apache::lonhomework::history= @@ -1115,13 +1130,13 @@ sub initialize_storage { &check_correctness_changes() is called in two circumstances in which the results hash is to be stored permanently, for grading triggered by a student's submission, where feedback on - correctness is to be provided to the student. + correctness is to be provided to the student. 1. Immediately prior to storing the results hash - To handle the case where a student's submission (and award) were + To handle the case where a student's submission (and award) were stored after history was retrieved in &initialize_storage(), e.g., - if a student submitted answers in quick succession (e.g., from + if a student submitted answers in quick succession (e.g., from multiple tabs). &Apache::inputtags::hidealldata() is called for any parts with out-of-order storage (i.e., correct then incorrect, where awarded >= 1 when correct). @@ -1131,12 +1146,12 @@ sub initialize_storage { To handle the case where lond on the student's homeserver returns delay:N -- where N is the number of transactions between the last retrieved in &initialize_storage() and the last stored immediately - before permanent storage of the current transaction via - lond::store_handler(). &Apache::grades::makehidden() is called + before permanent storage of the current transaction via + lond::store_handler(). &Apache::grades::makehidden() is called for any parts with out-of-order storage (i.e., correct then incorrect, where awarded >= 1 when correct). - Will call &store_aggregates() to increment totals for attempts, + Will call &store_aggregates() to increment totals for attempts, students, and corrects, if running user has student role. =cut @@ -1169,7 +1184,7 @@ sub finalize_storage { my ($map)=&Apache::lonnet::decode_symb($symb); $map = &Apache::lonnet::clutter($map); if ($env{'request.lti.login'}) { - ($passback,$pbscope,$pbmap,$pbsymb,$ltinum,$ltiref) = + ($passback,$pbscope,$pbmap,$pbsymb,$ltinum,$ltiref) = &needs_lti_passback($courseid,$symb,$map); } elsif ($env{'request.deeplink.login'}) { ($passback,$pbscope,$pbmap,$pbsymb,$crsdef,$ltinum,$ltiref) = @@ -1450,13 +1465,13 @@ sub needs_linkprot_passback { =item check_correctness_changes() For all parts for which current results contain a solved status - of "incorrect_attempted", check if there was a transaction in which - solved was set to "correct_by_student" in the time since the last - transaction (retrieved when &initialize_storage() was called i.e., + of "incorrect_attempted", check if there was a transaction in which + solved was set to "correct_by_student" in the time since the last + transaction (retrieved when &initialize_storage() was called i.e., when &start_problem() was called), unless: (a) questiontype parameter is set to survey or anonymous survey (+/- credit) (b) problemstatus is set to no or no_feedback_ever - If such a transaction exists, and did not occur after "reset status" + If such a transaction exists, and did not occur after "reset status" by a user with grading privileges, then the current transaction is an example of an out-of-order transaction (i.e., incorrect occurring after correct). Accordingly, the current transaction should be hidden. @@ -2364,7 +2379,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. @@ -3365,7 +3381,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.=' ';