--- loncom/homework/inputtags.pm 2011/12/08 02:59:34 1.297 +++ loncom/homework/inputtags.pm 2012/12/19 17:35:34 1.312 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.297 2011/12/08 02:59:34 www Exp $ +# $Id: inputtags.pm,v 1.312 2012/12/19 17:35:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,6 +125,37 @@ sub initialize_inputtags { %Apache::inputtags::submission_display=(); } +# +# provides the onblur binding for spellchecking. This could be an +# empty string if spellchecking was not enabled. +# Jquery selector binding is done rather than setting an onblur +# attribute because we'll need to set the element's spellcheck language +# option dynamically so we need $(this) to be defined. +# +# @param id - The element id to bind. +# @param lang - Language in which spellchecking is desired. +# if undef, nothing is generated. +# @return string - onblur specification to do the requested spellchecking. +# +sub spellcheck_onblur { + my ($id, $lang) = @_; + my $result = ''; + if ($lang) { + + $result = < +\$('\#$id').blur(function() { + doSpellcheck('\#$id', '$lang'); + }); + + +JAVASCRIPT + + + } + return $result; +} + sub check_for_duplicate_ids { my %check; foreach my $id (@Apache::inputtags::partlist, @@ -185,7 +216,7 @@ sub start_textfield { } } unless ($newvariation) { - $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); + $oldresponse = $Apache::lonhomework::history{"resource.$partid.$resid.submission"}; } if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval); @@ -194,13 +225,15 @@ sub start_textfield { if ( $rows eq '') { $rows = 16; } my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval); $result=''; + my $tagident = 'HWVAL_' . $resid; if ($addchars) { - $result.=&addchars('HWVAL_'.$resid,$addchars); + $result.=&addchars($tagident, $addchars); } - my $textareaclass = 'class="LC_richDetectHtml"'; - $result.= '"; + my $resid = $Apache::inputtags::response[-1]; + my $tagident = 'HWVAL_' . $resid; + my $result = ""; + $result .= &spellcheck_onblur($tagident, $spellcheck); + return $result; } } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); @@ -330,6 +372,12 @@ sub start_textline { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result = ""; my $input_id = &start_input($parstack,$safeeval); + + # The spellcheck attribute + # 1. enables spellchecking. + # 2. Provides the language code in which the spellchecking will be performed. + + my $spellcheck = &Apache::lonxml::get_param('spellcheck', $parstack, $safeeval); if ($target eq 'web') { $Apache::lonxml::evaluate--; my $partid=$Apache::inputtags::part; @@ -380,8 +428,15 @@ sub start_textline { if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') { $name = "none"; } - $result.= ''; + $result.= ''; + + $result .= &spellcheck_onblur($name, $spellcheck); } if ($Apache::lonhomework::type eq 'exam' && &needs_exam_box($tagstack)) { @@ -400,12 +455,14 @@ sub start_textline { 'addchars',$token,10); $result.=&Apache::edit::select_arg('Readonly:','readonly', ['no','yes'],$token); + $result.=&Apache::edit::select_arg("Spellcheck for: ", 'spellcheck', + ['none', 'en', 'de', 'fr'], $token); $result.=&Apache::edit::end_row(); $result.=&Apache::edit::end_table(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, $safeeval,'size', - 'addchars','readonly'); + 'addchars','readonly', 'spellcheck'); if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } } elsif ($target eq 'tex' && $Apache::lonhomework::type ne 'exam') { @@ -576,8 +633,20 @@ sub file_selector { if ( $which eq 'both') { $result.='
'.''.&mt('OR:').'
'; } - if ($which eq 'portfolioonly' || $which eq 'both') { - $result.=$extratext.''. + if ($which eq 'portfolioonly' || $which eq 'both') { + my $symb = $env{'request.symb'}; + (undef,undef,my $res)=&Apache::lonnet::decode_symb($symb); + my $showsymb; + # If resource is a .task and URL is unencrypted, include symb in query string + # for url opened in portfolio file selection window. Can be used to override + # blocking of portfolio access resulting from an exam event in a different course. + if ($res =~ /\.task$/i) { + my $encsymb = &Apache::lonenc::check_encrypt($symb); + if ($symb eq $encsymb) { + $showsymb = $symb; + } + } + $result.=$extratext.''. &mt('Select Portfolio Files: (one or more files per submission)').'
'. ''. '
'; @@ -676,9 +745,11 @@ sub current_file_submissions { } } if ($header_shown) { - $result .= &Apache::loncommon::end_data_table(). - '
'. - &mt('Exclude existing file(s) from grading by checking the "Delete?" checkbox(es) and clicking "Submit Answer"').''; + $result .= &Apache::loncommon::end_data_table(); + if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { + $result .= '
'. + &mt('Exclude existing file(s) from grading by checking the "Delete?" checkbox(es) and clicking "Submit Answer"').''; + } } if (@bad_file_list) { my $bad_files = ''. @@ -843,26 +914,6 @@ sub finalizeawards { } } -sub grading_is_nonlenient { - my ($part) = @_; -# Web mode: we are non-lenient unless told otherwise - my $defaultparm = 'off'; - my $nonlenient = 0; -# Grading a bubblesheet exam: we are grading lenient unless told otherwise - if ($Apache::lonhomework::scantronmode) { - $defaultparm = 'on'; - $nonlenient = 1; - } - my $lenientparm = - &Apache::response::get_response_param($part,'lenient',$defaultparm); - if ($lenientparm=~/^0|off|no$/i) { - $nonlenient = 1; - } elsif ($lenientparm=~/^1|on|yes$/i) { - $nonlenient = 0; - } - return $nonlenient; -} - sub decideoutput { my ($award,$awarded,$awardmsg,$solved,$previous,$target,$nocorrect)=@_; @@ -931,11 +982,11 @@ sub decideoutput { } } } - if (&grading_is_nonlenient($part)) { + if ($awarded >= 1) { $button=0; - } elsif ($awarded==1) { + } elsif (&Apache::lonnet::EXT("resource.$part.retrypartial") !~/^1|on|yes$/i) { $button=0; - } else { + } else { $button=1; } $previousmsg=''; @@ -1096,6 +1147,7 @@ sub decideoutput { } elsif ($award eq 'ANONYMOUS_CREDIT') { $message = &mt("Your anonymous submission has been recorded, and credit awarded."); $css_class=$possible_class{'correct'}; + $button=1; } elsif ($award eq 'DRAFT') { $message = &mt("Copy saved but not submitted."); $css_class=$possible_class{'not_charged_try'}; @@ -1146,7 +1198,17 @@ sub decideoutput { if (&Apache::lonhomework::hide_problem_status() && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER' && &hide_award($award)) { - $message = &mt("Answer Submitted: Your final submission will be graded after the due date."); + $message = &mt("Answer Submitted: Your final submission will be graded after the due date."); + my @interval= &Apache::lonnet::EXT("resource.$part.interval"); + if ($interval[0] =~ /\d+/) { + my $first_access=&Apache::lonnet::get_first_access($interval[1]); + if (defined($first_access)) { + my $due_date= &Apache::lonnet::EXT("resource.$part.duedate"); + unless (($due_date) && ($due_date < $first_access + $interval[0])) { + $message = &mt("Answer Submitted: Your final submission will be graded when the time limit is reached."); + } + } + } $css_class=$possible_class{'no_grade'}; $button=1; } @@ -1514,12 +1576,19 @@ sub gradestatus { && $status ne 'UNAVAILABLE' && $status ne 'INVALID_ACCESS' && $status ne 'NEEDS_CHECKIN' - && $status ne 'NOT_IN_A_SLOT') { + && $status ne 'NOT_IN_A_SLOT' + && $status ne 'RESERVABLE' + && $status ne 'RESERVABLE_LATER' + && $status ne 'NOTRESERVABLE') { + + if ($status eq 'SHOW_ANSWER') { + $showbutton = 0; + } ($previousmsg,$latemessage,$message,$trystr) = &get_grade_messages($id,"resource.$id",$target,$status, $showbutton); - if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') { + if ($status eq 'CANNOT_ANSWER') { $showbutton = 0; } if ( $status eq 'SHOW_ANSWER') { @@ -1647,27 +1716,14 @@ sub previous_tries { ''.''.&mt('Submission #').''.&mt('Try'). ''. &mt('Submitted Answer').''; - $output =&Apache::loncommon::start_scrollbox('420px','400px','400px'). - ''.$headers.$output.'
'. - &Apache::loncommon::end_scrollbox(); - #return $output; - $output = &Apache::loncommon::js_ready($output); + $output =''.$headers.$output.'
'; my $tries_text = &get_tries_text('link'); - my $start_page = - &Apache::loncommon::start_page($tries_text, undef, - {'only_body' => 1, - 'bgcolor' => '#FFFFFF', - 'js_ready' => 1, - 'inherit_jsmath' => 1, }); - my $end_page = - &Apache::loncommon::end_page({'js_ready' => 1,}); my $prefix = $env{'form.request.prefix'}; $prefix =~ tr{.}{_}; my $function_name = "LONCAPA_previous_tries_".$prefix. $Apache::lonxml::curdepth.'_'.$env{'form.counter'}; - my $result = &Apache::loncommon::modal_adhoc_script($function_name,420,410,$start_page.$output.$end_page). - "".&mt($tries_text)."
"; + my $result = &Apache::loncommon::modal_adhoc_window($function_name,420,410,$output,&mt($tries_text))."
"; return $result; }