--- loncom/homework/grades.pm 2022/02/09 23:50:00 1.596.2.12.2.60 +++ loncom/homework/grades.pm 2012/08/09 23:25:48 1.596.2.13 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.596.2.12.2.60 2022/02/09 23:50:00 raeburn Exp $ +# $Id: grades.pm,v 1.596.2.13 2012/08/09 23:25:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,11 +43,7 @@ use Apache::lonmsg(); use Apache::Constants qw(:common :http); use Apache::lonlocal; use Apache::lonenc; -use Apache::lonstathelpers; use Apache::bridgetask(); -use Apache::lontexconvert(); -use HTML::Parser(); -use File::MMagic; use String::Similarity; use LONCAPA; @@ -102,9 +98,6 @@ sub ssi_print_error { # # --- Retrieve the parts from the metadata file.--- -# Returns an array of everything that the resources stores away -# - sub getpartlist { my ($symb,$errorref) = @_; @@ -129,6 +122,21 @@ sub getpartlist { return @stores; } +# --- Get the symbolic name of a problem and the url +sub get_symb { + my ($request,$silent) = @_; + (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; + my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url))); + if ($symb eq '') { + if (!$silent) { + $request->print(&mt("Unable to handle ambiguous references: [_1].",$url)); + return (); + } + } + &Apache::lonenc::check_decrypt(\$symb); + return ($symb); +} + #--- Format fullname, username:domain if different for display #--- Use anywhere where the student names are listed sub nameUserString { @@ -143,8 +151,6 @@ sub nameUserString { #--- Get the partlist and the response type for a given problem. --- #--- Indicate if a response type is coded handgraded or not. --- -#--- Count responseIDs, essayresponse items, and dropbox items --- -#--- Sets response_error pointer to "1" if navmaps object broken --- sub response_type { my ($symb,$response_error) = @_; @@ -161,7 +167,6 @@ sub response_type { return; } my $partlist = $res->parts(); - my ($numresp,$numessay,$numdropbox) = (0,0,0); my %vPart = map { $_ => 1 } (&Apache::loncommon::get_env_multiple('form.vPart')); my (%response_types,%handgrade); @@ -171,20 +176,13 @@ sub response_type { my @types = $res->responseType($part); my @ids = $res->responseIds($part); for (my $i=0; $i < scalar(@ids); $i++) { - $numresp ++; $response_types{$part}{$ids[$i]} = $types[$i]; - if ($types[$i] eq 'essay') { - $numessay ++; - if (&Apache::lonnet::EXT("resource.$part".'_'.$ids[$i].".uploadedfiletypes",$symb)) { - $numdropbox ++; - } - } $handgrade{$part.'_'.$ids[$i]} = &Apache::lonnet::EXT('resource.'.$part.'_'.$ids[$i]. '.handgrade',$symb); } } - return ($partlist,\%handgrade,\%response_types,$numresp,$numessay,$numdropbox); + return ($partlist,\%handgrade,\%response_types); } sub flatten_responseType { @@ -211,127 +209,53 @@ sub get_display_part { return $display; } -#--- Show parts and response type +#--- Show resource title +#--- and parts and response type sub showResourceInfo { - my ($symb,$partlist,$responseType,$formname,$checkboxes,$uploads) = @_; - unless ((ref($partlist) eq 'ARRAY') && (ref($responseType) eq 'HASH')) { - return '
'; - } - my $coltitle = &mt('Problem Part Shown'); - if ($checkboxes) { - $coltitle = &mt('Problem Part'); - } else { - my $checkedparts = 0; - foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) { - if (grep(/^\Q$partid\E$/,@{$partlist})) { - $checkedparts ++; - } - } - if ($checkedparts == scalar(@{$partlist})) { - return '
'; - } - if ($uploads) { - $coltitle = &mt('Problem Part Selected'); + my ($symb,$probTitle,$checkboxes,$res_error) = @_; + my $result = '

'.&mt('Current Resource').': '.$probTitle.'

