version 1.256, 2006/06/30 17:42:38
|
version 1.263, 2006/12/13 22:48:07
|
Line 393 sub check_access {
|
Line 393 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 514 sub due_date {
|
Line 514 sub due_date {
|
my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb, |
my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb, |
$udom,$uname); |
$udom,$uname); |
&Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); |
&Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); |
if (defined($interval)) { |
if ($interval =~ /\d+/) { |
my $first_access=&Apache::lonnet::get_first_access('map',$symb); |
my $first_access=&Apache::lonnet::get_first_access('map',$symb); |
|
&Apache::lonxml::debug("looking for first_access $first_access"); |
if (defined($first_access)) { |
if (defined($first_access)) { |
$interval = $first_access+$interval; |
$interval = $first_access+$interval; |
$date = ($interval < $due_date)? $interval : $due_date; |
$date = ($interval < $due_date)? $interval : $due_date; |
Line 603 sub setuppermissions {
|
Line 604 sub setuppermissions {
|
|
|
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"}); |
} |
} |
Line 656 sub handle_save_or_undo {
|
Line 657 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; } |
Line 671 sub handle_save_or_undo {
|
Line 669 sub handle_save_or_undo {
|
$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; |
Line 754 sub analyze {
|
Line 753 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 = ['<font color="red">'.&mt('Error').'</font>']; |
|
} |
|
$seedexample{join("\0",$part,$i,@{$answer_part})}= |
|
$thisseed; |
|
$i++; |
|
} |
} |
} |
push( @{ $overall{$part.'.answer'} }, |
|
[@{ $analyze{$part.'.answer'} }]); |
|
$seedexample{join("\0",@{ $analyze{$part.'.answer'}})}=$thisseed; |
|
} |
} |
} |
} |
} |
} |
Line 769 sub analyze {
|
Line 775 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 884 sub renderpage {
|
Line 896 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 968 sub newproblem {
|
Line 987 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 985 sub newproblem {
|
Line 1004 sub newproblem {
|
my $instructions; |
my $instructions; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page("Create New $extension"); |
&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', |
|
'resource' => 'resource', |
|
'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); |
|
$start_page |
$start_page |
<h1>$lt{'create'} $extension $lt{'resource'}</h1> |
<h1>".&mt("Creating a new $extension 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 1047 sub handler {
|
Line 1059 sub handler {
|
} |
} |
&Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade"); |
&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 ) { |