--- loncom/homework/grades.pm 2007/06/25 22:23:27 1.399.2.2
+++ loncom/homework/grades.pm 2007/06/14 21:36:12 1.404
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.399.2.2 2007/06/25 22:23:27 albertel Exp $
+# $Id: grades.pm,v 1.404 2007/06/14 21:36:12 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -94,7 +94,6 @@ sub get_symb {
return ();
}
}
- &Apache::lonenc::check_decrypt(\$symb);
return ($symb);
}
@@ -181,7 +180,7 @@ sub showResourceInfo {
if (exists($partsseen{$partID})) {
$result.="
";
} else {
- $result.="
";
+ $result.="
";
}
$partsseen{$partID}=1;
}
@@ -494,7 +493,7 @@ sub jscriptNform {
' }'."\n".
''."\n";
$jscript.= ''."\n";
return $result;
}
@@ -6113,6 +6129,184 @@ sub init_perm {
}
}
+sub gather_clicker_ids {
+ my %clickerids=();
+
+ my $classlist = &Apache::loncoursedata::get_classlist();
+
+ # Set up a couple variables.
+ my $usernameidx = &Apache::loncoursedata::CL_SNAME();
+ my $domainidx = &Apache::loncoursedata::CL_SDOM();
+
+ foreach my $student (keys %$classlist) {
+
+ my $username = $classlist->{$student}->[$usernameidx];
+ my $domain = $classlist->{$student}->[$domainidx];
+ my $clickers =
+ (&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1];
+ foreach my $id (split(/\,/,$clickers)) {
+ if (exists($clickerids{$id})) {
+ $clickerids{$id}.=','.$username.':'.$domain;
+ } else {
+ $clickerids{$id}=$username.':'.$domain;
+ }
+ }
+ }
+ return %clickerids;
+}
+
+sub gather_adv_clicker_ids {
+ my %clickerids=();
+ my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+ my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
+ foreach my $element (sort keys %coursepersonnel) {
+ foreach my $person (split(/\,/,$coursepersonnel{$element})) {
+ my ($puname,$pudom)=split(/\:/,$person);
+ my $clickers =
+ (&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1];
+ foreach my $id (split(/\,/,$clickers)) {
+ if (exists($clickerids{$id})) {
+ $clickerids{$id}.=','.$puname.':'.$pudom;
+ } else {
+ $clickerids{$id}=$puname.':'.$pudom;
+ }
+ }
+ }
+ }
+ return %clickerids;
+}
+
+sub process_clicker {
+ my ($r)=@_;
+ my ($symb)=&get_symb($r);
+ if (!$symb) {return '';}
+ my $result=&checkforfile_js();
+ $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
+ my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
+ $result.=$table;
+ $result.='
'."\n";
+ $result.='
'."\n";
+ $result.=' '.&mt('Specify a file containing the clicker information for this resource').
+ '.
'."\n";
+ $result.='
'."\n";
+ my $upload=&mt("Upload File");
+ my $type=&mt("Type");
+ my $attendance=&mt("Award points just for participation");
+ my $personnel=&mt("Correctness determined from response by course personnel");
+ my $specific=&mt("Correctness determined from response with clicker ID");
+ my $pcorrect=&mt("Percentage points for correct solution");
+ my $pincorrect=&mt("Percentage points for incorrect solution");
+ my $selectform=&Apache::loncommon::select_form('iclicker','upfiletype',
+ ('iclicker' => 'iClicker'));
+
+ $result.=<
+function sanitycheck() {
+// Accept only integer percentages
+ document.forms.gradesupload.pcorrect.value=Math.round(document.forms.gradesupload.pcorrect.value);
+ document.forms.gradesupload.pincorrect.value=Math.round(document.forms.gradesupload.pincorrect.value);
+// Find out grading choice
+ for (i=0; i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ENDUPFORM
+ $result.='
'."\n".
+ '
'."\n";
+ $result.=&show_grading_menu_form($symb);
+ return $result;
+}
+
+sub process_clicker_file {
+ my ($r)=@_;
+ my ($symb)=&get_symb($r);
+ if (!$symb) {return '';}
+ my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+ 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 %clickerids=&gather_clicker_ids();
+ my %correctids=();
+ if ($env{'form.gradingmechanism'} eq 'personnel') {
+ %correctids=&gather_adv_clicker_ids();
+ }
+ if ($env{'form.gradingmechanism'} eq 'specific') {
+ my $correctid=$env{'form.specificid'};
+ $correctid=~tr/a-z/A-Z/;
+ $correctid=~s/\s//gs;
+ $correctids{$correctid}='specified';
+ }
+ 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').'