'."\n"; + my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error); + if (ref($res_error)) { + if ($$res_error) { + return; } } - my $result = '
'; - if ($checkboxes) { - my $legend = &mt('Parts to display'); - if ($uploads) { - $legend = &mt('Part(s) with dropbox'); - } - $result .= '
'.$legend.''. - ''. - ''.(' 'x2). - ''. - '
'; - } - $result .= '
'; - if (!keys(%partsseen)) { - $result = ''; - if ($uploads) { - return '
'. - '

'. - &mt('No dropbox items or essayresponse items with uploadedfiletypes set.'). - '

'; - } else { - return '
'; - } - } - return $result; -} - -sub part_selector_js { - my $js = <<"END"; -function toggleParts(formname) { - if (document.getElementById('LC_partselector')) { - var index = ''; - if (document.forms.length) { - for (var i=0; i 1)) { - for (var i=0; i $env{'request.course.id'}, 'grade_username' => $uname, 'grade_noincrement' => $no_increment); - if ($bubbles_per_row ne '') { - $form{'bubbles_per_row'} = $bubbles_per_row; - } if ($type eq 'randomizetry') { $form{'grade_questiontype'} = $type; if ($rndseed ne '') { @@ -427,7 +348,7 @@ sub reset_caches { } sub scantron_partids_tograde { - my ($resource,$cid,$uname,$udom,$check_for_randomlist,$bubbles_per_row,$scancode) = @_; + my ($resource,$cid,$uname,$udom,$check_for_randomlist) = @_; my (%analysis,@parts); if (ref($resource)) { my $symb = $resource->symb(); @@ -435,16 +356,7 @@ sub reset_caches { if ($check_for_randomlist) { $add_to_form = { 'check_parts_withrandomlist' => 1,}; } - if ($scancode) { - if (ref($add_to_form) eq 'HASH') { - $add_to_form->{'code_for_randomlist'} = $scancode; - } else { - $add_to_form = { 'code_for_randomlist' => $scancode,}; - } - } - my $analyze = - &get_analyze($symb,$uname,$udom,undef,$add_to_form, - undef,undef,undef,$bubbles_per_row); + my $analyze = &get_analyze($symb,$uname,$udom,undef,$add_to_form); if (ref($analyze) eq 'HASH') { %analysis = %{$analyze}; } @@ -471,8 +383,6 @@ sub cleanRecord { my $grayFont = ''; if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); - my @answer = %answer; - %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my ($toprow,$bottomrow); foreach my $foil (@$order) { @@ -489,8 +399,6 @@ sub cleanRecord { $bottomrow.''; } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); - my @answer = %answer; - %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my @items=&Apache::lonnet::str2array($record->{$version."resource.$partid.$respid.submissionitems"}); my ($toprow,$middlerow,$bottomrow); @@ -513,8 +421,6 @@ sub cleanRecord { $bottomrow.''; } elsif ($response eq 'radiobutton') { my %answer=&Apache::lonnet::str2hash($answer); - my @answer = %answer; - %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my ($toprow,$bottomrow); my $correct = &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed); @@ -547,11 +453,10 @@ sub cleanRecord { $env{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : ''; $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob. } - $answer = &Apache::lontexconvert::msgtexconverted($answer); + $answer =~ s-\n-
-g; return '

