--- loncom/homework/structuretags.pm 2017/03/14 12:20:57 1.512.2.13 +++ loncom/homework/structuretags.pm 2015/12/03 20:40:27 1.541 @@ -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.13 2017/03/14 12:20:57 raeburn Exp $ +# $Id: structuretags.pm,v 1.541 2015/12/03 20:40:27 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -270,7 +270,7 @@ sub homework_js { $jstimeout = 1000 * $timeout; } return &Apache::loncommon::resize_textarea_js(). - &Apache::loncommon::colorfuleditor_js(). + &Apache::loncommon::colorfuleditor_js(). &setmode_javascript(). <<"JS"; @@ -419,13 +417,9 @@ sub page_start { $extra_head .= &homework_js(). &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); if (&Apache::lonhtmlcommon::htmlareabrowser()) { - my %textarea_args; - if (($env{'request.state'} ne 'construct') || - ($env{'environment.nocodemirror'})) { - %textarea_args = ( + my %textarea_args = ( dragmath => 'math', ); - } $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); } my $is_task = ($env{'request.uri'} =~ /\.task$/); @@ -496,7 +490,9 @@ sub page_start { } } if ($needs_upload) { - $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js(); + $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js() + .''; } } @@ -774,9 +770,7 @@ sub problem_edit_buttons { if ($mode eq 'editxml') { $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); $result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1); - if ($env{'environment.nocodemirror'}) { - $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); - } + $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); } else { $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); $result.=&problem_edit_action_button('subundo','undo','u','Undo',1); @@ -792,9 +786,9 @@ sub problem_edit_header {
'.&mt('Problem Editing').$mode.&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').' -
'. - ''. - &problem_edit_buttons(); +
'. + ''. + &problem_edit_buttons(); $return .= '
' . &Apache::lonxml::message_location(); $return .= ' @@ -822,7 +816,6 @@ sub problem_edit_header { return $return; } - sub problem_edit_footer { my $resource = $env{'request.ambiguous'}; return '
@@ -898,7 +891,7 @@ sub problem_web_to_edit_header { ".&mt("Problem Type:")." '; + if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) { + my $uri = $env{'request.uri'}; + my $daxeurl = '/adm/daxe/daxe.html?config=config/loncapa_config.xml&file=/daxeopen'.$uri. + '&save=/daxesave'; + $result .= ''; + } $result.='
@@ -1018,7 +1018,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= @@ -1041,13 +1041,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). @@ -1057,14 +1057,14 @@ 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, - students, and corrects, if running user has student role. - + students, and corrects, if running user has student role. + =cut @@ -1185,13 +1185,13 @@ sub finalize_storage { =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. @@ -1285,8 +1285,8 @@ sub store_aggregates { } else { $anoncounter{$symb."\0".$part} = 1; } - my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; - if ($needsrelease) { + my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}.':'}; + if ($needsrelease) { my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; if ($curr_required eq '') { &Apache::lonnet::update_released_required($needsrelease); @@ -1319,8 +1319,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'} @@ -1517,6 +1517,7 @@ sub start_problem { my $status; my $accessmsg; my $resource_due; + my $ipused; my $name= &get_resource_name($parstack,$safeeval); my ($result,$form_tag_start,$slot_name,$slot,$probpartlist); @@ -1525,10 +1526,11 @@ 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],$interval[0]); + my ($timelimit) = split(/_/,$interval[0]); + &Apache::lonnet::set_first_access($interval[1],$timelimit); } - ($status,$accessmsg,$slot_name,$slot) = + ($status,$accessmsg,$slot_name,$slot,$ipused) = &Apache::lonhomework::check_slot_access('0','problem'); push (@Apache::inputtags::status,$status); } @@ -1619,7 +1621,8 @@ sub start_problem { ( $status eq 'NOTRESERVABLE') || ( $status eq 'RESERVABLE') || ( $status eq 'RESERVABLE_LATER') || - ( $status eq 'INVALID_ACCESS')) { + ( $status eq 'INVALID_ACCESS') || + ( $status eq 'NEED_DIFFERENT_IP')) { my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser, $style); if ( $target eq "web" ) { @@ -1652,7 +1655,14 @@ sub start_problem { &Apache::lonnavmaps::timeToHumanString($accessmsg,'start')); } elsif ($status eq 'NOTRESERVABLE') { $msg.=&mt('Not available to make a reservation.'); - } + } elsif ($status eq 'NEED_DIFFERENT_IP') { + if ($ipused) { + $msg.=&mt('You must use the same computer ([_1]) you used when you first accessed this resource using your time/place-based reservation.',"IP: $ipused"); + } else { + $msg.=&mt('Each student must use a different computer to access this resource at this time and/or place.').'
'. + &mt('Somebody else has already used this particular computer for that purpose.'); + } + } $result.=$msg.'
'; } elsif ($target eq 'tex') { my $startminipage = ($env{'form.problem_split'}=~/yes/i)? '' @@ -1672,8 +1682,11 @@ sub start_problem { $result .= &Apache::bridgetask::proctor_validation_screen($slot); } elsif ($target eq 'grade') { - &Apache::bridgetask::proctor_check_auth($slot_name,$slot, - 'problem'); + my $checkinresult = &Apache::bridgetask::proctor_check_auth($slot_name,$slot, + 'problem'); + if ($checkinresult = /^error:/) { + $result .= 'error'; + } } } elsif ($target eq 'web') { if ($status eq 'CAN_ANSWER') { @@ -1683,10 +1696,18 @@ sub start_problem { $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"}; + my $needsiptied; + if (ref($slot)) { + $needsiptied = $slot->{'iptied'}; + } + my $check = &Apache::bridgetask::check_in('problem',undef,undef, + $slot_name,$needsiptied); + if ($check =~ /^error: /) { + &Apache::lonnet::logthis("Error during self-checkin of problem (symb: $env{'request.symb'}) using slot: $slot_name"); + } else { + $checked_in = + $Apache::lonhomework::results{"resource.0.checkedin"}; + } } if ((ref($slot) eq 'HASH') && ($checked_in ne '')) { if ($slot->{'starttime'} < time()) { @@ -2891,7 +2912,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'], @@ -2939,13 +2960,9 @@ sub end_startouttext { .''.&mt('Delete?').' ' .&Apache::edit::deletelist($target,$token) .'' - .''; - if ($env{'environment.nocodemirror'}) { - $result.=&Apache::lonhtmlcommon::dragmath_button($areaid,1); - } else { - $result.=' '; - } - $result.='' + .'' + .&Apache::lonhtmlcommon::dragmath_button($areaid,1) + .'' .'' .&Apache::edit::insertlist($target,$token) .''