--- loncom/homework/structuretags.pm 2012/05/28 20:31:11 1.507 +++ loncom/homework/structuretags.pm 2014/11/21 18:04:57 1.523 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.507 2012/05/28 20:31:11 raeburn Exp $ +# $Id: structuretags.pm,v 1.523 2014/11/21 18:04:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -254,6 +254,55 @@ function image_response_click (which, e) input_element.value = click; img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; } + +var submithandled = 0; +var keypresshandled = 0; + +$(document).ready(function(){ + + $(document).keypress(function(event){ + var keycode = (event.keyCode ? event.keyCode : event.which); + if ((keycode == '13') && (keypresshandled == 0)) { + if ( $( document.activeElement ).hasClass("LC_textline") ) { + keypresshandled = 1; + var idsArray = $( document.activeElement ).attr("id").split(/HWVAL_/); + if (idsArray.length) { + event.preventDefault(); + var itemsArray = idsArray[1].split(/_/); + var buttonId = idsArray[0]+'submit_'+itemsArray[0]; + $("#"+buttonId).trigger("click"); + } + } + } + }); + + $(document).delegate('form :submit', 'click', function( event ) { + if ( $( this ).hasClass( "LC_hwk_submit" ) ) { + var buttonId = this.id; + if (submithandled == 0) { + submithandled = 1; + $( "#msg_"+buttonId ).css({"display": "inline","background-color": "#87cefa", + "color": "black","padding": "2px"}) ; + if (( $(this.form).id == "LC_page" ) && ($('input[name="all_submit"]').length )) { + if (buttonId != "all_submit") { + $( ".LC_status_"+buttonId ).hide(); + if (( "#"+buttonId+"_pressed" ).length) { + $( "#"+buttonId+"_pressed" ).val( "1" ); + } + } + } else { + $( ".LC_status_"+buttonId ).hide(); + } + $(this.form).submit(); + $( ".LC_hwk_submit" ).prop( "disabled", true); + $( ".LC_textline" ).prop( "readonly", "readonly"); + event.preventDefault(); + return true; + } + } + }); +}); + // ]]> JS @@ -379,10 +428,10 @@ sub page_start { } elsif (!defined($found{'body'}) && $env{'request.state'} eq 'construct') { if ($target eq 'web' || $target eq 'edit') { - # Breadcrumbs for Construction Space + # Breadcrumbs for Authoring Space &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', + 'text' => 'Authoring Space', 'href' => &Apache::loncommon::authorspace($env{'request.uri'}), }); # breadcrumbs (and tools) will be created @@ -414,6 +463,8 @@ sub page_start { $body_args{'add_entries'} = \%add_entries; if ( $env{'request.state'} eq 'construct') { $body_args{'only_body'} = 1; + } elsif ($target eq 'web') { + $body_args{'print_suppress'} = 1; } } $body_args{'no_auto_mt_title'} = 1; @@ -453,7 +504,6 @@ sub page_start { } $form_tag_start.='>'."\n"; - my $symb=&Apache::lonnet::symbread(); if ($symb =~ /\S/) { $symb= &HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb)); @@ -638,7 +688,7 @@ sub problem_edit_header { '.&Apache::lonxml::message_location().' '. - '
'; + '' - .'' + .'' .'' - .'
'; } sub problem_edit_footer { @@ -711,7 +761,7 @@ sub problem_web_to_edit_header { ".&mt("Problem Type:")." ".&option('yes','problemstatus').&mt("Show Feedback")." - ".&option('no', 'problemstatus').&mt("Don't Show Incorect/Correct Feedback")." + ".&option('no', 'problemstatus').&mt("Don't Show Incorrect/Correct Feedback")." ".&option('no_feedback_ever', 'problemstatus').&mt("Don't Show Any Feedback")." @@ -847,9 +897,9 @@ sub initialize_storage { =item finalize_storage() - Stores away the result has to a student's environment - checks form.grade_ for specific values, other wises stores - to the running users environment + Stores away the result hash to a student's environment + checks form.grade_ for specific values, otherwise stores + to the running user's environment. Will increment totals for attempts, students, and corrects if running user has student role. @@ -967,8 +1017,8 @@ sub checkout_msg { 'resource'=>'The resource needs to be checked out', 'id_expln'=>'As a resource gets checked out, a unique timestamped ID is given to it, and a permanent record is left in the system.', 'warning'=>'Checking out resources is subject to course policies, and may exclude future credit even if done erroneously.', - 'checkout'=>'Check out Exam for Viewing', - 'checkout?'=>'Check out Exam?'); + 'checkout'=>'Check out Bubblesheet Exam for Viewing', + 'checkout?'=>'Check out Bubblesheet Exam?'); my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); return (<$lt{'resource'} @@ -976,7 +1026,7 @@ sub checkout_msg {

$lt{'warning'}

- +
ENDCHECKOUT } @@ -1010,7 +1060,7 @@ sub firstaccess_msg { $result .= (< - + ENDCHECKOUT return $result; @@ -1160,6 +1210,7 @@ sub start_problem { &Apache::run::run($expression,$safeeval); my $status; my $accessmsg; + my $resource_due; my $name= &get_resource_name($parstack,$safeeval); my ($result,$form_tag_start,$slot_name,$slot); @@ -1168,7 +1219,7 @@ sub start_problem { $target eq 'tex') { if ($env{'form.markaccess'}) { my @interval=&Apache::lonnet::EXT("resource.0.interval"); - &Apache::lonnet::set_first_access($interval[1]); + &Apache::lonnet::set_first_access($interval[1],$interval[0]); } ($status,$accessmsg,$slot_name,$slot) = @@ -1189,14 +1240,6 @@ sub start_problem { if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { - if ($status eq 'CAN_ANSWER') { - my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'}); - my $time_left = $resource_due - time(); - if ($resource_due && ($time_left > 0) && ($target eq 'web')) { - $result .= &Apache::lonhtmlcommon::set_due_date($resource_due); - } - } - #handle rand seed in construction space my $rndseed=&setup_rndseed($safeeval,$target); my ($symb)=&Apache::lonnet::whichuser(); @@ -1305,13 +1348,35 @@ sub start_problem { 'problem'); } } elsif ($target eq 'web') { - if ($status eq 'CAN_ANSWER' - && $slot_name ne '' - && $Apache::lonhomework::history{'resource.0.checkedin'} eq '') { - # unproctored slot access, self checkin - &Apache::bridgetask::check_in('problem',undef,undef, - $slot_name); - } + 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'}; + } + } + } + } + if ($resource_due) { + my $time_left = $resource_due - time(); + if ($resource_due && ($time_left > 0) && ($target eq 'web')) { + $result .= &Apache::lonhtmlcommon::set_due_date($resource_due); + } + } + } $result.="\n $form_tag_start \t". ''; # create a page header and exit @@ -2043,9 +2108,15 @@ sub end_while { } $return = &Apache::run::run($code,$safeeval); } - if ($error) { - &Apache::lonxml::error('
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occurred while running <while> on line').' '.$line.'
'); - } + if ($error) { + &Apache::lonxml::error( + '
'
+               .&mt('Code ran too long. It ran for more than [_1] seconds.',
+                        $Apache::lonnet::perlvar{'lonScriptTimeout'})
+               .&mt('This occurred while running <while> on line [_1].',
+                        $line)
+               .'
'); + } } elsif ($target eq "edit") { $result.= &Apache::edit::tag_end($target,$token,''); } @@ -2482,7 +2553,7 @@ sub start_problemtype { ['hide','Hide']] ,$token); $result .=&Apache::edit::checked_arg('When used as type(s):','for', - [ ['exam','Exam/Quiz Problem'], + [ ['exam','Bubblesheet Exam/Quiz Problem'], ['survey','Survey'], ['surveycred','Survey (with credit)'], ['anonsurvey','Anonymous Survey'], @@ -2529,13 +2600,13 @@ sub end_startouttext { .'
'.&mt('Delete?').' ' .&Apache::edit::deletelist($target,$token) .'' + .'' .&Apache::lonhtmlcommon::dragmath_button($areaid,1) - .'' .&Apache::edit::insertlist($target,$token) .'' . + .'' . &Apache::loncommon::helpLatexCheatsheet(). &Apache::edit::end_row(). &Apache::edit::start_spanning_row()."\n".