'.&keywords_highlight($answer).'
'; } elsif ( $response eq 'organic') { - my $result=&mt('Smile representation: [_1]', - '"'.&HTML::Entities::encode($answer, '"<>&').'"'); + my $result='Smile representation: "'.$answer.'"'; my $jme=$record->{$version."resource.$partid.$respid.molecule"}; $result.=&Apache::chemresponse::jme_img($jme,$answer,400); return $result; @@ -585,20 +490,19 @@ sub cleanRecord { $result.=''; return $result; } - } elsif ( $response =~ m/(?:numerical|formula|custom)/) { - # Respect multiple input fields, see Bug #5409 + } elsif ( $response =~ m/(?:numerical|formula)/) { $answer = &Apache::loncommon::format_previous_attempt_value('submission', $answer); - return $answer; } - return &HTML::Entities::encode($answer, '"<>&'); + return $answer; } #-- A couple of common js functions sub commonJSfunctions { my $request = shift; - $request->print(&Apache::lonhtmlcommon::scripttag(<print(< function radioSelection(radioButton) { var selection=null; if (radioButton.length > 1) { @@ -626,13 +530,14 @@ sub commonJSfunctions { return selectOne.value; } } + COMMONJSFUNCTIONS } #--- Dumps the class list with usernames,list of sections, #--- section, ids and fullnames for each user. sub getclasslist { - my ($getsec,$filterbyaccstatus,$getgroup,$symb,$submitonly,$filterbysubmstatus) = @_; + my ($getsec,$filterlist,$getgroup) = @_; my @getsec; my @getgroup; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); @@ -660,13 +565,6 @@ sub getclasslist { # my %sections; my %fullnames; - my ($cdom,$cnum,$partlist); - if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) { - $cdom = $env{"course.$env{'request.course.id'}.domain"}; - $cnum = $env{"course.$env{'request.course.id'}.num"}; - my $res_error; - ($partlist) = &response_type($symb,\$res_error); - } foreach my $student (keys(%$classlist)) { my $end = $classlist->{$student}->[&Apache::loncoursedata::CL_END()]; @@ -683,7 +581,7 @@ sub getclasslist { my $group = $classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()]; # filter students according to status selected - if ($filterbyaccstatus && (!($stu_status =~ /Any/))) { + if ($filterlist && (!($stu_status =~ /Any/))) { if (!($stu_status =~ $status)) { delete($classlist->{$student}); next; @@ -700,58 +598,13 @@ sub getclasslist { } } if (($grp eq 'none') && !$group) { - $exclude = 0; + $exclude = 0; } } if ($exclude) { delete($classlist->{$student}); - next; } } - if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) { - my $udom = - $classlist->{$student}->[&Apache::loncoursedata::CL_SDOM()]; - my $uname = - $classlist->{$student}->[&Apache::loncoursedata::CL_SNAME()]; - if (($symb ne '') && ($udom ne '') && ($uname ne '')) { - if ($submitonly eq 'queued') { - my %queue_status = - &Apache::bridgetask::get_student_status($symb,$cdom,$cnum, - $udom,$uname); - if (!defined($queue_status{'gradingqueue'})) { - delete($classlist->{$student}); - next; - } - } else { - my (%status) =&student_gradeStatus($symb,$udom,$uname,$partlist); - my $submitted = 0; - my $graded = 0; - my $incorrect = 0; - foreach (keys(%status)) { - $submitted = 1 if ($status{$_} ne 'nothing'); - $graded = 1 if ($status{$_} =~ /^ungraded/); - $incorrect = 1 if ($status{$_} =~ /^incorrect/); - - my ($foo,$partid,$foo1) = split(/\./,$_); - if ($status{'resource.'.$partid.'.submitted_by'} ne '') { - $submitted = 0; - } - } - if (!$submitted && ($submitonly eq 'yes' || - $submitonly eq 'incorrect' || - $submitonly eq 'graded')) { - delete($classlist->{$student}); - next; - } elsif (!$graded && ($submitonly eq 'graded')) { - delete($classlist->{$student}); - next; - } elsif (!$incorrect && $submitonly eq 'incorrect') { - delete($classlist->{$student}); - next; - } - } - } - } $section = ($section ne '' ? $section : 'none'); if (&canview($section)) { if (!@getsec || grep(/^\Q$section\E$/,@getsec)) { @@ -766,6 +619,7 @@ sub getclasslist { delete($classlist->{$student}); } } + my %seen = (); my @sections = sort(keys(%sections)); return ($classlist,\@sections,\%fullnames); } @@ -781,7 +635,7 @@ sub canmodify { #can modify the requested section return 1; } else { - # can't modify the requested section + # can't modify the request section return 0; } } @@ -794,19 +648,19 @@ sub canview { my ($sec)=@_; if ($perm{'vgr'}) { if (!defined($perm{'vgr_section'})) { - # can view whole class + # can modify whole class return 1; } else { if ($sec eq $perm{'vgr_section'}) { - #can view the requested section + #can modify the requested section return 1; } else { - # can't view the requested section + # can't modify the request section return 0; } } } - #can't view + #can't modify return 0; } @@ -831,15 +685,17 @@ sub student_gradeStatus { sub jscriptNform { my ($symb) = @_; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); - my $jscript= &Apache::lonhtmlcommon::scripttag( + my $jscript=''."\n"; $jscript.= '
'."\n". ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -933,31 +789,22 @@ sub most_similar { #------------------------------------ Receipt Verification Routines # - -sub initialverifyreceipt { - my ($request,$symb) = @_; - &commonJSfunctions($request); - return ''. - &Apache::lonnet::recprefix($env{'request.course.id'}). - '-'. - ''."\n". - ''. - "
\n"; -} - #--- Check whether a receipt number is valid.--- sub verifyreceipt { - my ($request,$symb) = @_; + my $request = shift; my $courseid = $env{'request.course.id'}; my $receipt = &Apache::lonnet::recprefix($courseid).'-'. $env{'form.receipt'}; $receipt =~ s/[^\-\d]//g; + my ($symb) = &get_symb($request); - my $title = + my $title.= '

