version 1.343, 2014/01/15 14:46:27
|
version 1.348, 2015/01/27 08:40:41
|
Line 541 sub due_date {
|
Line 541 sub due_date {
|
} else { |
} else { |
$date = $due_date; |
$date = $due_date; |
} |
} |
return $date |
return $date; |
} |
} |
|
|
sub seconds_to_human_length { |
sub seconds_to_human_length { |
Line 590 sub showarray {
|
Line 590 sub showarray {
|
sub showhashsubset { |
sub showhashsubset { |
my ($hash,$keyre) = @_; |
my ($hash,$keyre) = @_; |
my $resultkey; |
my $resultkey; |
foreach $resultkey (sort keys %$hash) { |
foreach $resultkey (sort(keys(%$hash))) { |
if ($resultkey !~ /$keyre/) { next; } |
if ($resultkey !~ /$keyre/) { next; } |
if (ref($$hash{$resultkey}) eq 'ARRAY' ) { |
if (ref($$hash{$resultkey}) eq 'ARRAY' ) { |
&Apache::lonxml::debug("$resultkey ---- ". |
&Apache::lonxml::debug("$resultkey ---- ". |
Line 768 sub analyze_header {
|
Line 768 sub analyze_header {
|
.&Apache::loncommon::head_subbox( |
.&Apache::loncommon::head_subbox( |
&Apache::loncommon::CSTR_pageheader()); |
&Apache::loncommon::CSTR_pageheader()); |
$result .= |
$result .= |
&Apache::lonxml::message_location().' |
'<form name="lonhomework" method="post" action="'. |
<form name="lonhomework" method="post" action="'. |
|
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
'<input type="hidden" name="problemmode" value="'. |
'<input type="hidden" name="problemmode" value="'. |
$env{'form.problemmode'}.'" />'. |
$env{'form.problemmode'}.'" />'. |
Line 783 sub analyze_header {
|
Line 782 sub analyze_header {
|
<input type="button" name="submitmode" value="'.&mt("View").'" '. |
<input type="button" name="submitmode" value="'.&mt("View").'" '. |
'onclick="javascript:setmode(this.form,'."'view'".')" /> |
'onclick="javascript:setmode(this.form,'."'view'".')" /> |
<hr /> |
<hr /> |
</div> |
</div>' |
</form>'; |
.&Apache::lonxml::message_location(). |
|
'</form>'; |
&Apache::lonxml::add_messages(\$result); |
&Apache::lonxml::add_messages(\$result); |
$request->print($result); |
$request->print($result); |
$request->rflush(); |
$request->rflush(); |
Line 963 sub editxmlmode {
|
Line 963 sub editxmlmode {
|
|
|
$problem=''; |
$problem=''; |
} |
} |
|
|
if (($env{'form.problemmode'} eq 'saveeditxml') || |
if (($env{'form.problemmode'} eq 'saveeditxml') || |
($env{'form.problemmode'} eq 'saveviewxml') || |
($env{'form.problemmode'} eq 'saveviewxml') || |
($env{'form.problemmode'} eq 'undoxml')) { |
($env{'form.problemmode'} eq 'undoxml')) { |
my $error=&handle_save_or_undo($request,\$problem, |
my $error=&handle_save_or_undo($request,\$problem, |
\$env{'form.editxmltext'}); |
\$env{'form.editxmltext'}); |
Line 1011 sub editxmlmode {
|
Line 1010 sub editxmlmode {
|
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="post" action="'. |
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="post" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&Apache::structuretags::remember_problem_state().' |
&Apache::structuretags::remember_problem_state().' |
<div class="LC_edit_problem_editxml_header"> |
<div class="LC_edit_problem_header"> |
<table class="LC_edit_problem_header_title"><tr><td> |
<div class="LC_edit_problem_header_title">'. |
<h2>'.&mt('Problem Editing').' '.&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').'</h2> |
&mt('Problem Editing').' '.&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index'). |
</td><td align="right"> |
'</div><div class="LC_edit_actionbar" id="actionbar">'; |
'.&Apache::loncommon::helpLatexCheatsheet('Problem_LON-CAPA_Functions','Script Functions').' |
|
</td></tr> |
|
</table>'; |
|
|
|
$result.='<input type="hidden" name="problemmode" value="saveedit" />'. |
$result.='<input type="hidden" name="problemmode" value="saveedit" />'. |
&Apache::structuretags::problem_edit_buttons('editxml'); |
&Apache::structuretags::problem_edit_buttons('editxml'); |
|
$result.='<div class="LC_edit_problem_discards">'; |
|
|
|
unless ($env{'environment.nocodemirror'}) { |
|
# dropdown menues |
|
$result .= '<ol class="LC_primary_menu LC_floatleft">'. |
|
&Apache::lonmenu::create_submenu("#", "", &mt("Insert Menu"), &Apache::structuretags::insert_menu_datastructure(),"").'</ol>'; |
|
} |
|
$result .= '<ol class="LC_primary_menu LC_floatleft">'. |
|
Apache::lonmenu::create_submenu("#", "", &mt("Help"), &Apache::structuretags::helpmenu_datastructure(),"").'</ol>'; |
|
$result.="</div>"; |
|
|
$result.='<hr style="clear:both;" />'.&Apache::lonxml::message_location().'</div>'. |
$result.='<hr style="clear:both;visibility:hidden" /></div></div>'.&Apache::lonxml::message_location(). |
'<textarea '.&Apache::edit::element_change_detection(). |
&Apache::loncommon::xmleditor_js(). |
|
'<textarea '.&Apache::edit::element_change_detection(). |
' rows="'.$rows.'" cols="'.$cols.'" style="width:100%" '. |
' rows="'.$rows.'" cols="'.$cols.'" style="width:100%" '. |
' name="editxmltext" id="LC_editxmltext">'. |
' name="editxmltext" id="LC_editxmltext">'. |
&HTML::Entities::encode($problem,'<>&"').'</textarea> |
&HTML::Entities::encode($problem,'<>&"').'</textarea> |
<div id="LC_aftertextarea"> |
<div id="LC_aftertextarea"> |
</div> |
</div> |
</form>'.&Apache::loncommon::end_page(); |
</form>'; |
&Apache::lonxml::add_messages(\$result); |
my $resource = $env{'request.ambiguous'}; |
$request->print($result); |
unless($env{'environment.nocodemirror'}){ |
|
|
|
$result .= '<link rel="stylesheet" href="/adm/codemirror/codemirror-combined-xml.css"> |
|
<script src="/adm/codemirror/codemirror-compressed-xml.js"></script> |
|
<script> |
|
CodeMirror.defineMode("mixedmode", function(config) { |
|
return CodeMirror.multiplexingMode( |
|
CodeMirror.getMode(config, "xml"), |
|
{ |
|
open: "\<script type=\"loncapa/perl\"\>", close: "\</script\>", |
|
mode: CodeMirror.getMode(config, "perl"), |
|
delimStyle: "tag", |
|
} |
|
); |
|
}); |
|
var cm = CodeMirror.fromTextArea(document.getElementById("LC_editxmltext"), |
|
{ |
|
mode: "mixedmode", |
|
lineWrapping: true, |
|
lineNumbers: true, |
|
tabSize: 4, |
|
indentUnit: 4, |
|
|
|
autoCloseTags: true, |
|
autoCloseBrackets: true, |
|
height: "auto", |
|
styleActiveLine: true, |
|
|
|
extraKeys: { |
|
"Tab": "indentMore", |
|
"Shift-Tab": "indentLess", |
|
} |
|
}); |
|
restoreScrollPosition("'.$resource.'"); |
|
</script>'; |
|
} |
|
$result .= &Apache::loncommon::end_page(); |
|
&Apache::lonxml::add_messages(\$result); |
|
$request->print($result); |
} |
} |
return ''; |
return ''; |
} |
} |
Line 1066 sub renderpage {
|
Line 1111 sub renderpage {
|
$problem=''; |
$problem=''; |
my $filename=(split('/',$file))[-1]; |
my $filename=(split('/',$file))[-1]; |
my $error = |
my $error = |
&mt('Unable to find [_1]', |
'<p class="LC_error">' |
'<span class="LC_filename">'.$filename.'</span>'); |
.&mt('Unable to find [_1]', |
|
'<span class="LC_filename">'.$filename.'</span>') |
|
."</p>"; |
$result.= |
$result.= |
&Apache::loncommon::simple_error_page($request,'Not available', |
&Apache::loncommon::simple_error_page($request,'Not available', |
$error,{'no_auto_mt_msg' => 1}); |
$error,{'no_auto_mt_msg' => 1}); |
Line 1118 sub finished_parsing {
|
Line 1165 sub finished_parsing {
|
undef($Apache::lonhomework::parsing_a_task); |
undef($Apache::lonhomework::parsing_a_task); |
} |
} |
|
|
sub get_template_list { |
# function extracted from get_template_html |
|
# returns "key" -> list |
|
# key: path of template |
|
# value 1: title |
|
# value 2: category |
|
# value 3: name of help topic ??? |
|
sub get_template_list{ |
|
my ($extension) = @_; |
|
|
|
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
|
'/templates/*.'.$extension); |
|
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
|
(&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')), |
|
&mt(&Apache::lonnet::metadata($_, 'help'))]} (@files); |
|
@files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files); |
|
return @files; |
|
} |
|
|
|
sub get_template_html { |
my ($extension) = @_; |
my ($extension) = @_; |
my $result; |
my $result; |
my @allnames; |
my @allnames; |
Line 1127 sub get_template_list {
|
Line 1192 sub get_template_list {
|
if ($extension eq 'survey' || $extension eq 'exam') { |
if ($extension eq 'survey' || $extension eq 'exam') { |
$glob_extension = 'problem'; |
$glob_extension = 'problem'; |
} |
} |
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
my @files = &get_template_list($extension); |
'/templates/*.'.$glob_extension); |
|
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
|
(&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')), |
|
&Apache::lonnet::metadata($_, 'help')]} (@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'); |
my @noexamplelink = ('blank.problem','blank.library','script.library'); |
$numfiles = 0; |
$numfiles = 0; |
Line 1176 sub get_template_list {
|
Line 1236 sub get_template_list {
|
# Provide example link |
# Provide example link |
my $filename=$file->[0]; |
my $filename=$file->[0]; |
$filename=~s{^\Q$londocroot\E}{}; |
$filename=~s{^\Q$londocroot\E}{}; |
if (!(grep $filename =~ $_, @noexamplelink)) { |
if (!(grep($filename =~ /\Q$_\E$/,@noexamplelink))) { |
$result .= ' <span class="LC_fontsize_small">' |
$result .= ' <span class="LC_fontsize_small">' |
.&Apache::loncommon::modal_link( |
.&Apache::loncommon::modal_link( |
$filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample') |
$filename.'?inhibitmenu=yes',&mt('Example'),600,420,'sample') |
.'</span>'; |
.'</span>'; |
}; |
} |
$result .= '<br />'."\n"; |
$result .= '<br />'."\n"; |
$count ++; |
$count ++; |
} |
} |
Line 1194 sub get_template_list {
|
Line 1254 sub get_template_list {
|
sub newproblem { |
sub newproblem { |
my ($request) = @_; |
my ($request) = @_; |
|
|
|
if ($env{'form.mode'} eq 'blank'){ |
|
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
|
&File::Copy::copy('/home/httpd/html/res/adm/includes/templates/blank.problem',$dest); |
|
&renderpage($request,$dest); |
|
return; |
|
} |
if ($env{'form.template'}) { |
if ($env{'form.template'}) { |
my $file = $env{'form.template'}; |
my $file = $env{'form.template'}; |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
my $dest = &Apache::lonnet::filelocation("",$request->uri); |
Line 1204 sub newproblem {
|
Line 1270 sub newproblem {
|
|
|
my ($extension) = ($request->uri =~ m/\.(\w+)$/); |
my ($extension) = ($request->uri =~ m/\.(\w+)$/); |
&Apache::lonxml::debug("Looking for :$extension:"); |
&Apache::lonxml::debug("Looking for :$extension:"); |
my $templatelist=&get_template_list($extension); |
my $templatelist=&get_template_html($extension); |
if ($env{'form.newfile'} && !$templatelist) { |
if ($env{'form.newfile'} && !$templatelist) { |
# no templates found |
# no templates found |
my $templatefilename = |
my $templatefilename = |
Line 1316 sub handler {
|
Line 1382 sub handler {
|
&renderpage($request,$file); |
&renderpage($request,$file); |
} |
} |
} else { |
} else { |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['mode']); |
# requested file doesn't exist in contruction space |
# requested file doesn't exist in contruction space |
&newproblem($request); |
&newproblem($request); |
} |
} |