--- loncom/homework/grades.pm 2007/06/13 17:18:48 1.403
+++ loncom/homework/grades.pm 2007/06/15 22:10:15 1.407
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.403 2007/06/13 17:18:48 albertel Exp $
+# $Id: grades.pm,v 1.407 2007/06/15 22:10:15 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,7 +41,6 @@ use Apache::Constants qw(:common);
use Apache::lonlocal;
use Apache::lonenc;
use String::Similarity;
-use lib '/home/httpd/lib/perl';
use LONCAPA;
use POSIX qw(floor);
@@ -6078,9 +6077,9 @@ GRADINGMENUJS
''.
' '.&mt('scores from file').' '."\n";
-# $result.='
'.
-# ''.
-# ' '.&mt('clicker file').' |
'."\n";
+ $result.=''.
+ ''.
+ ' '.&mt('clicker file').' |
'."\n";
$result.=''.
' 'iClicker'));
+ ('iclicker' => 'i>clicker'));
$result.=<
@@ -6268,12 +6269,95 @@ sub process_clicker_file {
my ($symb)=&get_symb($r);
if (!$symb) {return '';}
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
- $result.=&show_grading_menu_form($symb);
- my %clickerids=&gather_clicker_ids();
- foreach my $key (keys %clickerids) {
- $result.=' '.$key.' - '.$clickerids{$key};
+ if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) {
+ $result.=''.&mt('You need to specify a clicker ID for the correct answer').'';
+ return $result.&show_grading_menu_form($symb);
+ }
+ my %clicker_ids=&gather_clicker_ids();
+ my %correct_ids=();
+ if ($env{'form.gradingmechanism'} eq 'personnel') {
+ %correct_ids=&gather_adv_clicker_ids();
+ }
+ if ($env{'form.gradingmechanism'} eq 'specific') {
+ my $correct_id=$env{'form.specificid'};
+ $correct_id=~tr/a-z/A-Z/;
+ $correct_id=~s/\s//gs;
+ $correct_id=~s/^0+//;
+ $correct_ids{$correct_id}='specified';
}
- return $result;
+ if ($env{'form.gradingmechanism'} eq 'attendance') {
+ $result.=&mt('Score based on attendance only');
+ } else {
+ my $number=0;
+ $result.=''.&mt('Correctness determined by the following IDs').'';
+ foreach my $id (sort(keys(%correct_ids))) {
+ $result.=''.$id.' - ';
+ if ($correct_ids{$id} eq 'specified') {
+ $result.=&mt('specified');
+ } else {
+ my ($uname,$udom)=split(/\:/,$correct_ids{$id});
+ $result.=&Apache::loncommon::plainname($uname,$udom);
+ }
+ $result.=' ';
+ $number++;
+ }
+ if ($number==0) {
+ $result.=''.&mt('No IDs found to determine correct answer').'';
+ return $result.&show_grading_menu_form($symb);
+ }
+ }
+ if (length($env{'form.upfile'}) < 2) {
+ $result.=&mt('[_1] Error: [_2] The file you attempted to upload, [_3] contained no information. Please check that you entered the correct filename.',
+ '',
+ '',
+ ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'');
+ return $result.&show_grading_menu_form($symb);
+ }
+ my %responses=();
+ my @questiontitles=();
+ my $errormsg='';
+ my $number=0;
+ if ($env{'form.upfiletype'} eq 'iclicker') {
+ ($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses);
+ }
+ $result.=' '.&mt('Found [_1] questions',$number).' ';
+ foreach my $id (keys %responses) {
+ $result.=' '.$id.' - '.$responses{$id};
+ }
+ return $result.&show_grading_menu_form($symb);
+}
+
+sub iclicker_eval {
+ my ($questiontitles,$responses)=@_;
+ my $number=0;
+ my $errormsg='';
+ foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) {
+ chomp($line);
+ foreach my $quoted ($line=~/\,\s*\"([^\"]*)\"\s*\,/g) {
+ my $replace=$quoted;
+ $replace=~s/\,//g;
+ &Apache::lonnet::logthis($quoted.' - '.$replace.' ');
+ $line=~s/\,\s*\"\Q$quoted\E\"\s*\,/,$replace,/gs;
+ }
+ my @entries=split(/\,/,$line);
+ if ($entries[0] eq 'Question') {
+ for (my $i=3;$i<$#entries;$i+=6) {
+ $$questiontitles[$number]=$entries[$i];
+ $number++;
+ }
+ }
+ if ($entries[0]=~/^\#/) {
+ my $id=$entries[0];
+ my @idresponses=();
+ $id=~s/^[\#0]+//;
+ for (my $i=0;$i<$number;$i++) {
+ my $idx=3+$i*6;
+ push(@idresponses,$entries[$idx]);
+ }
+ $$responses{$id}=join(',',@idresponses);
+ }
+ }
+ return ($errormsg,$number);
}
sub handler {
|