'. - &mt('Verifying Receipt Number [_1]',$receipt). - '

'."\n"; + &mt('Verifying Receipt No. [_1]',$receipt). + '
'."\n". + '

'.&mt('Resource: [_1]',$env{'form.probTitle'}). + '

'."\n"; my ($string,$contents,$matches) = ('','',0); my (undef,undef,$fullname) = &getclasslist('all','0'); @@ -1027,7 +874,7 @@ sub verifyreceipt { $contents. &Apache::loncommon::end_data_table()."\n"; } - return $string; + return $string.&show_grading_menu_form($symb); } #--- This is called by a number of programs. @@ -1035,37 +882,30 @@ sub verifyreceipt { #--- Also called directly when one clicks on the subm button # on the problem page. sub listStudents { - my ($request,$symb,$submitonly,$divforres) = @_; + my ($request) = shift; + my ($symb) = &get_symb($request); my $cdom = $env{"course.$env{'request.course.id'}.domain"}; my $cnum = $env{"course.$env{'request.course.id'}.num"}; my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'}; my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'}; - unless ($submitonly) { - $submitonly = $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; - } + my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; + my $viewgrade = $env{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View'; + $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? + &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'}; + + my $result='

 ' + .&mt("$viewgrade Submissions for a Student or a Group of Students") + .'

