--- loncom/homework/grades.pm 2021/12/17 15:22:13 1.596.2.12.2.58
+++ 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.58 2021/12/17 15:22:13 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('No dropbox items or essayresponse items with uploadedfiletypes set.'). - '
'; - } else { - 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(<