--- loncom/homework/grades.pm 2023/09/07 17:38:56 1.596.2.12.2.60.2.5
+++ loncom/homework/grades.pm 2018/05/04 15:15:05 1.750
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.60.2.5 2023/09/07 17:38:56 raeburn Exp $
+# $Id: grades.pm,v 1.750 2018/05/04 15:15:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,11 +44,9 @@ use Apache::Constants qw(:common :http);
use Apache::lonlocal;
use Apache::lonenc;
use Apache::lonstathelpers;
+use Apache::lonquickgrades;
use Apache::bridgetask();
-use Apache::lontexconvert();
use String::Similarity;
-use HTML::Parser();
-use File::MMagic;
use LONCAPA;
use POSIX qw(floor);
@@ -147,7 +145,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) = @_;
@@ -165,7 +162,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);
@@ -175,20 +171,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 {
@@ -215,129 +204,6 @@ sub get_display_part {
return $display;
}
-#--- Show 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 $result = '
';
- if ($checkboxes) {
- my $legend = &mt('Parts to display');
- if ($uploads) {
- $legend = &mt('Part(s) with dropbox');
- }
- $result .= '';
- }
- $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 $scancode,};
}
}
- my $analyze =
+ my $analyze =
&get_analyze($symb,$uname,$udom,undef,$add_to_form,
undef,undef,undef,$bubbles_per_row);
if (ref($analyze) eq 'HASH') {
@@ -476,7 +342,7 @@ sub cleanRecord {
if ($response =~ /^(option|rank)$/) {
my %answer=&Apache::lonnet::str2hash($answer);
my @answer = %answer;
- %answer = map {&HTML::Entities::encode($_, '"<>&')} @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) {
@@ -494,7 +360,7 @@ sub cleanRecord {
} elsif ($response eq 'match') {
my %answer=&Apache::lonnet::str2hash($answer);
my @answer = %answer;
- %answer = map {&HTML::Entities::encode($_, '"<>&')} @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);
@@ -551,8 +417,8 @@ 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);
return '
'.&keywords_highlight($answer).'
';
+
} elsif ( $response eq 'organic') {
my $result=&mt('Smile representation: [_1]',
'"'.&HTML::Entities::encode($answer, '"<>&').'"');
@@ -669,7 +535,7 @@ sub getclasslist {
$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);
+ ($partlist,my $handgrade,my $responseType) = &response_type($symb,\$res_error);
}
foreach my $student (keys(%$classlist)) {
my $end =
@@ -785,7 +651,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;
}
}
@@ -798,19 +664,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;
}
@@ -951,14 +817,14 @@ sub initialverifyreceipt {
#--- Check whether a receipt number is valid.---
sub verifyreceipt {
- my ($request,$symb) = @_;
+ my ($request,$symb) = @_;
my $courseid = $env{'request.course.id'};
my $receipt = &Apache::lonnet::recprefix($courseid).'-'.
$env{'form.receipt'};
$receipt =~ s/[^\-\d]//g;
- my $title =
+ my $title.=
'
'.
&mt('Verifying Receipt Number [_1]',$receipt).
'
'."\n";
@@ -1039,7 +905,7 @@ 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,$symb,$submitonly) = @_;
my $is_tool = ($symb =~ /ext\.tool$/);
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
@@ -1047,23 +913,12 @@ sub listStudents {
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'};
+ $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
}
my $result='';
my $res_error;
- my ($partlist,$handgrade,$responseType,$numresp,$numessay) = &response_type($symb,\$res_error);
-
- my $table;
- if (ref($partlist) eq 'ARRAY') {
- if (scalar(@$partlist) > 1 ) {
- $table = &showResourceInfo($symb,$partlist,$responseType,'gradesub',1);
- } elsif ($divforres) {
- $table = '';
- } else {
- $table = ' ';
- }
- }
+ my ($partlist,$handgrade,$responseType) = &response_type($symb,\$res_error);
my %js_lt = &Apache::lonlocal::texthash (
'multiple' => 'Please select a student or group of students before clicking on the Next button.',
@@ -1105,8 +960,8 @@ LISTJAVASCRIPT
$request->print($result);
my $gradeTable='