'; - my $result=''; - my $res_error; - my ($partlist,$handgrade,$responseType,$numresp,$numessay) = &response_type($symb,\$res_error); + my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); - my $table; - if (ref($partlist) eq 'ARRAY') { - if (scalar(@$partlist) > 1 ) { - $table = &showResourceInfo($symb,$partlist,$responseType,'gradesub',1); - } elsif ($divforres) { - $table = '
'; - } else { - $table = '
'; - } - } - - my %js_lt = &Apache::lonlocal::texthash ( + my %lt = &Apache::lonlocal::texthash ( 'multiple' => 'Please select a student or group of students before clicking on the Next button.', 'single' => 'Please select the student before clicking on the Next button.', ); - &js_escape(\%js_lt); - $request->print(&Apache::lonhtmlcommon::scripttag(<print(< function checkSelect(checkBox) { var ctr=0; var sense=""; @@ -1075,12 +915,12 @@ sub listStudents { ctr++; } } - sense = '$js_lt{'multiple'}'; + sense = '$lt{'multiple'}'; } else { if (checkBox.checked) { ctr = 1; } - sense = '$js_lt{'single'}'; + sense = '$lt{'single'}'; } if (ctr == 0) { alert(sense); @@ -1094,14 +934,17 @@ sub listStudents { formname.command.value = 'submission'; formname.submit(); } + LISTJAVASCRIPT &commonJSfunctions($request); $request->print($result); + my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : ''; + my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : ''; my $gradeTable='
'. "\n".$table; - + $gradeTable .= &Apache::lonhtmlcommon::start_pick_box(); $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text')) .''."\n" @@ -1114,102 +957,66 @@ LISTJAVASCRIPT .'
'."\n" .&Apache::lonhtmlcommon::row_closure(); + my $submission_options; + if ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) { + $submission_options.= + ''."\n"; + } my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); my $saveStatus = $stu_status eq '' ? 'Active' : $stu_status; $env{'form.Status'} = $saveStatus; - my %optiontext = &Apache::lonlocal::texthash ( - lastonly => 'last submission', - last => 'last submission with details', - datesub => 'all submissions', - all => 'all submissions with details', - ); - my $submission_options = + $submission_options.= ''. - ''."\n". + ''."\n". ''. ''."\n". + &mt('last submission & parts info').' '."\n". ''. - ''."\n". + ''."\n". ''. ''; - my ($compmsg,$nocompmsg); - $nocompmsg = ' checked="checked"'; - if ($numessay) { - $compmsg = $nocompmsg; - $nocompmsg = ''; - } + &mt('all details').''; $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Submissions')) - .$submission_options; -# Check if any gradable - my $showmore; - if ($perm{'mgr'}) { - my @sections; - if ($env{'request.course.sec'} ne '') { - @sections = ($env{'request.course.sec'}); - } elsif ($env{'form.section'} eq '') { - @sections = ('all'); - } else { - @sections = &Apache::loncommon::get_env_multiple('form.section'); - } - if (grep(/^all$/,@sections)) { - $showmore = 1; - } else { - foreach my $sec (@sections) { - if (&canmodify($sec)) { - $showmore = 1; - last; - } - } - } - } - - if ($showmore) { - $gradeTable .= - &Apache::lonhtmlcommon::row_closure() - .&Apache::lonhtmlcommon::row_title(&mt('Send Messages')) - .'' - .'' - .'' + .$submission_options .&Apache::lonhtmlcommon::row_closure(); - $gradeTable .= - &Apache::lonhtmlcommon::row_title(&mt('Grading Increments')) + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Grading Increments')) .''; - } + .'' + .&Apache::lonhtmlcommon::row_closure(); + $gradeTable .= &build_section_inputs(). ''."\n". + '
'."\n". + '
'."\n". + ''."\n". + ''."\n". ''."\n". ''."\n"; - if (exists($env{'form.Status'})) { - $gradeTable .= ''."\n"; + + if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) { + $gradeTable .= ''."\n"; } else { - $gradeTable .= &Apache::lonhtmlcommon::row_closure() - .&Apache::lonhtmlcommon::row_title(&mt('Student Status')) + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Student Status')) .&Apache::lonhtmlcommon::StatusOptions( - $saveStatus,undef,1,'javascript:reLoadList(this.form);'); + $saveStatus,undef,1,'javascript:reLoadList(this.form);') + .&Apache::lonhtmlcommon::row_closure(); } - if ($numessay) { - $gradeTable .= &Apache::lonhtmlcommon::row_closure() - .&Apache::lonhtmlcommon::row_title(&mt('Check For Plagiarism')) - .''; - } - $gradeTable .= &Apache::lonhtmlcommon::row_closure(1) + + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Check For Plagiarism')) + .'' + .&Apache::lonhtmlcommon::row_closure(1) .&Apache::lonhtmlcommon::end_pick_box(); $gradeTable .= '

' - .&mt("To view/grade/regrade a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n" + .&mt('To '.lc($viewgrade)." a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n" .'' .'

