version 1.325, 2011/03/07 19:42:21
|
version 1.343, 2014/01/15 14:46:27
|
Line 163 sub get_target {
|
Line 163 sub get_target {
|
} |
} |
} |
} |
# |
# |
# End of Construction Space |
# End of Authoring Space |
# |
# |
} |
} |
# |
# |
Line 246 sub check_slot_access {
|
Line 246 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); |
|
my $now = time; |
|
my $num_usable_slots = 0; |
foreach my $slot (@slots) { |
foreach my $slot (@slots) { |
$slot =~ s/(^\s*|\s*$)//g; |
$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); |
if ($slot{'starttime'} < time && |
next if ($slot{'endtime'} < $now); |
$slot{'endtime'} > time && |
$num_usable_slots ++; |
|
if ($slot{'starttime'} < $now && |
|
$slot{'endtime'} > $now && |
&Apache::loncommon::check_ip_acc($slot{'ip'})) { |
&Apache::loncommon::check_ip_acc($slot{'ip'})) { |
&Apache::lonxml::debug("$slot is good"); |
&Apache::lonxml::debug("$slot is good"); |
$slotstatus='NEEDS_CHECKIN'; |
$slotstatus='NEEDS_CHECKIN'; |
$returned_slot=\%slot; |
$returned_slot=\%slot; |
$slot_name=$slot; |
$slot_name=$slot; |
last; |
last; |
} |
} |
} |
} |
if ($slotstatus eq 'NEEDS_CHECKIN' && |
if ($slotstatus eq 'NEEDS_CHECKIN' && |
&proctor_checked_in($slot_name,$returned_slot,$type)) { |
&proctor_checked_in($slot_name,$returned_slot,$type)) { |
Line 299 sub check_slot_access {
|
Line 303 sub check_slot_access {
|
# However, the problem is not closed, and potentially, another slot might be |
# However, the problem is not closed, and potentially, another slot might be |
# used to gain access to it to work on it, until the due date is reached, and the |
# used to gain access to it to work on it, until the due date is reached, and the |
# problem then becomes CLOSED. Therefore return the slotstatus - |
# problem then becomes CLOSED. Therefore return the slotstatus - |
# (which will be NOT_IN_SLOT). |
# (which will be one of: NOT_IN_A_SLOT, RESERVABLE, RESERVABLE_LATER, or NOTRESERVABLE. |
if (!defined($slot_name) |
if (!defined($slot_name) && $type eq 'problem') { |
&& $checkedin |
if ($slotstatus eq 'NOT_IN_A_SLOT') { |
&& $type eq 'problem') { |
if (!$num_usable_slots) { |
return ($slotstatus); |
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my ($symb)=&Apache::lonnet::whichuser(); |
|
$slotstatus = 'NOTRESERVABLE'; |
|
my ($reservable_now_order,$reservable_now,$reservable_future_order, |
|
$reservable_future) = |
|
&Apache::loncommon::get_future_slots($cnum,$cdom,$now,$symb); |
|
if ((ref($reservable_now_order) eq 'ARRAY') && (ref($reservable_now) eq 'HASH')) { |
|
if (@{$reservable_now_order} > 0) { |
|
$slotstatus = 'RESERVABLE'; |
|
$datemsg = $reservable_now->{$reservable_now_order->[-1]}{'endreserve'}; |
|
} |
|
} |
|
unless ($slotstatus eq 'RESERVABLE') { |
|
if ((ref($reservable_future_order) eq 'ARRAY') && (ref($reservable_future) eq 'HASH')) { |
|
if (@{$reservable_future_order} > 0) { |
|
$slotstatus = 'RESERVABLE_LATER'; |
|
$datemsg = $reservable_future->{$reservable_future_order->[0]}{'startreserve'}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($slotstatus,$datemsg); |
} |
} |
|
|
if ($slotstatus eq 'NOT_IN_A_SLOT' |
if ($slotstatus eq 'NOT_IN_A_SLOT' |
Line 376 sub check_access {
|
Line 405 sub check_access {
|
$date=&mt("can not be accessed from your location."); |
$date=&mt("can not be accessed from your location."); |
return($status,$date); |
return($status,$date); |
} |
} |
|
if ($env{'form.grade_imsexport'}) { |
|
if (($env{'request.course.id'}) && |
|
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
|
return ('SHOW_ANSWER'); |
|
} |
|
} |
foreach my $temp ("opendate","duedate","answerdate") { |
foreach my $temp ("opendate","duedate","answerdate") { |
$lastdate = $date; |
$lastdate = $date; |
if ($temp eq 'duedate') { |
if ($temp eq 'duedate') { |
Line 417 sub check_access {
|
Line 451 sub check_access {
|
$datemsg=$date; |
$datemsg=$date; |
} elsif ($type eq 'opendate') { |
} elsif ($type eq 'opendate') { |
$status='CLOSED'; |
$status='CLOSED'; |
$datemsg = &mt("will open on")." $date"; |
$datemsg = &mt('will open on [_1]',$date); |
} elsif ($type eq 'duedate') { |
} elsif ($type eq 'duedate') { |
$status='CAN_ANSWER'; |
$status='CAN_ANSWER'; |
$datemsg = &mt("is due at")." $date"; |
$datemsg = &mt('is due at [_1]',$date); |
} elsif ($type eq 'answerdate') { |
} elsif ($type eq 'answerdate') { |
$status='CLOSED'; |
$status='CLOSED'; |
$datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; |
$datemsg = &mt('was due on [_1], and answers will be available on [_2]', |
|
$lastdate,$date); |
} |
} |
} |
} |
if ($status eq 'CAN_ANSWER' || |
if ($status eq 'CAN_ANSWER' || |
Line 434 sub check_access {
|
Line 469 sub check_access {
|
if ( $tries eq '' ) { $tries = '0'; } |
if ( $tries eq '' ) { $tries = '0'; } |
if ( $maxtries eq '' && |
if ( $maxtries eq '' && |
$env{'request.state'} ne 'construct') { $maxtries = '2'; } |
$env{'request.state'} ne 'construct') { $maxtries = '2'; } |
|
$Apache::lonhomework::results{'resource.'.$id.'.maxtries'}=$maxtries; |
if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } |
if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } |
# if (correct and show prob status) or excused then CANNOT_ANSWER |
# if (correct and show prob status) or excused then CANNOT_ANSWER |
if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/ |
if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/) |
&& |
&& (&show_problem_status()) ) { |
&show_problem_status() |
if (($Apache::lonhomework::history{"resource.$id.awarded"} >= 1) || |
&& |
(&Apache::lonnet::EXT("resource.$id.retrypartial") !~/^1|on|yes$/i)) { |
$Apache::lonhomework::history{"resource.$id.awarded"}==1) |
$status = 'CANNOT_ANSWER'; |
|| |
} |
$Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { |
} elsif ($Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { |
$status = 'CANNOT_ANSWER'; |
$status = 'CANNOT_ANSWER'; |
} |
} |
if ($status eq 'CANNOT_ANSWER' |
if ($status eq 'CANNOT_ANSWER' |
Line 473 sub check_access {
|
Line 509 sub check_access {
|
# return ('UNCHECKEDOUT','needs to be checked out'); |
# return ('UNCHECKEDOUT','needs to be checked out'); |
#} |
#} |
|
|
|
|
&Apache::lonxml::debug("sending back :$status:$datemsg:"); |
&Apache::lonxml::debug("sending back :$status:$datemsg:"); |
if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) { |
if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) { |
&Apache::lonxml::debug("should be allowed to browse a resource when closed"); |
&Apache::lonxml::debug("should be allowed to browse a resource when closed"); |
Line 573 sub showhashsubset {
|
Line 608 sub showhashsubset {
|
|
|
sub setuppermissions { |
sub setuppermissions { |
$Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$env{'request.filename'}); |
$Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$env{'request.filename'}); |
|
unless ($Apache::lonhomework::browse eq 'F') { |
|
$Apache::lonhomework::browse=&Apache::lonnet::allowed('bro',$env{'request.filename'}); |
|
} |
my $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
my $viewgrades = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
if (! $viewgrades && |
if (! $viewgrades && |
exists($env{'request.course.sec'}) && |
exists($env{'request.course.sec'}) && |
Line 632 sub setupheader {
|
Line 670 sub setupheader {
|
} |
} |
|
|
sub handle_save_or_undo { |
sub handle_save_or_undo { |
my ($request,$problem,$result) = @_; |
my ($request,$problem,$result,$getobjref) = @_; |
|
|
my $file = &Apache::lonnet::filelocation("",$request->uri); |
my $file = &Apache::lonnet::filelocation("",$request->uri); |
my $filebak =$file.".bak"; |
my $filebak =$file.".bak"; |
Line 675 sub handle_save_or_undo {
|
Line 713 sub handle_save_or_undo {
|
my $fh=Apache::File->new(">$file"); |
my $fh=Apache::File->new(">$file"); |
if (defined($fh)) { |
if (defined($fh)) { |
print $fh $$result; |
print $fh $$result; |
|
if (ref($getobjref) eq 'SCALAR') { |
|
if ($file =~ m{([^/]+)\.(html?)$}) { |
|
my $fname = $1; |
|
my $ext = $2; |
|
my $path = $file; |
|
$path =~ s/\Q$fname\E\.\Q$ext\E$//; |
|
my (%allfiles,%codebase); |
|
&Apache::lonnet::extract_embedded_items($file,\%allfiles, |
|
\%codebase,$result); |
|
if (keys(%allfiles) > 0) { |
|
my $url = $request->uri; |
|
my $state = <<STATE; |
|
<input type="hidden" name="action" value="upload_embedded" /> |
|
<input type="hidden" name="url" value="$url" /> |
|
STATE |
|
$$getobjref = "<h3>".&mt("Reference Warning")."</h3>". |
|
"<p>".&mt("Completed upload of the file. This file contained references to other files.")."</p>". |
|
"<p>".&mt("Please select the locations from which the referenced files are to be uploaded.")."</p>". |
|
&Apache::loncommon::ask_for_embedded_content($url,$state,\%allfiles,\%codebase, |
|
{'error_on_invalid_names' => 1, |
|
'ignore_remote_references' => 1,}); |
|
} |
|
} |
|
} |
} else { |
} else { |
&Apache::lonxml::info('<span class="LC_error">'. |
&Apache::lonxml::info('<span class="LC_error">'. |
&mt("Unable to write to [_1]", |
&mt("Unable to write to [_1]", |
Line 692 sub analyze_header {
|
Line 754 sub analyze_header {
|
my $js = &Apache::structuretags::setmode_javascript(); |
my $js = &Apache::structuretags::setmode_javascript(); |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace(), |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
'text' => 'Construction Space'}, |
'text' => 'Authoring Space'}, |
{'href' => '', |
{'href' => '', |
'text' => 'Problem Testing'}, |
'text' => 'Problem Testing'}, |
{'href' => '', |
{'href' => '', |
Line 744 sub analyze {
|
Line 806 sub analyze {
|
my $rndseed=$env{'form.rndseed'}; |
my $rndseed=$env{'form.rndseed'}; |
&analyze_header($request); |
&analyze_header($request); |
my %prog_state= |
my %prog_state= |
&Apache::lonhtmlcommon::Create_PrgWin($request,&mt('Analyze Progress'), |
&Apache::lonhtmlcommon::Create_PrgWin($request,$env{'form.numtoanalyze'}); |
&mt('Getting Problem Variants'), |
|
$env{'form.numtoanalyze'}, |
|
'inline',undef); |
|
for(my $i=1;$i<$env{'form.numtoanalyze'}+1;$i++) { |
for(my $i=1;$i<$env{'form.numtoanalyze'}+1;$i++) { |
&Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,'last problem'); |
&mt('last problem')); |
|
if (&Apache::loncommon::connection_aborted($request)) { return; } |
if (&Apache::loncommon::connection_aborted($request)) { return; } |
my $thisseed=$i+$rndseed; |
my $thisseed=$i+$rndseed; |
my $subresult=&Apache::lonnet::ssi($request->uri, |
my $subresult=&Apache::lonnet::ssi($request->uri, |
Line 759 sub analyze {
|
Line 817 sub analyze {
|
(my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); |
(my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
my @parts; |
my @parts; |
if (defined(@{ $analyze{'parts'} })) { |
if (ref($analyze{'parts'}) eq 'ARRAY') { |
@parts=@{ $analyze{'parts'} }; |
@parts=@{ $analyze{'parts'} }; |
} |
} |
foreach my $part (@parts) { |
foreach my $part (@parts) { |
Line 792 sub analyze {
|
Line 850 sub analyze {
|
} |
} |
} |
} |
} |
} |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state,&mt('Analyzing Results')); |
&mt('Analyzing Results')); |
|
$request->print('<hr />' |
$request->print('<hr />' |
.'<h3>' |
.'<h3>' |
.&mt('List of possible answers') |
.&mt('List of possible answers') |
.'</h3>' |
.'</h3>' |
); |
); |
foreach my $part (sort(keys(%allparts))) { |
foreach my $part (sort(keys(%allparts))) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
if ((ref($overall{$part.'.answer'}) eq 'ARRAY') && |
|
(@{$overall{$part.'.answer'}} > 0)) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] }); |
my $num_cols=scalar(@{ $overall{$part.'.answer'}[$i][0] }); |
$request->print(&Apache::loncommon::start_data_table() |
$request->print(&Apache::loncommon::start_data_table() |
Line 898 sub editxmlmode {
|
Line 956 sub editxmlmode {
|
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
if ($problem eq -1) { |
if ($problem eq -1) { |
&Apache::lonxml::error( |
&Apache::lonxml::error( |
'<b> ' |
'<p class="LC_error">' |
.&mt('Unable to find [_1]', |
.&mt('Unable to find [_1]', |
'<span class="LC_filename">'.$file.'</span>') |
'<span class="LC_filename">'.$file.'</span>') |
.'</b>'); |
.'</p>'); |
|
|
$problem=''; |
$problem=''; |
} |
} |
Line 930 sub editxmlmode {
|
Line 988 sub editxmlmode {
|
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); |
&Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace(), |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
'text' => 'Construction Space'}, |
'text' => 'Authoring Space'}, |
{'href' => '', |
{'href' => '', |
'text' => 'Problem Editing'}]; |
'text' => 'Problem Editing'}]; |
|
|
Line 1008 sub renderpage {
|
Line 1066 sub renderpage {
|
$problem=''; |
$problem=''; |
my $filename=(split('/',$file))[-1]; |
my $filename=(split('/',$file))[-1]; |
my $error = |
my $error = |
"<b> ".&mt('Unable to find [_1]', |
&mt('Unable to find [_1]', |
'<span class="LC_filename">'.$filename.'</span>') |
'<span class="LC_filename">'.$filename.'</span>'); |
."</b>"; |
|
$result.= |
$result.= |
&Apache::loncommon::simple_error_page($request,'Not available', |
&Apache::loncommon::simple_error_page($request,'Not available', |
$error); |
$error,{'no_auto_mt_msg' => 1}); |
return; |
return; |
} |
} |
|
|
Line 1074 sub get_template_list {
|
Line 1131 sub get_template_list {
|
'/templates/*.'.$glob_extension); |
'/templates/*.'.$glob_extension); |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
(&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')), |
(&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')), |
&mt(&Apache::lonnet::metadata($_, 'help'))]} (@files); |
&Apache::lonnet::metadata($_, 'help')]} (@files); |
@files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files); |
@files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files); |
my ($midpoint,$seconddiv,$numfiles); |
my ($midpoint,$seconddiv,$numfiles); |
|
my @noexamplelink = ('blank.problem','blank.library','script.library'); |
$numfiles = 0; |
$numfiles = 0; |
foreach my $file (@files) { |
foreach my $file (@files) { |
next if ($file->[1] !~ /\S/); |
next if ($file->[1] !~ /\S/); |
Line 1092 sub get_template_list {
|
Line 1150 sub get_template_list {
|
my $count = 0; |
my $count = 0; |
my $currentcategory=''; |
my $currentcategory=''; |
my $first = 1; |
my $first = 1; |
|
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
foreach my $file (@files) { |
foreach my $file (@files) { |
next if ($file->[1] !~ /\S/); |
next if ($file->[1] !~ /\S/); |
if ($file->[2] ne $currentcategory) { |
if ($file->[2] ne $currentcategory) { |
Line 1114 sub get_template_list {
|
Line 1173 sub get_template_list {
|
if ($file->[3]) { |
if ($file->[3]) { |
$result.=&Apache::loncommon::help_open_topic($file->[3]); |
$result.=&Apache::loncommon::help_open_topic($file->[3]); |
} |
} |
|
# Provide example link |
my $filename=$file->[0]; |
my $filename=$file->[0]; |
$filename=~s/^\/home\/httpd\/html//; |
$filename=~s{^\Q$londocroot\E}{}; |
$result.=' <span class="LC_fontsize_small">' |
if (!(grep $filename =~ $_, @noexamplelink)) { |
.'<a href="'.$filename.'?inhibitmenu=yes" target="sample">'.&mt('Example').'</a>' |
$result .= ' <span class="LC_fontsize_small">' |
.'</span><br />'."\n"; |
.&Apache::loncommon::modal_link( |
|
$filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample') |
|
.'</span>'; |
|
}; |
|
$result .= '<br />'."\n"; |
$count ++; |
$count ++; |
} |
} |
if ($numfiles > 0) { |
if ($numfiles > 0) { |
Line 1151 sub newproblem {
|
Line 1215 sub newproblem {
|
&renderpage($request,$dest); |
&renderpage($request,$dest); |
} else { |
} else { |
my $url=&HTML::Entities::encode($request->uri,'<>&"'); |
my $url=&HTML::Entities::encode($request->uri,'<>&"'); |
my $shownurl=$url; |
|
$shownurl=~s-^/~-/priv/-; |
|
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $errormsg; |
my $errormsg; |
my $instructions; |
my $instructions; |
my $brcrum = [{'href' => &Apache::loncommon::authorspace(), |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), |
'text' => 'Construction Space'}, |
'text' => 'Authoring Space'}, |
{'href' => '', |
{'href' => '', |
'text' => "Create New $extension"}]; |
'text' => "Create New $extension"}]; |
my $start_page = |
my $start_page = |
Line 1171 sub newproblem {
|
Line 1233 sub newproblem {
|
.'<h1>'.&mt("Creating a new $extension resource.")."</h1> |
.'<h1>'.&mt("Creating a new $extension resource.")."</h1> |
$errormsg |
$errormsg |
".&mt("The requested file [_1] currently does not exist.", |
".&mt("The requested file [_1] currently does not exist.", |
'<span class="LC_filename">'.$shownurl.'</span>').' |
'<span class="LC_filename">'.$url.'</span>').' |
<p class="LC_info"> |
<p class="LC_info"> |
'.&mt("To create a new $extension, select a template from the". |
'.&mt("To create a new $extension, select a template from the". |
" list below. Then click on the \"Create $extension\" button.").' |
" list below. Then click on the \"Create $extension\" button.").' |