查看作业代码着色
This commit is contained in:
parent
d1315e35b5
commit
c98e9fc639
|
@ -25,8 +25,8 @@
|
|||
|
||||
<li >
|
||||
<span class="tit_fb ">编程代码:</span>
|
||||
<div class="showHworkP break_word"><pre class="fontGrey2 font_cus"><%= text_format(work.description) if work.description%>
|
||||
</pre>
|
||||
<div class="showHworkP break_word"><pre id="work-src" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code">
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
|
||||
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
|
||||
<% end %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#RSide").removeAttr("id");
|
||||
|
|
|
@ -4,6 +4,31 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0){
|
|||
else{
|
||||
<% if @homework.homework_type == 2%>
|
||||
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
|
||||
|
||||
var program_name = "text/x-csrc";
|
||||
var language = <%= @homework.language %>;
|
||||
if (language == 1) {
|
||||
program_name = 'text/x-csrc';
|
||||
} else if(language==2){
|
||||
program_name = 'text/x-c++src';
|
||||
}else if(language==3){
|
||||
program_name = 'text/x-cython';
|
||||
} else if(language==4){
|
||||
program_name = 'text/x-java';
|
||||
}
|
||||
|
||||
var editor = CodeMirror(document.getElementById("work-code"), {
|
||||
mode: {name: program_name,
|
||||
version: 2,
|
||||
singleLineStringErrors: false},
|
||||
lineNumbers: true,
|
||||
indentUnit: 2,
|
||||
matchBrackets: true,
|
||||
readOnly: true,
|
||||
value: document.getElementById("work-src").innerText
|
||||
}
|
||||
);
|
||||
|
||||
<% else%>
|
||||
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
|
||||
<% end%>
|
||||
|
|
Loading…
Reference in New Issue