version 1.403, 2007/06/13 17:18:48
|
version 1.411, 2007/06/16 02:35:22
|
Line 41 use Apache::Constants qw(:common);
|
Line 41 use Apache::Constants qw(:common);
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonenc; |
use Apache::lonenc; |
use String::Similarity; |
use String::Similarity; |
use lib '/home/httpd/lib/perl'; |
|
use LONCAPA; |
use LONCAPA; |
|
|
use POSIX qw(floor); |
use POSIX qw(floor); |
Line 6078 GRADINGMENUJS
|
Line 6077 GRADINGMENUJS
|
'<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="'.&mt('Upload').'" />'. |
'<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="'.&mt('Upload').'" />'. |
' '.&mt('scores from file').' </td></tr>'."\n"; |
' '.&mt('scores from file').' </td></tr>'."\n"; |
|
|
# $result.='<tr bgcolor="#ffffe6"><td>'. |
$result.='<tr bgcolor="#ffffe6"><td>'. |
# '<input type="button" onClick="javascript:checkChoice(this.form,\'6\',\'processclicker\');" value="'.&mt('Process').'" />'. |
'<input type="button" onClick="javascript:checkChoice(this.form,\'6\',\'processclicker\');" value="'.&mt('Process').'" />'. |
# ' '.&mt('clicker file').' </td></tr>'."\n"; |
' '.&mt('clicker file').' </td></tr>'."\n"; |
|
|
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'. |
'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'. |
Line 6130 sub init_perm {
|
Line 6129 sub init_perm {
|
} |
} |
|
|
sub gather_clicker_ids { |
sub gather_clicker_ids { |
my %clickerids=(); |
my %clicker_ids; |
|
|
my $classlist = &Apache::loncoursedata::get_classlist(); |
my $classlist = &Apache::loncoursedata::get_classlist(); |
|
|
# Set up a couple variables. |
# Set up a couple variables. |
my $usernameidx = &Apache::loncoursedata::CL_SNAME(); |
my $username_idx = &Apache::loncoursedata::CL_SNAME(); |
my $domainidx = &Apache::loncoursedata::CL_SDOM(); |
my $domain_idx = &Apache::loncoursedata::CL_SDOM(); |
|
|
foreach my $student (keys %$classlist) { |
foreach my $student (keys(%$classlist)) { |
|
|
my $username = $classlist->{$student}->[$usernameidx]; |
my $username = $classlist->{$student}->[$username_idx]; |
my $domain = $classlist->{$student}->[$domainidx]; |
my $domain = $classlist->{$student}->[$domain_idx]; |
my $clickers = |
my $clickers = |
(&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1]; |
(&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1]; |
foreach my $id (split(/\,/,$clickers)) { |
foreach my $id (split(/\,/,$clickers)) { |
if (exists($clickerids{$id})) { |
$id=~s/^0+//; |
$clickerids{$id}.=','.$username.':'.$domain; |
if (exists($clicker_ids{$id})) { |
|
$clicker_ids{$id}.=','.$username.':'.$domain; |
} else { |
} else { |
$clickerids{$id}=$username.':'.$domain; |
$clicker_ids{$id}=$username.':'.$domain; |
} |
} |
} |
} |
} |
} |
return %clickerids; |
return %clicker_ids; |
} |
} |
|
|
sub gather_adv_clicker_ids { |
sub gather_adv_clicker_ids { |
my %clickerids=(); |
my %clicker_ids; |
my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum); |
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum); |
foreach my $element (sort keys %coursepersonnel) { |
foreach my $element (sort(keys(%coursepersonnel))) { |
foreach my $person (split(/\,/,$coursepersonnel{$element})) { |
foreach my $person (split(/\,/,$coursepersonnel{$element})) { |
my ($puname,$pudom)=split(/\:/,$person); |
my ($puname,$pudom)=split(/\:/,$person); |
my $clickers = |
my $clickers = |
(&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1]; |
(&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1]; |
foreach my $id (split(/\,/,$clickers)) { |
foreach my $id (split(/\,/,$clickers)) { |
if (exists($clickerids{$id})) { |
$id=~s/^0+//; |
$clickerids{$id}.=','.$puname.':'.$pudom; |
if (exists($clicker_ids{$id})) { |
} else { |
$clicker_ids{$id}.=','.$puname.':'.$pudom; |
$clickerids{$id}=$puname.':'.$pudom; |
} else { |
} |
$clicker_ids{$id}=$puname.':'.$pudom; |
} |
} |
|
} |
} |
} |
} |
} |
return %clickerids; |
return %clicker_ids; |
} |
} |
|
|
sub process_clicker { |
sub process_clicker { |
Line 6194 sub process_clicker {
|
Line 6195 sub process_clicker {
|
my $type=&mt("Type"); |
my $type=&mt("Type"); |
my $attendance=&mt("Award points just for participation"); |
my $attendance=&mt("Award points just for participation"); |
my $personnel=&mt("Correctness determined from response by course personnel"); |
my $personnel=&mt("Correctness determined from response by course personnel"); |
my $specific=&mt("Correctness determind from response with clicker ID"); |
my $specific=&mt("Correctness determined from response with clicker ID"); |
my $pcorrect=&mt("Percentage points for correct solution"); |
my $pcorrect=&mt("Percentage points for correct solution"); |
my $pincorrect=&mt("Percentage points for incorrect solution"); |
my $pincorrect=&mt("Percentage points for incorrect solution"); |
my $selectform=&Apache::loncommon::select_form('iclicker','upfiletype', |
my $selectform=&Apache::loncommon::select_form('iclicker','upfiletype', |
('iclicker' => 'iClicker')); |
('iclicker' => 'i>clicker')); |
|
|
$result.=<<ENDUPFORM; |
$result.=<<ENDUPFORM; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 6268 sub process_clicker_file {
|
Line 6269 sub process_clicker_file {
|
my ($symb)=&get_symb($r); |
my ($symb)=&get_symb($r); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); |
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); |
$result.=&show_grading_menu_form($symb); |
if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) { |
my %clickerids=&gather_clicker_ids(); |
$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>'; |
foreach my $key (keys %clickerids) { |
return $result.&show_grading_menu_form($symb); |
$result.='<br />'.$key.' - '.$clickerids{$key}; |
} |
|
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.='<p><b>'.&mt('Correctness determined by the following IDs').'</b>'; |
|
foreach my $id (sort(keys(%correct_ids))) { |
|
$result.='<br /><tt>'.$id.'</tt> - '; |
|
if ($correct_ids{$id} eq 'specified') { |
|
$result.=&mt('specified'); |
|
} else { |
|
my ($uname,$udom)=split(/\:/,$correct_ids{$id}); |
|
$result.=&Apache::loncommon::plainname($uname,$udom); |
|
} |
|
$number++; |
|
} |
|
$result.="</p>\n"; |
|
if ($number==0) { |
|
$result.='<span class="LC_error">'.&mt('No IDs found to determine correct answer').'</span>'; |
|
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.', |
|
'<span class="LC_error">', |
|
'</span>', |
|
'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'</span>'); |
|
return $result.&show_grading_menu_form($symb); |
|
} |
|
|
|
# Were able to get all the info needed, now analyze the file |
|
|
|
$result.=&Apache::loncommon::studentbrowser_javascript(); |
|
my $heading=&mt('Scanning clicker file'); |
|
$result.=(<<ENDHEADER); |
|
<br /><table width="100%" border="0"><tr><td bgcolor="#777777"> |
|
<table width="100%" border="0"><tr bgcolor="#e6ffff"><td> |
|
<b>$heading</b></td></tr><tr bgcolor=#ffffe6><td> |
|
<form method="post" action="/adm/grades" name="clickeranalysis"> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="command" value="assignclickergrades" /> |
|
<input type="hidden" name="probTitle" value="$env{'form.probTitle'}" /> |
|
<input type="hidden" name="saveState" value="$env{'form.saveState'}" /> |
|
<input type="hidden" name="gradingmechanism" value="$env{'form.gradingmechanism'}" /> |
|
<input type="hidden" name="pcorrect" value="$env{'form.pcorrect'}" /> |
|
<input type="hidden" name="pincorrect" value="$env{'form.pincorrect'}" /> |
|
ENDHEADER |
|
my %responses; |
|
my @questiontitles; |
|
my $errormsg=''; |
|
my $number=0; |
|
if ($env{'form.upfiletype'} eq 'iclicker') { |
|
($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses); |
|
} |
|
$result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'. |
|
'<input type="hidden" name="number" value="'.$number.'" />'. |
|
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses', |
|
$env{'form.pcorrect'},$env{'form.pincorrect'}). |
|
'<br />'; |
|
my $correct_count=0; |
|
my $student_count=0; |
|
my $unknown_count=0; |
|
foreach my $id (keys(%responses)) { |
|
if ($correct_ids{$id}) { |
|
$result.="\n".'<input type="hidden" name="correct:'.$correct_ids{$id}.'" value="'.$responses{$id}.'" />'; |
|
$correct_count++; |
|
} elsif ($clicker_ids{$id}) { |
|
$result.="\n".'<input type="hidden" name="student:'.$clicker_ids{$id}.'" value="'.$responses{$id}.'" />'; |
|
$student_count++; |
|
} else { |
|
$result.="\n<hr />".&mt('Unregistered Clicker')." <tt>".$id."</tt><br />"; |
|
$result.="\n".'<input type="hidden" name="unknown:'.$id.'" value="'.$responses{$id}.'" />'. |
|
"\n".&mt("Username").": <input type='text' name='uname".$id."' /> ". |
|
"\n".&mt("Domain").": ". |
|
&Apache::loncommon::select_dom_form($env{'course.'.$env{'request.course.id'}.'.domain'},'udom'.$id).' '. |
|
&Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id); |
|
$unknown_count++; |
|
} |
|
} |
|
$result.='<hr /><p> </p><input type="submit" name="finalize" value="'.&mt('Finalize Grading').'" /></form>'; |
|
$result.='</td></tr></table>'."\n". |
|
'</td></tr></table><br /><br />'."\n"; |
|
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'})) { |
|
my %components=&Apache::loncommon::record_sep($line); |
|
my @entries=map {$components{$_}} (sort(keys(%components))); |
|
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 { |
sub handler { |