'; @@ -1226,7 +1033,9 @@ LISTJAVASCRIPT while ($loop < 2) { $gradeTable.=''.&mt('No.').''.&mt('Select').''. ''.&nameUserString('header').' '.&mt('Section/Group').''; - if (($submitonly ne 'queued') && ($submitonly ne 'all')) { + if ($env{'form.showgrading'} eq 'yes' + && $submitonly ne 'queued' + && $submitonly ne 'all') { foreach my $part (sort(@$partlist)) { my $display_part= &get_display_part((split(/_/,$part))[0],$symb); @@ -1262,7 +1071,9 @@ LISTJAVASCRIPT $status{'gradingqueue'} = $queue_status{'gradingqueue'}; } - if (($submitonly ne 'queued') && ($submitonly ne 'all')) { + if ($env{'form.showgrading'} eq 'yes' + && $submitonly ne 'queued' + && $submitonly ne 'all') { (%status) =&student_gradeStatus($symb,$udom,$uname,$partlist); my $submitted = 0; my $graded = 0; @@ -1303,7 +1114,7 @@ LISTJAVASCRIPT &nameUserString(undef,$$fullname{$student},$uname,$udom). ' '.$section.($group ne '' ?'/'.$group:'').''."\n"; - if ($submitonly ne 'all') { + if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { foreach (sort(keys(%status))) { next if ($_ =~ /^resource.*?submitted_by$/); $gradeTable.=' '.&mt($status{$_}).' '."\n"; @@ -1317,7 +1128,9 @@ LISTJAVASCRIPT } if ($ctr%2 ==1) { $gradeTable.='   '; - if (($submitonly ne 'queued') && ($submitonly ne 'all')) { + if ($env{'form.showgrading'} eq 'yes' + && $submitonly ne 'queued' + && $submitonly ne 'all') { foreach (@$partlist) { $gradeTable.=' '; } @@ -1341,13 +1154,14 @@ LISTJAVASCRIPT if ($submitonly eq 'graded' ) { $submissions = 'ungraded submissions'; } if ($submitonly eq 'queued' ) { $submissions = 'queued submissions'; } $gradeTable='
 '. - &mt('No '.$submissions.' found for this resource for any students. ([quant,_1,student] checked for '.$submissions.')', + &mt('No '.$submissions.' found for this resource for any students. ([_1] students checked for '.$submissions.')', $num_students). '
