version 1.405, 2007/06/15 21:21:16
|
version 1.407, 2007/06/15 22:10:15
|
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 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)) { |
$id=~s/^0+//; |
$id=~s/^0+//; |
if (exists($clickerids{$id})) { |
if (exists($clicker_ids{$id})) { |
$clickerids{$id}.=','.$username.':'.$domain; |
$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); |
Line 6168 sub gather_adv_clicker_ids {
|
Line 6167 sub gather_adv_clicker_ids {
|
(&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1]; |
(&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1]; |
foreach my $id (split(/\,/,$clickers)) { |
foreach my $id (split(/\,/,$clickers)) { |
$id=~s/^0+//; |
$id=~s/^0+//; |
if (exists($clickerids{$id})) { |
if (exists($clicker_ids{$id})) { |
$clickerids{$id}.=','.$puname.':'.$pudom; |
$clicker_ids{$id}.=','.$puname.':'.$pudom; |
} else { |
} else { |
$clickerids{$id}=$puname.':'.$pudom; |
$clicker_ids{$id}=$puname.':'.$pudom; |
} |
} |
} |
} |
} |
} |
} |
} |
return %clickerids; |
return %clicker_ids; |
} |
} |
|
|
sub process_clicker { |
sub process_clicker { |
Line 6274 sub process_clicker_file {
|
Line 6273 sub process_clicker_file {
|
$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>'; |
$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>'; |
return $result.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
} |
} |
my %clickerids=&gather_clicker_ids(); |
my %clicker_ids=&gather_clicker_ids(); |
my %correctids=(); |
my %correct_ids=(); |
if ($env{'form.gradingmechanism'} eq 'personnel') { |
if ($env{'form.gradingmechanism'} eq 'personnel') { |
%correctids=&gather_adv_clicker_ids(); |
%correct_ids=&gather_adv_clicker_ids(); |
} |
} |
if ($env{'form.gradingmechanism'} eq 'specific') { |
if ($env{'form.gradingmechanism'} eq 'specific') { |
my $correctid=$env{'form.specificid'}; |
my $correct_id=$env{'form.specificid'}; |
$correctid=~tr/a-z/A-Z/; |
$correct_id=~tr/a-z/A-Z/; |
$correctid=~s/\s//gs; |
$correct_id=~s/\s//gs; |
$correctid=~s/^0+//; |
$correct_id=~s/^0+//; |
$correctids{$correctid}='specified'; |
$correct_ids{$correct_id}='specified'; |
} |
} |
if ($env{'form.gradingmechanism'} eq 'attendance') { |
if ($env{'form.gradingmechanism'} eq 'attendance') { |
$result.=&mt('Score based on attendance only'); |
$result.=&mt('Score based on attendance only'); |
} else { |
} else { |
my $number=0; |
my $number=0; |
$result.='<h3>'.&mt('Correctness determined by the following IDs').'</h3>'; |
$result.='<h3>'.&mt('Correctness determined by the following IDs').'</h3>'; |
foreach my $id (sort(keys(%correctids))) { |
foreach my $id (sort(keys(%correct_ids))) { |
$result.='<tt>'.$id.'</tt> - '; |
$result.='<tt>'.$id.'</tt> - '; |
if ($correctids{$id} eq 'specified') { |
if ($correct_ids{$id} eq 'specified') { |
$result.=&mt('specified'); |
$result.=&mt('specified'); |
} else { |
} else { |
my ($uname,$udom)=split(/\:/,$correctids{$id}); |
my ($uname,$udom)=split(/\:/,$correct_ids{$id}); |
$result.=&Apache::loncommon::plainname($uname,$udom); |
$result.=&Apache::loncommon::plainname($uname,$udom); |
} |
} |
$result.='<br />'; |
$result.='<br />'; |
Line 6308 sub process_clicker_file {
|
Line 6307 sub process_clicker_file {
|
} |
} |
} |
} |
if (length($env{'form.upfile'}) < 2) { |
if (length($env{'form.upfile'}) < 2) { |
$result.="<span class=\"LC_error\">Error:</span> The file you attempted to upload, <tt>".&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename."; |
$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); |
return $result.&show_grading_menu_form($symb); |
} |
} |
my %contents=(); |
my %responses=(); |
|
my @questiontitles=(); |
my $errormsg=''; |
my $errormsg=''; |
my $number=0; |
my $number=0; |
if ($env{'form.upfiletype'} eq 'iclicker') { |
if ($env{'form.upfiletype'} eq 'iclicker') { |
($errormsg,$number,%contents)=&iclicker_eval(); |
($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses); |
$result.=$errormsg; |
} |
|
$result.='<br />'.&mt('Found [_1] questions',$number).'<br />'; |
|
foreach my $id (keys %responses) { |
|
$result.='<br />'.$id.' - '.$responses{$id}; |
} |
} |
return $result.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
} |
} |
|
|
sub iclicker_eval { |
sub iclicker_eval { |
|
my ($questiontitles,$responses)=@_; |
my $number=0; |
my $number=0; |
my $errormsg=''; |
my $errormsg=''; |
foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) { |
foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) { |
Line 6335 sub iclicker_eval {
|
Line 6342 sub iclicker_eval {
|
my @entries=split(/\,/,$line); |
my @entries=split(/\,/,$line); |
if ($entries[0] eq 'Question') { |
if ($entries[0] eq 'Question') { |
for (my $i=3;$i<$#entries;$i+=6) { |
for (my $i=3;$i<$#entries;$i+=6) { |
|
$$questiontitles[$number]=$entries[$i]; |
$number++; |
$number++; |
$errormsg.='<br />'.$entries[$i]; |
|
} |
} |
} |
} |
|
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); |
return ($errormsg,$number); |
} |
} |