version 1.239, 2006/04/11 21:08:29
|
version 1.267, 2007/04/07 00:12:42
|
Line 86 sub get_target {
|
Line 86 sub get_target {
|
} elsif ( defined($env{'form.grade_target'} ) |
} elsif ( defined($env{'form.grade_target'} ) |
&& ($Apache::lonhomework::viewgrades eq 'F' )) { |
&& ($Apache::lonhomework::viewgrades eq 'F' )) { |
return ($env{'form.grade_target'}); |
return ($env{'form.grade_target'}); |
|
} elsif ( $env{'form.grade_target'} eq 'webgrade' |
|
&& ($Apache::lonhomework::queuegrade eq 'F' )) { |
|
return ($env{'form.grade_target'}); |
} |
} |
if ($env{'form.webgrade'} && |
if ($env{'form.webgrade'} && |
$Apache::lonhomework::modifygrades eq 'F') { |
($Apache::lonhomework::modifygrades eq 'F' |
|
|| $Apache::lonhomework::queuegrade eq 'F' )) { |
return ('grade','webgrade'); |
return ('grade','webgrade'); |
} |
} |
if ( defined($env{'form.submitted'}) && |
if ( defined($env{'form.submitted'}) && |
( !defined($env{'form.resetdata'})) && |
|
( !defined($env{'form.newrandomization'}))) { |
( !defined($env{'form.newrandomization'}))) { |
return ('grade', 'web'); |
return ('grade', 'web'); |
} else { |
} else { |
Line 109 sub get_target {
|
Line 112 sub get_target {
|
return ('web'); |
return ('web'); |
} |
} |
} else { |
} else { |
if ( $env{'form.problemmode'} eq &mt('View') || |
if ($env{'form.problemstate'} eq 'WEB_GRADE') { |
|
#$env{'form.webgrade'} = 'yes'; |
|
return ('grade','webgrade','answer'); |
|
} elsif ( $env{'form.problemmode'} eq &mt('View') || |
$env{'form.problemmode'} eq &mt('Discard Edits and View')) { |
$env{'form.problemmode'} eq &mt('Discard Edits and View')) { |
if ( defined($env{'form.submitted'}) && |
if ( defined($env{'form.submitted'}) && |
(!defined($env{'form.resetdata'})) && |
(!defined($env{'form.resetdata'})) && |
Line 157 sub proctor_checked_in {
|
Line 163 sub proctor_checked_in {
|
my ($slot_name,$slot,$type)=@_; |
my ($slot_name,$slot,$type)=@_; |
my @possible_proctors=split(",",$slot->{'proctor'}); |
my @possible_proctors=split(",",$slot->{'proctor'}); |
|
|
|
return 1 if (!@possible_proctors); |
|
|
my $key; |
my $key; |
if ($type eq 'Task') { |
if ($type eq 'Task') { |
my $version=$Apache::lonhomework::history{'resource.0.version'}; |
my $version=$Apache::lonhomework::history{'resource.0.version'}; |
Line 164 sub proctor_checked_in {
|
Line 172 sub proctor_checked_in {
|
} elsif ($type eq 'problem') { |
} elsif ($type eq 'problem') { |
$key ='resource.0.checkedin'; |
$key ='resource.0.checkedin'; |
} |
} |
|
# backward compatability, used to be username@domain, |
|
# now is username:domain |
|
my $who = $Apache::lonhomework::history{$key}; |
|
if ($who !~ /:/) { |
|
$who =~ tr/@/:/; |
|
} |
foreach my $possible (@possible_proctors) { |
foreach my $possible (@possible_proctors) { |
if ($Apache::lonhomework::history{$key} eq $possible |
if ($who eq $possible |
&& $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) { |
&& $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) { |
return 1; |
return 1; |
} |
} |
Line 233 sub check_slot_access {
|
Line 246 sub check_slot_access {
|
# does it pass normal muster |
# does it pass normal muster |
my ($status,$datemsg)=&check_access($id); |
my ($status,$datemsg)=&check_access($id); |
|
|
my $useslots = &Apache::lonnet::EXT("resource.$id.useslots"); |
my $useslots = &Apache::lonnet::EXT("resource.0.useslots"); |
if ($useslots ne 'resource') { |
if ($useslots ne 'resource' && $useslots ne 'map' |
|
&& $useslots ne 'map_map') { |
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
|
|
Line 257 sub check_slot_access {
|
Line 271 sub check_slot_access {
|
} |
} |
|
|
my @slots= |
my @slots= |
(split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")), |
(split(':',&Apache::lonnet::EXT("resource.0.availablestudent")), |
split(':',&Apache::lonnet::EXT("resource.$id.available"))); |
split(':',&Apache::lonnet::EXT("resource.0.available"))); |
|
|
# if (!@slots) { |
# if (!@slots) { |
# return ($status,$datemsg); |
# return ($status,$datemsg); |
Line 266 sub check_slot_access {
|
Line 280 sub check_slot_access {
|
my $slotstatus='NOT_IN_A_SLOT'; |
my $slotstatus='NOT_IN_A_SLOT'; |
my ($returned_slot,$slot_name); |
my ($returned_slot,$slot_name); |
foreach my $slot (@slots) { |
foreach my $slot (@slots) { |
|
$slot =~ s/(^\s*|\s*$)//g; |
&Apache::lonxml::debug("getting $slot"); |
&Apache::lonxml::debug("getting $slot"); |
my %slot=&Apache::lonnet::get_slot($slot); |
my %slot=&Apache::lonnet::get_slot($slot); |
&Apache::lonhomework::showhash(%slot); |
&Apache::lonhomework::showhash(%slot); |
Line 297 sub check_slot_access {
|
Line 312 sub check_slot_access {
|
$checkedin = |
$checkedin = |
$Apache::lonhomework::history{"resource.$version.0.checkedin"}; |
$Apache::lonhomework::history{"resource.$version.0.checkedin"}; |
} elsif ($type eq 'problem') { |
} elsif ($type eq 'problem') { |
$got_grade = 1; |
$got_grade = 1; |
$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"}; |
$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"}; |
|
$is_correct = |
|
($Apache::lonhomework::history{"resource.0.solved"} =~/^correct_/); |
} |
} |
|
|
&Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)"); |
&Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)"); |
|
|
# has a current checked in recrd, but hasn't got a grade, must be awaiting |
# no slot is currently open, and has been checked in for this version |
# a grade |
# but hasn't got a grade, therefore must be awaiting a grade |
if ($checkedin |
if (!defined($slot_name) |
|
&& $checkedin |
&& !$got_grade) { |
&& !$got_grade) { |
return ('WAITING_FOR_GRADE'); |
return ('WAITING_FOR_GRADE'); |
} |
} |
|
|
|
# no slot is currently open, and has been checked in for this version |
|
# previous slot is therefore CLOSED, so therefore the problem is |
|
if (!defined($slot_name) |
|
&& $checkedin |
|
&& $type eq 'problem') { |
|
return ('CLOSED',$datemsg); |
|
} |
|
|
if ($slotstatus eq 'NOT_IN_A_SLOT' |
if ($slotstatus eq 'NOT_IN_A_SLOT' |
&& $checkedin ) { |
&& $checkedin ) { |
|
|
Line 320 sub check_slot_access {
|
Line 346 sub check_slot_access {
|
} |
} |
|
|
} |
} |
|
|
if ( $is_correct) { |
if ( $is_correct) { |
|
if ($type eq 'problem') { |
|
return ($status); |
|
} |
return ('SHOW_ANSWER'); |
return ('SHOW_ANSWER'); |
} |
} |
|
|
if ( $status eq 'CANNOT_ANSWER' && |
if ( $status eq 'CANNOT_ANSWER' && |
($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) { |
($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) { |
return ($status,$datemsg); |
return ($status,$datemsg); |
Line 364 sub check_access {
|
Line 395 sub check_access {
|
&Apache::lonxml::debug("checking for part :$id:"); |
&Apache::lonxml::debug("checking for part :$id:"); |
&Apache::lonxml::debug("time:".time); |
&Apache::lonxml::debug("time:".time); |
|
|
my ($symb)=&Apache::lonxml::whichuser(); |
my ($symb)=&Apache::lonnet::whichuser(); |
&Apache::lonxml::debug("symb:".$symb); |
&Apache::lonxml::debug("symb:".$symb); |
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
if ($env{'request.state'} ne "construct") { |
if ($env{'request.state'} ne "construct") { |
Line 377 sub check_access {
|
Line 408 sub check_access {
|
|
|
foreach my $temp ("opendate","duedate","answerdate") { |
foreach my $temp ("opendate","duedate","answerdate") { |
$lastdate = $date; |
$lastdate = $date; |
$date = &Apache::lonnet::EXT("resource.$id.$temp"); |
if ($temp eq 'duedate') { |
|
$date = &due_date($id); |
|
} else { |
|
$date = &Apache::lonnet::EXT("resource.$id.$temp"); |
|
} |
|
|
my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type"); |
my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type"); |
if ($thistype =~ /^(con_lost|no_such_host)/ || |
if ($thistype =~ /^(con_lost|no_such_host)/ || |
$date =~ /^(con_lost|no_such_host)/) { |
$date =~ /^(con_lost|no_such_host)/) { |
Line 445 sub check_access {
|
Line 481 sub check_access {
|
&Apache::lonxml::debug("looking for accesstime $first_access"); |
&Apache::lonxml::debug("looking for accesstime $first_access"); |
if (!$first_access) { |
if (!$first_access) { |
$status='NOT_YET_VIEWED'; |
$status='NOT_YET_VIEWED'; |
$datemsg=&seconds_to_human_length($interval); |
my $due_date = &due_date($id); |
} else { |
my $seconds_left = $due_date - time; |
my $newdate=localtime($first_access+$interval); |
if ($seconds_left > $interval || $due_date eq '') { |
if (time > ($first_access+$interval)) { |
$seconds_left = $interval; |
$status='CLOSED'; |
|
$datemsg = &mt("was due on")." $newdate".&mt(", and answers will be available on")." $date"; |
|
} else { |
|
$datemsg = &mt("is due at")." $newdate"; |
|
} |
} |
|
$datemsg=&seconds_to_human_length($seconds_left); |
} |
} |
} |
} |
} |
} |
|
|
#if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && |
#if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && |
# (!$Apache::lonhomework::history{"resource.0.outtoken"})) { |
# (!$Apache::lonhomework::history{"resource.0.outtoken"})) { |
# return ('UNCHECKEDOUT','needs to be checked out'); |
# return ('UNCHECKEDOUT','needs to be checked out'); |
Line 472 sub check_access {
|
Line 506 sub check_access {
|
|
|
return ($status,$datemsg); |
return ($status,$datemsg); |
} |
} |
|
# this should work exactly like the copy in lonnavmaps.pm |
|
sub due_date { |
|
my ($part_id,$symb,$udom,$uname)=@_; |
|
my $date; |
|
my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb, |
|
$udom,$uname); |
|
&Apache::lonxml::debug("looking for interval $part_id $symb $interval"); |
|
my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb, |
|
$udom,$uname); |
|
&Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); |
|
if ($interval =~ /\d+/) { |
|
my $first_access=&Apache::lonnet::get_first_access('map',$symb); |
|
&Apache::lonxml::debug("looking for first_access $first_access"); |
|
if (defined($first_access)) { |
|
$interval = $first_access+$interval; |
|
$date = ($interval < $due_date)? $interval : $due_date; |
|
} else { |
|
$date = $due_date; |
|
} |
|
} else { |
|
$date = $due_date; |
|
} |
|
return $date |
|
} |
|
|
sub seconds_to_human_length { |
sub seconds_to_human_length { |
my ($length)=@_; |
my ($length)=@_; |
Line 544 sub setuppermissions {
|
Line 602 sub setuppermissions {
|
$viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}. |
$viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}. |
'/'.$env{'request.course.sec'}); |
'/'.$env{'request.course.sec'}); |
} |
} |
$Apache::lonhomework::viewgrades = $viewgrades; # File global variable...dirt. |
$Apache::lonhomework::viewgrades = $viewgrades; |
|
|
if ($Apache::lonhomework::browse eq 'F' && |
if ($Apache::lonhomework::browse eq 'F' && |
$env{'form.devalidatecourseresdata'} eq 'on') { |
$env{'form.devalidatecourseresdata'} eq 'on') { |
my (undef,$courseid) = &Apache::lonxml::whichuser(); |
my (undef,$courseid) = &Apache::lonnet::whichuser(); |
&Apache::lonnet::devalidatecourseresdata($env{"course.$courseid.num"}, |
&Apache::lonnet::devalidatecourseresdata($env{"course.$courseid.num"}, |
$env{"course.$courseid.domain"}); |
$env{"course.$courseid.domain"}); |
} |
} |
|
|
my $modifygrades = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); |
my $modifygrades = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); |
if (! $modifygrades && |
if (! $modifygrades && |
exists($env{'request.course.sec'}) && |
exists($env{'request.course.sec'}) && |
Line 560 sub setuppermissions {
|
Line 620 sub setuppermissions {
|
'/'.$env{'request.course.sec'}); |
'/'.$env{'request.course.sec'}); |
} |
} |
$Apache::lonhomework::modifygrades = $modifygrades; |
$Apache::lonhomework::modifygrades = $modifygrades; |
|
|
|
my $queuegrade = &Apache::lonnet::allowed('mqg',$env{'request.course.id'}); |
|
if (! $queuegrade && |
|
exists($env{'request.course.sec'}) && |
|
$env{'request.course.sec'} !~ /^\s*$/) { |
|
$queuegrade = |
|
&Apache::lonnet::allowed('qgr',$env{'request.course.id'}. |
|
'/'.$env{'request.course.sec'}); |
|
} |
|
$Apache::lonhomework::queuegrade = $queuegrade; |
return ''; |
return ''; |
} |
} |
|
|
|
sub unset_permissions { |
|
undef($Apache::lonhomework::queuegrade); |
|
undef($Apache::lonhomework::modifygrades); |
|
undef($Apache::lonhomework::viewgrades); |
|
undef($Apache::lonhomework::browse); |
|
} |
|
|
sub setupheader { |
sub setupheader { |
my $request=$_[0]; |
my $request=$_[0]; |
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::content_type($request,'text/html'); |
Line 582 sub handle_save_or_undo {
|
Line 659 sub handle_save_or_undo {
|
my $filebak =$file.".bak"; |
my $filebak =$file.".bak"; |
my $filetmp =$file.".tmp"; |
my $filetmp =$file.".tmp"; |
my $error=0; |
my $error=0; |
|
|
&Apache::lonnet::correct_line_ends($result); |
|
|
|
if ($env{'form.Undo'} eq &mt('undo')) { |
if ($env{'form.Undo'} eq &mt('undo')) { |
my $error=0; |
my $error=0; |
if (!copy($file,$filetmp)) { $error=1; } |
if (!copy($file,$filetmp)) { $error=1; } |
if ((!$error) && (!copy($filebak,$file))) { $error=1; } |
if ((!$error) && (!copy($filebak,$file))) { $error=1; } |
if ((!$error) && (!move($filetmp,$filebak))) { $error=1; } |
if ((!$error) && (!move($filetmp,$filebak))) { $error=1; } |
if (!$error) { |
if (!$error) { |
&Apache::lonxml::info("<p><b>".&mt("Undid changes, Switched")." $filebak ".&mt("and")." $file</b></p>"); |
&Apache::lonxml::info("<p><b>". |
|
&mt("Undid changes, Switched [_1] and [_2]", |
|
'<span class="LC_filename">'.$filebak. |
|
'</span>', |
|
'<span class="LC_filename">'.$file. |
|
'</span>')."</b></p>"); |
} else { |
} else { |
&Apache::lonxml::info("<p><font color=\"red\" size=\"+1\"><b>".&mt("Unable to undo, unable to switch")." $filebak ".&mt("and")." $file</b></font></p>"); |
&Apache::lonxml::info("<p><span class=\"LC_error\">". |
|
&mt("Unable to undo, unable to switch [_1] and [_2]", |
|
'<span class="LC_filename">'. |
|
$filebak.'</span>', |
|
'<span class="LC_filename">'. |
|
$file.'</span>')."</span></p>"); |
$error=1; |
$error=1; |
} |
} |
} else { |
} else { |
|
&Apache::lonnet::correct_line_ends($result); |
my $fs=Apache::File->new(">$filebak"); |
my $fs=Apache::File->new(">$filebak"); |
if (defined($fs)) { |
if (defined($fs)) { |
print $fs $$problem; |
print $fs $$problem; |
&Apache::lonxml::info("<b>".&mt("Making Backup to"). |
&Apache::lonxml::info("<b>".&mt("Making Backup to [_1]", |
" $filebak</b>"); |
'<span class="LC_filename">'. |
|
$filebak.'</span>'). |
|
"</b>"); |
} else { |
} else { |
&Apache::lonxml::info("<font color=\"red\" size=\"+1\"><b>".&mt("Unable to make backup")." $filebak</b></font>"); |
&Apache::lonxml::info("<span class=\"LC_error\">". |
|
&mt("Unable to make backup [_1]", |
|
'<span class="LC_filename">'. |
|
$filebak.'</span>')."</span>"); |
$error=2; |
$error=2; |
} |
} |
my $fh=Apache::File->new(">$file"); |
my $fh=Apache::File->new(">$file"); |
if (defined($fh)) { |
if (defined($fh)) { |
print $fh $$result; |
print $fh $$result; |
&Apache::lonxml::info("<b>".&mt("Saving Modifications to"). |
&Apache::lonxml::info("<b>".&mt("Saving Modifications to [_1]", |
" $file</b>"); |
'<span class="LC_filename">'. |
|
$file.'</span>' )."</b>"); |
} else { |
} else { |
&Apache::lonxml::info("<font color=\"red\" size=\"+1\"><b>". |
&Apache::lonxml::info('<span class="LC_error">'. |
&mt("Unable to write to")." $file</b></font>"); |
&mt("Unable to write to [_1]", |
|
'<span class="LC_filename">'. |
|
$file.'</span>'). |
|
'</span>'); |
$error|=4; |
$error|=4; |
} |
} |
} |
} |
Line 623 sub handle_save_or_undo {
|
Line 717 sub handle_save_or_undo {
|
sub analyze_header { |
sub analyze_header { |
my ($request) = @_; |
my ($request) = @_; |
my $result = |
my $result = |
&Apache::loncommon::start_page('Analyzing a problem',undef, |
&Apache::loncommon::start_page('Analyzing a problem',undef); |
{'only_body' => ($env{'environment.remote'} ne 'off'),}); |
|
$result .= |
$result .= |
&Apache::lonxml::message_location().' |
&Apache::lonxml::message_location().' |
<form name="lonhomework" method="POST" action="'. |
<form name="lonhomework" method="POST" action="'. |
Line 680 sub analyze {
|
Line 774 sub analyze {
|
if ($analyze{$part.'.type'} eq 'numericalresponse' || |
if ($analyze{$part.'.type'} eq 'numericalresponse' || |
$analyze{$part.'.type'} eq 'stringresponse' || |
$analyze{$part.'.type'} eq 'stringresponse' || |
$analyze{$part.'.type'} eq 'formularesponse' ) { |
$analyze{$part.'.type'} eq 'formularesponse' ) { |
my $concatanswer=join("\0",@{ $analyze{$part.'.answer'} }); |
foreach my $name (keys(%{ $analyze{$part.'.answer'} })) { |
if (($concatanswer eq '') || ($concatanswer=~/^\@/)) { |
my $i=0; |
@{$analyze{$part.'.answer'}}=('<font color="red">'.&mt('Error').'</font>'); |
foreach my $answer_part (@{ $analyze{$part.'.answer'}{$name} }) { |
|
push( @{ $overall{$part.'.answer'}[$i] }, |
|
$answer_part); |
|
my $concatanswer= join("\0",@{ $answer_part }); |
|
if (($concatanswer eq '') || ($concatanswer=~/^\@/)) { |
|
$answer_part = ['<span class="LC_error">'.&mt('Error').'</span>']; |
|
} |
|
$seedexample{join("\0",$part,$i,@{$answer_part})}= |
|
$thisseed; |
|
$i++; |
|
} |
} |
} |
push( @{ $overall{$part.'.answer'} }, |
|
[@{ $analyze{$part.'.answer'} }]); |
|
$seedexample{join("\0",@{ $analyze{$part.'.answer'}})}=$thisseed; |
|
} |
} |
} |
} |
} |
} |
Line 695 sub analyze {
|
Line 796 sub analyze {
|
$request->print('<hr />'.&mt('List of possible answers').': '); |
$request->print('<hr />'.&mt('List of possible answers').': '); |
foreach my $part (sort(keys(%allparts))) { |
foreach my $part (sort(keys(%allparts))) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] }); |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
$request->print('<table class="thinborder"><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</th></tr>'); |
my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] }); |
my %frequency; |
$request->print('<table class="thinborder"><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part); |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { |
if (scalar(@{ $overall{$part.'.answer'} }) > 1) { |
$frequency{join("\0",@{ $answer })}++; |
$request->print(&mt(' Answer [_1]',$i+1)); |
} |
} |
$request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />(' |
$request->print('</th></tr>'); |
.&mt('click for example').')</th></tr>'); |
my %frequency; |
foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) { |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'}[$i] })) { |
$request->print('<tr><td class="center">'. |
$frequency{join("\0",@{ $answer })}++; |
join('</td><td class="center">',split("\0",$answer)). |
} |
'</td><td class="center"><a href="'.$request->uri.'?rndseed='.$seedexample{$answer}.'">'.$frequency{$answer}. |
$request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />(' |
'</a></td></tr>'); |
.&mt('click for example').')</th></tr>'); |
|
foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) { |
|
$request->print('<tr><td class="center">'. |
|
join('</td><td class="center">',split("\0",$answer)). |
|
'</td><td class="center"><a href="'.$request->uri.'?rndseed='.$seedexample{join("\0",$part,$i,$answer)}.'">'.$frequency{$answer}. |
|
'</a></td></tr>'); |
|
} |
|
$request->print('</table>'); |
} |
} |
$request->print('</table>'); |
|
} else { |
} else { |
$request->print('<p>'.&mt('Response').' '.$part.' '. |
$request->print('<p>'.&mt('Response').' '.$part.' '. |
&mt('is not analyzable at this time').'</p>'); |
&mt('is not analyzable at this time').'</p>'); |
Line 749 sub editxmlmode {
|
Line 856 sub editxmlmode {
|
&Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", |
&Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", |
"Problem Editing Help"). |
"Problem Editing Help"). |
'</td><td>'. |
'</td><td>'. |
&Apache::loncommon::help_open_menu('',undef,undef,undef,5,'Authoring'). |
&Apache::loncommon::help_open_menu(undef,undef,5,'Authoring'). |
'</td></tr></table>'; |
'</td></tr></table>'; |
if ($cols > 80) { $cols = 80; } |
if ($cols > 80) { $cols = 80; } |
if ($cols < 70) { $cols = 70; } |
if ($cols < 70) { $cols = 70; } |
if ($rows < 20) { $rows = 20; } |
if ($rows < 20) { $rows = 20; } |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page("EditXML $file", |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file), |
&Apache::edit::js_change_detection(), |
&Apache::edit::js_change_detection(), |
{'only_body' => |
{'no_auto_mt_title' => 1,}); |
($env{'environment.remote'} ne 'off')}); |
|
|
|
$result.=$start_page. |
$result.=$start_page. |
&renderpage($request,$file,['no_output_web'],1). |
&renderpage($request,$file,['no_output_web'],1). |
Line 812 sub renderpage {
|
Line 918 sub renderpage {
|
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
my $result; |
my $result; |
if ($problem eq -1) { |
if ($problem eq -1) { |
my $filename=(split('/',$file))[-1]; |
|
$result.="<b> ".&mt('Unable to find')." <i>$filename</i></b>"; |
|
$problem=''; |
$problem=''; |
|
my $filename=(split('/',$file))[-1]; |
|
my $error = |
|
"<b> ".&mt('Unable to find [_1]', |
|
' <span class="LC_filename">'.$filename.'</span>') |
|
."</b>"; |
|
$result.= |
|
&Apache::loncommon::simple_error_page($request,'Not available', |
|
$error); |
|
return; |
} |
} |
|
|
my %mystyle; |
my %mystyle; |
Line 896 sub newproblem {
|
Line 1009 sub newproblem {
|
# I don't like hard-coded filenames but for now, this will work. |
# I don't like hard-coded filenames but for now, this will work. |
use File::Copy; |
use File::Copy; |
my $templatefilename = |
my $templatefilename = |
$request->dir_config('lonIncludes').'/templates/blank.problem'; |
$request->dir_config('lonIncludes').'/templates/blank.'.$extension; |
&Apache::lonxml::debug("$templatefilename"); |
&Apache::lonxml::debug("$templatefilename"); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
copy($templatefilename,$dest); |
copy($templatefilename,$dest); |
Line 908 sub newproblem {
|
Line 1021 sub newproblem {
|
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $errormsg; |
my $errormsg; |
if ($env{'form.newfile'}) { |
if ($env{'form.newfile'}) { |
$errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n"; |
$errormsg='<p><span class="LC_error">'.&mt('You did not select a template.').'</span></p>'."\n"; |
} |
} |
my $instructions; |
my $instructions; |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, |
my $start_page = |
($env{'environment.remote'} ne 'off')); |
&Apache::loncommon::start_page("Create New $extension"); |
if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");} |
$request->print(" |
my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new', |
$start_page |
'resource' => 'resource', |
<h1>".&mt("Creating a new $extension resource.")."</h1> |
'requested' => 'The requested file', |
|
'not exist' => 'currently does not exist', |
|
'createnew' => 'To create a new', |
|
'click' => 'click on the', |
|
'Create' => 'Create', |
|
'button' => 'button'); |
|
$request->print(<<ENDNEWPROBLEM); |
|
$bodytag |
|
<h1>$lt{'create'} $extension $lt{'resource'}</h1> |
|
$errormsg |
$errormsg |
$lt{'requested'} <tt>$shownurl</tt> $lt{'not exist'}. |
".&mt("The requested file [_1] currently does not exist.", |
|
"<tt>$shownurl</tt>")." |
<p> |
<p> |
<b>$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}.</b> |
<b> |
</p> |
".&mt("To create a new $extension, select a template from the". |
<p><form action="$url" method="POST"> |
"pull-down menu below. Then click on the \"Create $extension\" button.")."</b> |
ENDNEWPROBLEM |
</p><form action=\"$url\" method=\"POST\">"); |
|
|
if (defined($templatelist)) { |
if (defined($templatelist)) { |
$request->print("<select name=\"template\">$templatelist</select>"); |
$request->print("<select name=\"template\">$templatelist</select>"); |
} |
} |
Line 964 sub handler {
|
Line 1070 sub handler {
|
if ($Apache::lonhomework::browse ne 'F' && |
if ($Apache::lonhomework::browse ne 'F' && |
$env{'request.state'} ne "construct") { |
$env{'request.state'} ne "construct") { |
#should know where we are, so ask |
#should know where we are, so ask |
$request->internal_redirect('/adm/ambiguous'); return OK; |
&unset_permissions(); |
|
$request->internal_redirect('/adm/ambiguous'); |
|
return OK; |
} |
} |
} |
} |
if (&setupheader($request)) { return OK; } |
if (&setupheader($request)) { |
&Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:"); |
&unset_permissions(); |
|
return OK; |
|
} |
|
&Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade"); |
&Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'}); |
&Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'}); |
my ($symb) = &Apache::lonxml::whichuser(); |
my ($symb) = &Apache::lonnet::whichuser(); |
&Apache::lonxml::debug('symb is '.$symb); |
&Apache::lonxml::debug('symb is '.$symb); |
if ($env{'request.state'} eq "construct") { |
if ($env{'request.state'} eq "construct") { |
if ( -e $file ) { |
if ( -e $file ) { |
Line 1001 sub handler {
|
Line 1112 sub handler {
|
#&Apache::lonxml::debug("Spent $td seconds processing"); |
#&Apache::lonxml::debug("Spent $td seconds processing"); |
# always turn off debug messages |
# always turn off debug messages |
$Apache::lonxml::debug=0; |
$Apache::lonxml::debug=0; |
|
&unset_permissions(); |
return OK; |
return OK; |
|
|
} |
} |