'; } } elsif ($ctr == 1) { $gradeTable =~ s/type="checkbox"/type="checkbox" checked="checked"/; } + $gradeTable.=&show_grading_menu_form($symb); $request->print($gradeTable); return ''; } @@ -1355,8 +1169,8 @@ LISTJAVASCRIPT #---- Called from the listStudents routine sub check_script { - my ($form,$type) = @_; - my $chkallscript = &Apache::lonhtmlcommon::scripttag(' + my ($form, $type)=@_; + my $chkallscript=''."\n"; return $chkallscript; } @@ -1401,7 +1215,7 @@ sub check_buttons { # Displays the submissions for one student or a group of students sub processGroup { - my ($request,$symb) = @_; + my ($request) = shift; my $ctr = 0; my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo'); my $total = scalar(@stuchecked)-1; @@ -1411,7 +1225,7 @@ sub processGroup { $env{'form.student'} = $uname; $env{'form.userdom'} = $udom; $env{'form.fullname'} = $fullname; - &submission($request,$ctr,$total,$symb); + &submission($request,$ctr,$total); $ctr++; } return ''; @@ -1425,9 +1239,9 @@ sub processGroup { #--- Javascript to handle the submission page functionality --- sub sub_page_js { my $request = shift; - my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = '); - &js_escape(\$alertmsg); - $request->print(&Apache::lonhtmlcommon::scripttag(< + my $inner_js_msg_central=< function checkInput() { opener.document.SCORE.msgsub.value = opener.checkEntities(document.msgcenter.msgsub.value); var nmsg = opener.document.SCORE.savemsgN.value; @@ -1633,22 +1457,48 @@ sub sub_grademessage_js { self.close() } + +INNERJS + + my $inner_js_highlight_central=< + function updateChoice(flag) { + opener.document.SCORE.kwclr.value = opener.radioSelection(document.hlCenter.kwdclr); + opener.document.SCORE.kwsize.value = opener.radioSelection(document.hlCenter.kwdsize); + opener.document.SCORE.kwstyle.value = opener.radioSelection(document.hlCenter.kwdstyle); + opener.document.SCORE.refresh.value = "on"; + if (opener.document.SCORE.keywords.value!=""){ + opener.document.SCORE.submit(); + } + self.close() + } INNERJS - my $start_page_msg_central = + my $start_page_msg_central = &Apache::loncommon::start_page('Message Central',$inner_js_msg_central, {'js_ready' => 1, 'only_body' => 1, 'bgcolor' =>'#FFFFFF',}); - my $end_page_msg_central = + my $end_page_msg_central = &Apache::loncommon::end_page({'js_ready' => 1}); + my $start_page_highlight_central = + &Apache::loncommon::start_page('Highlight Central', + $inner_js_highlight_central, + {'js_ready' => 1, + 'only_body' => 1, + 'bgcolor' =>'#FFFFFF',}); + my $end_page_highlight_central = + &Apache::loncommon::end_page({'js_ready' => 1}); + my $docopen=&Apache::lonhtmlcommon::javascript_docopen(); $docopen=~s/^document\.//; - - my %html_js_lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( + keyw => 'Keywords list, separated by a space. Add/delete to list if desired.', + plse => 'Please select a word or group of words from document and then click this link.', + adds => 'Add selection to keyword list? Edit if desired.', comp => 'Compose Message for: ', incl => 'Include', type => 'Type', @@ -1657,10 +1507,26 @@ INNERJS new => 'New', save => 'Save', canc => 'Cancel', + kehi => 'Keyword Highlight Options', + txtc => 'Text Color', + font => 'Font Size', + fnst => 'Font Style', ); - &html_escape(\%html_js_lt); - &js_escape(\%html_js_lt); - $request->print(&Apache::lonhtmlcommon::scripttag(<print(< + +//===================== Show list of keywords ==================== + function keywords(formname) { + var nret = prompt("$lt{'keyw'}",formname.keywords.value); + if (nret==null) return; + formname.keywords.value = nret; + + if (formname.keywords.value != "") { + formname.refresh.value = "on"; + formname.submit(); + } + return; + } //===================== Script to view submitted by ================== function viewSubmitter(submitter) { @@ -1671,6 +1537,26 @@ INNERJS return; } +//===================== Script to add keyword(s) ================== + function getSel() { + if (document.getSelection) txt = document.getSelection(); + else if (document.selection) txt = document.selection.createRange().text; + else return; + var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," "); + if (cleantxt=="") { + alert("$lt{'plse'}"); + return; + } + var nret = prompt("$lt{'adds'}",cleantxt); + if (nret==null) return; + document.SCORE.keywords.value = document.SCORE.keywords.value+" "+nret; + if (document.SCORE.keywords.value != "") { + document.SCORE.refresh.value = "on"; + document.SCORE.submit(); + } + return; + } + //====================== Script for composing message ============== // preload images img1 = new Image(); @@ -1725,15 +1611,17 @@ INNERJS function savedMsgHeader(Nmsg,usrctr,fullname) { var height = 70*Nmsg+250; + var scrollbar = "no"; if (height > 600) { height = 600; + scrollbar = "yes"; } var xpos = (screen.width-600)/2; xpos = (xpos < 0) ? '0' : xpos; var ypos = (screen.height-height)/2-30; ypos = (ypos < 0) ? '0' : ypos; - pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars=yes,screenx='+xpos+',screeny='+ypos+',width=700,height='+height); + pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=700,height='+height); pWin.focus(); pDoc = pWin.document; pDoc.$docopen; @@ -1741,146 +1629,47 @@ INNERJS pDoc.write(""); pDoc.write(""); - pDoc.write("

 $html_js_lt{'comp'}\"+fullname+\"<\\/h1>"); + pDoc.write("

 $lt{'comp'}\"+fullname+\"<\\/span><\\/h3>

"); - pDoc.write(''); - pDoc.write("
$html_js_lt{'incl'}<\\/b><\\/td>$html_js_lt{'type'}<\\/b><\\/td>$html_js_lt{'mesa'}<\\/td><\\/tr>"); + pDoc.write('
'); + pDoc.write(''); + pDoc.write(""); + pDoc.write(""); + pDoc.write(""); - pDoc.write(""); pDoc.write("
$lt{'type'}<\\/b><\\/td>$lt{'incl'}<\\/b><\\/td>$lt{'mesa'}<\\/td><\\/tr>"); } function displaySubject(msg,shwsel) { pDoc = pWin.document; - pDoc.write("
$lt{'subj'}<\\/td>"); pDoc.write("<\\/td>"); - pDoc.write("$html_js_lt{'subj'}<\\/td>"); - pDoc.write("<\\/td><\\/tr>"); + pDoc.write("<\\/td><\\/tr>"); } function displaySavedMsg(ctr,msg,shwsel) { pDoc = pWin.document; - pDoc.write("
<\\/td>"); + pDoc.write("
"+ctr+"<\\/td>"); + pDoc.write("<\\/td>"); pDoc.write("