JAVA语言支持

This commit is contained in:
guange 2015-09-24 15:09:15 +08:00
parent d727097ed2
commit 0b4c8b05f1
4 changed files with 1737 additions and 1706 deletions

View File

@ -4,6 +4,6 @@ class HomeworkDetailPrograming < ActiveRecord::Base
belongs_to :homework_common
def language_name
%W(C C++ Python).at(self.language.to_i - 1)
%W(C C++ Python Java).at(self.language.to_i - 1)
end
end

View File

@ -4,7 +4,7 @@
<div class="HomeWorkCon">
<div class="mt15">
<select class="InputBox W120 language_type" >
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
</select>
</div>
<% if edit_mode && homework.is_program_homework? %>

File diff suppressed because it is too large Load Diff

View File

@ -153,6 +153,8 @@ $(function(){
language = 'C++';
}else if($('select.language_type').val() == 3){
language = 'Python';
}else if($('select.language_type').val() == 4){
language = 'Java';
}
if (valid) {
@ -199,8 +201,33 @@ $(function(){
program_name = 'text/x-c++src';
}else if(language==3){
program_name = 'text/x-cython';
} else if(language==4){
program_name = 'text/x-java';
}
if ($('#program-src').val().length<=0) {
if(language==4)
$('#program-src').val('\
import java.io.*;\n\
import java.util.*;\n\
\n\
//请一定不要修改类名\n\
class Main\n\
{\n\
public static void main (String args[])\n\
{\n\
//获取参数方式\n\
//Scanner in = new Scanner(System.in);\n\
//int a = in.nextInt();\n\
//int b = in.nextInt();\n\
\n\
//您的代码\n\
}\n\
}\n\
');
};
var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {
mode: {name: program_name,
version: 2,