From b94f5a54cc7efe2b497f55a9f275f54a0c4ee09f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 27 Jul 2015 10:43:39 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E8=BE=93=E5=85=A5=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E9=9B=86=E5=8F=AA=E8=A6=81=E8=80=81=E5=B8=88?= =?UTF-8?q?=E6=89=8D=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/index.html.erb | 2 +- .../_programing_work_show.html.erb | 69 +++++++++---------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index c0f716ed7..6847da2c7 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -48,7 +48,7 @@
- <% if homework.homework_type == 2 && homework.homework_detail_programing%> + <% if homework.homework_type == 2 && homework.homework_detail_programing && @is_teacher%> "> diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 7081dea8c..b259e20a5 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -24,42 +24,41 @@
-
  • 测试结果: -
  • - - - - - - - <%@homework.homework_tests.each do |test|%> - "> - - - <% student_work_test = StudentWorkTest.where(:homework_test_id => test.id,:student_work_id => @work.id).first%> - - - - <% end%> - <% student_work_test = @work.student_work_test.first%> - <% if student_work_test && student_work_test.error_msg && !student_work_test.error_msg.empty?%> - - - - <% end%> - - -
    输入输出测试结果
    <%= student_work_test.nil? ? "正在编译" : student_work_test.status_to_s%>
    - <%= student_work_test.error_msg%> -
    -
    - - <% if @is_teacher%> +
  • 测试结果: + + + + + + + + <%@homework.homework_tests.each do |test|%> + "> + + + <% student_work_test = StudentWorkTest.where(:homework_test_id => test.id,:student_work_id => @work.id).first%> + + + + <% end%> + <% student_work_test = @work.student_work_test.first%> + <% if student_work_test && student_work_test.error_msg && !student_work_test.error_msg.empty?%> + + + + <% end%> + + +
    输入输出测试结果
    <%= student_work_test.nil? ? "正在编译" : student_work_test.status_to_s%>
    + <%= student_work_test.error_msg%> +
    +
    +
  • <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> From 81c942a7926ff79f021b6a0c5b80bf1adf9e242c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 27 Jul 2015 15:06:00 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 38 --------------------------- app/views/welcome/course.html.erb | 13 +-------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9ce107f8b..6b14db9bb 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -100,44 +100,6 @@ class WelcomeController < ApplicationController @course_page = FirstPage.find_by_page_type('course') @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117 @logoLink ||= logolink() - - ##3-8月份为查找春季课程,9-2月份为查找秋季课程 - #month_now = Time.now.strftime("%m").to_i - #year_now = Time.new.strftime("%Y").to_i - #(month_now >= 3 && month_now < 9) ? course_term = l(:label_spring) : course_term = l(:label_autumn) - ##year_now -= 1 if year_now < 3 - #@school_id.nil? ? @cur_school_course = [] : @cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term) - ##未登录或者当前学校未开设课程 - #if @cur_school_course.empty? - # @has_course = false - # User.current.logged? ? course_count = 9 : course_count = 10 - # @cur_school_course += find_all_new_hot_course(course_count, @school_id, year_now, course_term) - # while @cur_school_course.count < 9 do - # if course_term == l(:label_spring) - # course_term = l(:label_autumn) - # year_now -= 1 - # else - # course_term = l(:label_spring) - # end - # @cur_school_course += find_all_new_hot_course((10-@cur_school_course.count), nil, year_now, course_term) - # end - #else - # if @cur_school_course.count < 9 - # @has_course = false - # @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, @school_id, year_now, course_term) - # if @cur_school_course.count < 9 - # if course_term == l(:label_spring) - # course_term = l(:label_autumn) - # year_now -= 1 - # else - # course_term = l(:label_spring) - # end - # @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, nil, year_now, course_term) - # end - # else - # @has_course = true - # end - #end end def logolink() diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 143c32dbe..4edec2202 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -56,21 +56,11 @@ <% end %> - - <%= l(:label_welcome_trustie_course) %> + <%= l(:label_welcome_trustie_course) %> <% else %> <% unless @course_page.nil? %> - <%= l(:label_welcome_trustie_course) %> , @@ -112,7 +102,6 @@ course_term = "春季学期" end %> - <%# (month_now >= 3 && month_now < 9) ? course_term = "春季学期" : course_term = "秋季学期" %> <% cur_school_course = @school_id.nil? ? [] : find_miracle_course(10,7,@school_id, year_now, course_term) %> <% if cur_school_course.count == 0 %> From 7c818ce59ac3cbfdcf6c6d996899c95796ad43db Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 27 Jul 2015 16:07:29 +0800 Subject: [PATCH 03/39] =?UTF-8?q?admin=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=8C=89=E5=90=8D=E7=A7=B0=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 13 +++++++++ app/views/admin/schools.html.erb | 44 +++++++++++++++++++++++++++++ config/locales/zh.yml | 1 + config/routes.rb | 1 + lib/redmine.rb | 1 + public/stylesheets/courses.css | 1 - 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/schools.html.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 086ecfb7f..d2c94f5de 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -337,6 +337,19 @@ class AdminController < ApplicationController format.html end end + + #学校列表 + def schools + @q = params[:school_name] + if @q + @schools = School.where("name like '%#{@q}%'") + else + @schools = School.all + end + respond_to do |format| + format.html + end + end #移动端版本管理 def mobile_version @versions = PhoneAppVersion.reorder('created_at desc') diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb new file mode 100644 index 000000000..760a0c5a4 --- /dev/null +++ b/app/views/admin/schools.html.erb @@ -0,0 +1,44 @@ +

    + <%=l(:label_school_plural)%> +

    +<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %> + <%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%> + +<% end %> +
    + +
    + + + + + + + + + + <% @schools.each do |school|%> + "> + + + + + <% end%> + +
    + LOGO + + 学校名称 +
    + <%= image_tag(school.logo_link,width:46,height:46) %> + + + <%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %> + + + <%= link_to("上传logo", edit_organization_path(school.id), :class => 'icon icon-copy') %> + <%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> +
    +
    + +<% html_title(l(:label_project_plural)) -%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 83ccebbe9..1018a213a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -381,6 +381,7 @@ zh: label_organization_choose: --请选择组织-- label_organization_name: 组织名称 label_organization_list: 组织列表 + label_school_plural: 学校列表 label_organization_new: 新建组织 label_organization_edit: 修改组织 label_project_plural: 项目列表 diff --git a/config/routes.rb b/config/routes.rb index 1ae607eb7..d353c60ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -670,6 +670,7 @@ RedmineApp::Application.routes.draw do match 'admin/test_email', :via => :get match 'admin/default_configuration', :via => :post get 'admin/organization' + get 'admin/schools' resources :auth_sources do member do diff --git a/lib/redmine.rb b/lib/redmine.rb index 3043cfe5d..0f6c14b8a 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -369,6 +369,7 @@ Redmine::MenuManager.map :admin_menu do |menu| menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural + menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 778a474cd..00a2f0034 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -665,7 +665,6 @@ a:hover.ping_pic{border:1px solid #64bdd9;} .ping_back_tit{ float:left; width:523px; margin-left:10px; } a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;} -.fr{ float:right;} .min_search{ width:140px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; } .li_min_search{ float:right; margin-right:-10px;} .info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;} From 19c515e11ed210611170cccd37bca61ac2a81e31 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 27 Jul 2015 16:15:04 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=8F=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/schools.html.erb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb index 760a0c5a4..b5e649dd0 100644 --- a/app/views/admin/schools.html.erb +++ b/app/views/admin/schools.html.erb @@ -11,20 +11,26 @@ - + - + <% @schools.each do |school|%> "> + diff --git a/app/views/school/upload_logo.html.erb b/app/views/school/upload_logo.html.erb index 97a3f171c..26da7e081 100644 --- a/app/views/school/upload_logo.html.erb +++ b/app/views/school/upload_logo.html.erb @@ -1,5 +1,28 @@ -<%= form_tag({action: :upload},method: "post", multipart: true) do %> - <%= text_field_tag 'school'%> - <%= file_field_tag 'logo' %> - <%= submit_tag('Upload') %> + + +<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true) do %> + <%#= text_field_tag 'school'%> +
    + + <%= image_tag(@school.logo_link, id: "avatar_image", :class=>"school_avatar")%> + 上传图片 + <%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%> +
    +
    + <%= submit_tag('上传') %> + <%= submit_tag('取消') %> +
    +
    <% end %> + diff --git a/config/routes.rb b/config/routes.rb index d353c60ff..280053f60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,17 @@ RedmineApp::Application.routes.draw do end + resources :school do + collection do + + end + + member do + get 'upload_logo' + post 'upload' + end + end + resources :homework_attach do collection do get 'get_homework_member_list' @@ -809,9 +820,6 @@ RedmineApp::Application.routes.draw do post 'school/search_school/', :to => 'school#search_school' get 'school/search_school/', :to => 'school#search_school' - post 'school/upload', :to => 'school#upload' - get 'school/upload_logo', :to => 'school#upload_logo' - ######added by nie match 'tags/show_projects_tags' ########### added by liuping diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d4d309181..3e01d68ff 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2796,4 +2796,15 @@ div.repos_explain{ .upload_img img{max-width: 100%;} #activity .upload_img img{max-width: 580px;} -img,embed{max-width: 100%;} \ No newline at end of file +img,embed{max-width: 100%;} + +img.school_avatar { + background: rgb(245, 245, 245); + padding: 4px; + border: 1px solid #e5dfc7; + float: left; + display: block; + width: 100px; + height: 100px; + max-width: none; +} \ No newline at end of file From 45d5972a93d98b576c57a8a78ed82a283949ccad Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 28 Jul 2015 10:27:45 +0800 Subject: [PATCH 06/39] =?UTF-8?q?=E5=9C=A8=E5=8F=91=E5=B8=83=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=AD=E9=97=B4=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=8F=92=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 16 +- app/views/poll/_new_MC.html.erb | 1 + app/views/poll/_poll_form.html.erb | 186 ++++++++++++++++++++- app/views/poll/_show_MC.html.erb | 18 +- app/views/poll/_show_MCQ.html.erb | 14 +- app/views/poll/_show_mulit.html.erb | 14 +- app/views/poll/_show_single.html.erb | 14 +- app/views/poll/create_poll_question.js.erb | 6 +- public/stylesheets/polls.css | 5 +- 9 files changed, 261 insertions(+), 13 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 758747e02..8f81bc2c6 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -137,11 +137,19 @@ class PollController < ApplicationController @poll_questions.poll_answers.new question_option end end - if @poll_questions.save - respond_to do |format| - format.js - end + # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 + if params[:quest_id] + @is_insert = true + @poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") + @poll_question_num = params[:quest_num].to_i + @poll_questions.question_number = params[:quest_num].to_i + 1 end + if @poll_questions.save + respond_to do |format| + format.js + end + end + end #修改题目 diff --git a/app/views/poll/_new_MC.html.erb b/app/views/poll/_new_MC.html.erb index 8c47baa01..e5f2a6b82 100644 --- a/app/views/poll/_new_MC.html.erb +++ b/app/views/poll/_new_MC.html.erb @@ -1,5 +1,6 @@ <%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> + <% insert_begin = insert_begin %>
    diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 74ca9fb32..0a15143fb 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -6,23 +6,203 @@ function edit_head(){ $("#polls_description").val($("#polls_description_div").html()); } - function add_MC(){ +function chooseQuestionType(quest_type,quest_id){ + $("#div_"+quest_type+"_"+quest_id).css("position", "absolute"); + + $("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30); + + $("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10); + if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') { + $("#div_"+quest_type+"_"+quest_id).css('display', 'none'); + } + else{ + $("#div_"+quest_type+"_"+quest_id).css('display', 'block'); + } +} + +function add_MC(){ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>"); $("#poll_questions_title").focus(); - } - function add_MCQ(){ +} + + function insert_MC(quest_type,quest_num,quest_id){ + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '<% end%>' + ); + $("#poll_questions_title").focus(); +} + +function add_MCQ(){ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>"); $("#poll_questions_title").focus(); +} + +function insert_MCQ(quest_type,quest_num,quest_id){ + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    • '+ + ''+ + ''+ + ''+ + ''+ + '
    • '+ + '
      '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '<% end%>' + ); + $("#poll_questions_title").focus(); } + function add_single(){ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>"); $("#poll_questions_title").focus(); } + + function insert_SINGLE(quest_type,quest_num,quest_id){ + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '<% end%>' + ); + $("#poll_questions_title").focus(); + } function add_mulit(){ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_mulit') %>"); $("#poll_questions_title").focus(); } + function insert_MULIT(quest_type,quest_num,quest_id){ + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+ + '
    '+ + '
    '+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + '
    '+ + ''+ + '
    '+ + '
    '+ + '<% end%>' + ); + $("#poll_questions_title").focus(); + } + //添加标题时确定按钮 function add_poll_question(doc) { diff --git a/app/views/poll/_show_MC.html.erb b/app/views/poll/_show_MC.html.erb index ff8e52f25..9c47894dc 100644 --- a/app/views/poll/_show_MC.html.erb +++ b/app/views/poll/_show_MC.html.erb @@ -1,3 +1,6 @@ +
    @@ -9,9 +12,11 @@ * <%end%>
    + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> +
    + + 序号 + LOGO 学校名称
    + <%= school.id %> + - <%= image_tag(school.logo_link,width:46,height:46) %> + <%= image_tag(school.logo_link,width:40,height:40) %> From 6091369e02b33042749218e39a401eace43da23c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 27 Jul 2015 18:20:20 +0800 Subject: [PATCH 05/39] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=A6=E6=A0=A1logo?= =?UTF-8?q?=E7=9A=84=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=AE=9E=E6=97=B6=E9=A2=84=E8=A7=88=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 6 +++--- app/controllers/school_controller.rb | 17 +++++---------- app/views/admin/schools.html.erb | 4 ++-- app/views/school/upload_logo.html.erb | 31 +++++++++++++++++++++++---- config/routes.rb | 14 +++++++++--- public/stylesheets/application.css | 13 ++++++++++- 6 files changed, 60 insertions(+), 25 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d2c94f5de..a44b58789 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -340,9 +340,9 @@ class AdminController < ApplicationController #学校列表 def schools - @q = params[:school_name] - if @q - @schools = School.where("name like '%#{@q}%'") + @school_name = params[:school_name] + if @school_name + @schools = School.where("name like '%#{@school_name}%'") else @schools = School.all end diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 008fe00fc..3e0c280ac 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -4,28 +4,21 @@ class SchoolController < ApplicationController def upload uploaded_io = params[:logo] - school_id = 0 - schools = School.where("name = ?", params[:school]) - - schools.each do |s| - school_id = s.id - end - + school_id ||= params[:id] unless uploaded_io.nil? File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file| file.write(uploaded_io.read) end - s1 = School.find(school_id) s1.logo_link = '/images/school/'+school_id.to_s+'.png' s1.save - - - end + end + redirect_to admin_schools_url(:school_name => params[:school_name]) end def upload_logo - + @school = School.find params[:id] + @school_name = params[:school_name] end #获取制定学校开设的课程数 diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb index b5e649dd0..0956981e8 100644 --- a/app/views/admin/schools.html.erb +++ b/app/views/admin/schools.html.erb @@ -3,7 +3,7 @@ <%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %> <%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%> - + <% end %>
    @@ -38,7 +38,7 @@
    - <%= link_to("上传logo", edit_organization_path(school.id), :class => 'icon icon-copy') %> + <%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %> <%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
    @@ -29,4 +34,15 @@
    - \ No newline at end of file + + +
    +
    + \ No newline at end of file diff --git a/app/views/poll/_show_MCQ.html.erb b/app/views/poll/_show_MCQ.html.erb index 63b9d1c1f..fb2c03080 100644 --- a/app/views/poll/_show_MCQ.html.erb +++ b/app/views/poll/_show_MCQ.html.erb @@ -12,6 +12,7 @@ <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> +
    @@ -29,4 +30,15 @@
    - \ No newline at end of file + + +
    +
    + \ No newline at end of file diff --git a/app/views/poll/_show_mulit.html.erb b/app/views/poll/_show_mulit.html.erb index 2d52fffb5..ad01d0a3e 100644 --- a/app/views/poll/_show_mulit.html.erb +++ b/app/views/poll/_show_mulit.html.erb @@ -13,9 +13,21 @@ <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> +
    - \ No newline at end of file + + +
    +
    + \ No newline at end of file diff --git a/app/views/poll/_show_single.html.erb b/app/views/poll/_show_single.html.erb index 8caa7b1a5..f5846b6b7 100644 --- a/app/views/poll/_show_single.html.erb +++ b/app/views/poll/_show_single.html.erb @@ -12,8 +12,20 @@ <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> +
    - \ No newline at end of file + + +
    +
    + \ No newline at end of file diff --git a/app/views/poll/create_poll_question.js.erb b/app/views/poll/create_poll_question.js.erb index ac44ebb4c..8a597514e 100644 --- a/app/views/poll/create_poll_question.js.erb +++ b/app/views/poll/create_poll_question.js.erb @@ -1,4 +1,8 @@ +<% if @is_insert %> + $("#poll_content").html('<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll})%>'); +<% else %> $("#new_poll_question").html(""); + $("#poll_content").append("
    " + "
    " + "<% if @poll_questions.question_type == 1%>" + @@ -23,4 +27,4 @@ $("#poll_content").append("
    " + "<% end%>" + "
    " + "
    "); - +<% end %> diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 353ec3937..83fa5089b 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -28,7 +28,7 @@ a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;} #polls div{word-break: break-all;word-wrap: break-word;} .ur_prefix_content{ color:#656565; text-indent:30px; margin-top:10px; } .ur_card{border-top:1px solid #dcdcdc;margin-top:20px; color:#3a3a3a;} -.ur_title{ padding:20px 0px ; float:left; width:604px; } +.ur_title{ padding:20px 0px ; float:left; width:564px; } .ur_required{ font-weight: bold; color:red;} .ur_inputs{ color:#666;} .ur_table{border-top:1px solid #dcdcdc; background:#fff;} @@ -101,10 +101,13 @@ a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;} .ur_editor02{width:648px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px;} a.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } a:hover.ur_button_submit{ background:#0fa9bb; text-decoration:none;} + a.ur_icon_de{ background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px;} a:hover.ur_icon_de{ background:url(images/icons.png) -20px -338px no-repeat;} .ur_icon_edit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px; margin-right:10px;} a:hover.ur_icon_edit{ background:url(images/icons.png) -21px -272px no-repeat;} +.ur_icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px; margin-right:10px;} +a:hover.ur_icon_add{background:url(images/icons.png) -20px -310px no-repeat;} /***弹框***/ .popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} From 6b45702f8c403a7f5b37393ae26b9cb8cbf664d0 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 28 Jul 2015 11:20:21 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E5=A4=84=E5=8F=AF=E4=BB=A5=E8=AE=A9=E5=BC=B9=E5=87=BA=E6=A1=86?= =?UTF-8?q?=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll_form.html.erb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 0a15143fb..b081f4d18 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -2,11 +2,24 @@ - diff --git a/public/javascripts/user.js b/public/javascripts/user.js new file mode 100644 index 000000000..7c7189066 --- /dev/null +++ b/public/javascripts/user.js @@ -0,0 +1,238 @@ +$(function(){ + if($(".top_new").length==0){ + $("#RSide").css("min-height",$("#LSide").height()-30); + } + else{ + $("#RSide").css("min-height",$("#LSide").height()-87); + } + +}); + +//个人动态 +$(function(){ + + function init_editor(params){ + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",height:"80px", + items:['emoticons'], + afterChange:function(){//按键事件 + nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); + }, + afterCreate:function(){ + var toolbar = $("div[class='ke-toolbar']",params.div_form); + $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); + params.toolbar_container.append(toolbar); + } + }).loadPlugin('paste'); + return editor; + } + + function nh_check_field(params){ + var result=true; + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + if(params.content.isEmpty()){ + params.contentmsg.html('内容不能为空'); + params.contentmsg.css({color:'#ff0000'}); + }else{ + params.contentmsg.html('填写正确'); + params.contentmsg.css({color:'#008000'}); + } + params.contentmsg.show(); + } + } + return result; + } + function init_form(params){ + params.form.submit(function(){ + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + if(is_checked){ + if(flag){ + return true; + }else{ + $(this)[0].submit(); + return false; + } + } + return false; + }); + } + function nh_reset_form(params){ + params.form[0].reset(); + params.textarea.empty(); + if(params.editor != undefined){ + params.editor.html(params.textarea.html()); + } + params.contentmsg.hide(); + } + + KindEditor.ready(function(K){ + $("a[nhname='reply_btn']").live('click',function(){ + var params = {}; + params.kindutil = K; + params.container = $(this).parent('div'); + params.div_form = $("div[nhname='div_form']",params.container); + params.form = $("form",params.div_form); + params.textarea = $("textarea[name='user_notes']",params.div_form); + params.contentmsg = $("p[nhname='contentmsg']",params.div_form); + params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); + params.cancel_btn = $("a[nhname='cancel_btn']",params.div_form); + params.submit_btn = $("a[nhname='submit_btn']",params.div_form); + if(params.textarea.data('init') == undefined){ + params.editor = init_editor(params); + init_form(params); + params.cancel_btn.click(function(){ + nh_reset_form(params); + toggleAndSettingWordsVal(params.div_form, params.textarea); + }); + params.submit_btn.click(function(){ + params.form.submit(); + }); + params.textarea.data('init',1); + } + params.cancel_btn.click(); + setTimeout(function(){ + if(!params.div_form.is(':hidden')){ + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); + } + },300); + + }); + + $("div[nhname='new_message']").each(function(){ + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form",params.div_form); + if(params.form==undefined || params.form.length==0){ + return; + } + params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form); + params.contentmsg = $("p[nhname='contentmsg']",params.div_form); + params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); + params.cancel_btn = $("#new_message_cancel_btn"); + params.submit_btn = $("#new_message_submit_btn"); + + if(params.textarea.data('init') == undefined){ + params.editor = init_editor(params); + init_form(params); + params.cancel_btn.click(function(){ + nh_reset_form(params); + }); + params.submit_btn.click(function(){ + params.form.submit(); + }); + params.textarea.data('init',1); + $(this).show(); + } + }); + }); +}); +function init_list_more_div(params){ + var p=params; + p.exbtn.click(function(){ + var isclose = p.container.data('isclose'); + var hasmore = p.container.data('hasmore'); + if(isclose == '1'){ + $("div[nhname='rec']",p.container).show(); + p.container.data('isclose','0'); + change_status_4_list_more_div(params); + return; + } + if(hasmore == '0'){ + change_status_4_list_more_div(params,'get'); + return; + } + var url = p.container.data('url'); + if($("div[nhname='rec']",p.container).length > 0){ + var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id'); + url += "?lastid="+lastid; + var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time'); + if(lasttime != undefined){ + url += "&lasttime="+lasttime; + } + } + $.ajax( {url:url,dataType:'text',success:function(data){ + var html = $("
    "+data+"
    "); + var lens = $("div[nhname='rec']",html).length; + if(lens < p.size){ + p.container.data('hasmore','0'); + } + if(lens>0){ + var currpage = parseInt(p.container.data('currpage'))+1; + p.container.data('currpage',currpage); + p.container.append(html.html()) + } + change_status_4_list_more_div(params,'get'); + p.div.show(); + }} ); + }); + p.clbtn.click(function(){ + var i=0; + $("div[nhname='rec']",p.container).each(function(){ + i++; + if(i> p.size){ + $(this).hide(); + } + }); + p.container.data('isclose','1'); + change_status_4_list_more_div(params); + }); + p.exbtn.click(); +} +function change_status_4_list_more_div(params,opt){ + var p=params; + if($("div[nhname='rec']",p.container).length == 0 && opt != 'get'){ + p.exbtn.click(); + return; + } + var show_lens = $("div[nhname='rec']",p.container).length - $("div[nhname='rec']",p.container).filter(':hidden').length; + if( show_lens > p.size ){ + p.clbtn.show(); + }else{ + p.clbtn.hide(); + } + if($("div[nhname='rec']",p.container).length == 0){ + p.exbtn.html(p.nodatamsg); + }else if( p.container.data('hasmore') == '1' || p.container.data('isclose')=='1' ){ + p.exbtn.html('点击展开更多'); + }else{ + p.exbtn.html('没有更多了'); + } +} +function init_list_more_div_params(div){ + var params = {}; + params.div = div; + params.container = $("div[nhname='container']",div); + params.exbtn = $("a[nhname='expand']",div); + params.clbtn = $("a[nhname='close']",div); + params.size = params.container.data('pagesize'); + params.nodatamsg = params.container.data('nodatamsg'); + if( params.size == undefined ){ + params.size = 13; + } + return params; +} +$(function(){ + $("div[nhname='list_more_div']").each(function(){ + var params = init_list_more_div_params($(this)); + init_list_more_div(params) + }); +}); +//个人动态 end \ No newline at end of file diff --git a/public/stylesheets/users.css b/public/stylesheets/users.css index 30e6594f5..7c3dad383 100644 --- a/public/stylesheets/users.css +++ b/public/stylesheets/users.css @@ -8,7 +8,7 @@ .icon_female{ background:url(../images/pic_uersall.png) 0 -24px no-repeat; width:15px; height:15px;} .pf_intro{ width:222px; margin-top:5px; color:#696969;word-break: break-all; } .leftbox{ width:230px; padding:10px; padding-right:0px; padding-bottom:5px;background:#fff; margin-bottom:10px; margin-right:10px;} -.pic_members{ background:url(../images/pic_users.jpg) 0 0 no-repeat; display:block; width:38px; height:38px; border:1px solid #e9edf0; margin-right:5px; margin-bottom:5px;float:left;} +.pic_members{ display:block; width:38px; height:38px; border:1px solid #e9edf0; margin-right:5px; margin-bottom:5px;float:left;} .pic_members:hover{border:1px solid #c9c9c9;} /*新建*/ .top_new{ height:26px; border-bottom:10px solid #eaebed; padding:10px; background:#fff; float:left; margin-left:10px; width:730px; } @@ -89,7 +89,7 @@ a.select_btn_select{ background:#64bddb; color:#fff;} .users_ctt input,.users_ctt select,.users_ctt textarea{ border:1px solid #CCC;} .users_ctt input,.users_ctt select,.users_ctt option{ height:26px;} .users_ctt input,.users_ctt textarea{ margin-left:2px;} -.users_ctt textarea{ margin-bottom:none;} +/*.users_ctt textarea{ margin-bottom:nor;}*/ .w450{ width:450px;} .w210{ width:200px;} .w70{ width:70px;} @@ -124,4 +124,12 @@ a:hover.c_lgrey{ color:#3ca5c6;} .newhwork_div textarea{border:1px solid #CCC;} .w460{ width:460px;} -a.hidepic>img{display:none;} \ No newline at end of file +a.hidepic>img{display:none;} + +div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;} +span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;} +span.ke-toolbar-icon-url{background-image:url( ../images/public_icon.png )} +div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;} +span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;} +span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;} +div.ke-toolbar .ke-outline{border:none;} \ No newline at end of file From a0a5f3410847752d2c28c535a801976558046546 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 29 Jul 2015 10:07:00 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BB=A5=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 31 +++++++++++++++++++++ app/views/poll/_poll_form.html.erb | 43 +++++++++++++++++++++++++++++- app/views/poll/_show_head.html.erb | 3 +++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 8f81bc2c6..dda5b81b2 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -336,6 +336,37 @@ class PollController < ApplicationController end end + + def import_poll + @poll = Poll.find(params[:to_id]) + question_num = @poll.poll_questions.select("max(question_number) question_number").first.question_number + import_poll = Poll.find(params[:import_id]) + import_poll.poll_questions.each_with_index do |question,index| + option = { + :is_necessary => question.is_necessary, + :question_title => question.question_title, + :question_type => question.question_type, + :question_number => question_num + index+1 + } + poll_questions = @poll.poll_questions.new option + for i in 1..question.poll_answers.count + answer = question.poll_answers[i-1][:answer_text] + question_option = { + :answer_position => i, + :answer_text => answer + } + poll_questions.poll_answers.new question_option + end + @poll.poll_questions << poll_questions + end + if @poll.save + @poll = Poll.find(params[:to_id]) + respond_to do |format| + format.js + end + end + end + #重新发布问卷 def republish_poll @poll.poll_questions.each do |poll_question| diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index d784edab3..c5c016583 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -3,6 +3,7 @@ + diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 66482211c..2a9e96432 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> <% @center_flag = (User.current == @user) %> <% if @center_flag %>
    diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index f9573f65e..91c049f7a 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %>

    用户留言

    diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index 977945d7f..42e665388 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -2,8 +2,6 @@ <% if @user.allowed_to?(:add_project, nil, :global => true) %> 新建项目 - <% else %> - 加入项目 <% end %>
    diff --git a/public/javascripts/user.js b/public/javascripts/user.js index e760361b9..5cf18590a 100644 --- a/public/javascripts/user.js +++ b/public/javascripts/user.js @@ -1,13 +1,3 @@ -$(function(){ - if($(".top_new").length==0){ - $("#RSide").css("min-height",$("#LSide").height()-30); - } - else{ - $("#RSide").css("min-height",$("#LSide").height()-87); - } - -}); - //个人动态 $(function(){ function init_editor(params){ From 9dde668742a12c3975229dd5c08fb633f363cdde Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 16:02:41 +0800 Subject: [PATCH 32/39] =?UTF-8?q?=E8=BF=9B=E5=85=A5=E4=BB=96=E4=BA=BA?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=EF=BC=8CTA=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=EF=BC=8C=E5=AF=B9=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E6=88=90=E5=91=98=E7=9A=84=E9=A1=B9=E7=9B=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=94=B3=E8=AF=B7=E9=A1=B9=E7=9B=AE/=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/applied_project/_set_applied.js.erb | 4 +++- app/views/applied_project/applied_join_project.js.erb | 1 + app/views/users/user_projects.html.erb | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/applied_project/_set_applied.js.erb b/app/views/applied_project/_set_applied.js.erb index 33d862d1c..472da3c09 100644 --- a/app/views/applied_project/_set_applied.js.erb +++ b/app/views/applied_project/_set_applied.js.erb @@ -17,6 +17,8 @@ if (window.Messenger) { Messenger().post({ id: "label_apply_project_waiting", message: "<%= l(:label_apply_project_waiting) %>", - showCloseButton: true, + showCloseButton: true }); }; + +$("#applied_project_link_<%= @project.id%>").replaceWith("<%= escape_javascript(link_to "加入项目",appliedproject_path(:user_id => User.current.id,:project_id => @project.id,:project_join => true),:class => "blue_n_btn fr mt20", :remote => "true",:method => "post",:id => "applied_project_link_#{@project.id}") %>"); diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index 846d2a61d..ae9d3f467 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -6,6 +6,7 @@ <% elsif @status == 2%> alert("<%= l('project.join.tips.success') %>"); hideModal($("#popbox")); + $("#applied_project_link_<%= @project.id%>").replaceWith("<%=escape_javascript(link_to '取消申请',appliedproject_applied_path(:project_id => @project.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{@project.id}")%>"); <% elsif @status == 3%> alert("<%= l('project.join.tips.has') %>"); <%else%> diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index 42e665388..f54874aa3 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -41,7 +41,16 @@
    - item.id, :host=>Setting.host_name) %>" target="_blank" class="blue_n_btn fr mt20">发布问题 + <% if User.current.member_of? item%> + item.id, :host=>Setting.host_name) %>" target="_blank" class="blue_n_btn fr mt20">发布问题 + <% elsif User.current.logged?%> + <% if item.applied_projects.find_by_user_id(User.current.id)%> + <%= link_to '取消申请',appliedproject_applied_path(:project_id => item.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{item.id}"%> + <% else%> + <%= link_to "加入项目",appliedproject_path(:user_id => User.current.id,:project_id => item.id,:project_join => true),:class => "blue_n_btn fr mt20", :remote => "true",:method => "post",:id => "applied_project_link_#{item.id}" %> + <% end%> + + <% end%>
    <% end %> From b5849ed8b8c9f9871fa697e4ec828bcf82d9d49a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 16:06:42 +0800 Subject: [PATCH 33/39] =?UTF-8?q?=E8=BF=9B=E5=85=A5=E4=BB=96=E4=BA=BA?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=EF=BC=8CTA=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?TA=E5=88=9B=E5=BB=BA/TA=E5=8F=82=E4=B8=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_projects.html.erb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index f54874aa3..d76964020 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -11,9 +11,16 @@

    全部项目

    - 全部 - 我创建 - 我参与 + + 全部 + + + + <%= User.current == @user ? "我创建" : "TA创建"%> + + + <%= User.current == @user ? "我参与" : "TA参与"%> +
    From 28509b7cdd76e9c36f5f22a8ab33c5796a770973 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 17:27:42 +0800 Subject: [PATCH 34/39] =?UTF-8?q?=E8=80=81=E5=B8=88=E5=B8=83=E7=BD=AE?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E7=95=8C=E9=9D=A2=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 12 ++++++------ public/javascripts/course.js | 5 +++-- public/stylesheets/courses.css | 1 + public/stylesheets/public.css | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index be08dd107..3063b3af5 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -87,16 +87,16 @@
  • - +
  • - +
  • - + 测试
  • @@ -105,16 +105,16 @@
  • - +
  • - +
  • - + 测试
  • diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b2736993b..8c6991a3a 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -546,10 +546,11 @@ function submit_homework_form(){if(regexHomeworkCommonName()&®exHomeworkCommo //增加测试结果 function add_programing_test(obj) { var now = new Date().getTime(); - obj.after("
  • " + - "
  • " + + obj.after("
  • " + + "
  • " + "
  • " + "" + + "测试" + "
  • "); } //删除测试结果 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 00a2f0034..7ccb783fe 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -609,6 +609,7 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} .w547{ width:544px;} .w196{ width:196px;} .w186{ width:186px;} +.w190{width: 190px;} .w200{width: 200px;} .w459{ width:459px;} .hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index c1e47c787..2a9e71e7d 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -166,8 +166,8 @@ a.c_green{ color:#28be6c;} .grey_btn{ background:#d9d9d9; color:#656565;font-size:14px; font-weight:normal; text-align:center;padding:2px 10px;} a.grey_btn{ background:#d9d9d9; color:#656565;font-size:14px; font-weight:normal; text-align:center;padding:2px 10px;} a:hover.grey_btn{ background:#717171; color:#fff;} -.green_btn{ background:#28be6c; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} -a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} +.green_btn{ background:#28be6c; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;cursor: pointer;} a:hover.green_btn{ background:#14ad5a;} .blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} From 5e885d9417dcc39f64599ce0f082fb165981c1f3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 17:38:01 +0800 Subject: [PATCH 35/39] =?UTF-8?q?=E8=80=81=E5=B8=88=E5=B8=83=E7=BD=AE?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E7=95=8C=E9=9D=A2=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=BB=93=E6=9E=9C=E7=9A=84=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 2 ++ db/migrate/20150730093403_add_result_to_test.rb | 9 +++++++++ db/schema.rb | 17 ++++------------- public/javascripts/course.js | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20150730093403_add_result_to_test.rb diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 3063b3af5..43bfc2254 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -97,6 +97,7 @@ 测试 +
    @@ -115,6 +116,7 @@ 测试 +
    diff --git a/db/migrate/20150730093403_add_result_to_test.rb b/db/migrate/20150730093403_add_result_to_test.rb new file mode 100644 index 000000000..8494fbbf5 --- /dev/null +++ b/db/migrate/20150730093403_add_result_to_test.rb @@ -0,0 +1,9 @@ +class AddResultToTest < ActiveRecord::Migration + def up + add_column :homework_tests, :result, :integer,default: 0 + end + + def down + remove_column :homework_tests,:result + end +end diff --git a/db/schema.rb b/db/schema.rb index 0e8cde619..3791eb248 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150722015428) do +ActiveRecord::Schema.define(:version => 20150730093403) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -632,8 +632,9 @@ ActiveRecord::Schema.define(:version => 20150722015428) do t.text "input" t.text "output" t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result", :default => 0 end create_table "homework_users", :force => true do |t| @@ -744,16 +745,6 @@ ActiveRecord::Schema.define(:version => 20150722015428) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 8c6991a3a..b6ecc9f52 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -551,6 +551,7 @@ function add_programing_test(obj) { "
  • " + "" + "测试" + + "" + "
  • "); } //删除测试结果 From 3e5af49281ab04d7aef13f3ecb4f28ac0f8149d4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 20:36:00 +0800 Subject: [PATCH 36/39] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6=E7=9A=84=E5=8F=91?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 4 +++ .../_homework_detail_programing_form.html.erb | 25 ++++++++++++++++--- .../homework_common/programing_test.js.erb | 0 config/routes.rb | 1 + public/javascripts/course.js | 2 +- 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 app/views/homework_common/programing_test.js.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 34e97e4dd..58d3c8d12 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -351,6 +351,10 @@ class HomeworkCommonController < ApplicationController end end + def programing_test + + end + private #获取课程 def find_course diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 43bfc2254..1d4c52c71 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -96,7 +96,7 @@
  • - 测试 + 测试
  • @@ -115,11 +115,30 @@
  • - 测试 + 测试
  • <% end %> - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index e83fe2417..a8cffb2ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,6 +98,7 @@ RedmineApp::Application.routes.draw do end collection do post 'next_step' + post 'programing_test' end end diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b6ecc9f52..dd2d300d1 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -550,7 +550,7 @@ function add_programing_test(obj) { "
  • " + "
  • " + "" + - "测试" + + "测试" + "" + "
  • "); } From f163cdac51e19a1323843c2dc1a976e687cd0d26 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 21:02:04 +0800 Subject: [PATCH 37/39] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E6=AF=8F=E7=BB=84=E6=B5=8B=E8=AF=95=E5=AF=B9=E6=A0=87=E5=87=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 38 +++++++++++++------ .../_homework_detail_programing_form.html.erb | 11 +++--- .../homework_common/programing_test.js.erb | 2 + public/javascripts/course.js | 4 +- public/stylesheets/courses.css | 2 - public/stylesheets/public.css | 6 ++- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 58d3c8d12..a6fae032f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -99,12 +99,13 @@ class HomeworkCommonController < ApplicationController question = {title:homework.name,content:homework.description} question[:input] = [] question[:output] = [] - if params[:input] && params[:output] + if params[:input] && params[:output] && params[:result] params[:input].each do |k,v| if params[:output].include? k homework_test = HomeworkTest.new homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] homework.homework_tests << homework_test question[:input] << homework_test.input question[:output] << homework_test.output @@ -119,16 +120,16 @@ class HomeworkCommonController < ApplicationController # http.request(req) # end - uri = URI('http://192.168.80.21:8080/api/questions.json') - body = question.to_json - res = Net::HTTP.new(uri.host, uri.port).start do |client| - request = Net::HTTP::Post.new(uri.path) - request.body = body - request["Content-Type"] = "application/json" - client.request(request) - end - result = JSON.parse(res.body) - homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + # uri = URI('http://192.168.80.21:8080/api/questions.json') + # body = question.to_json + # res = Net::HTTP.new(uri.host, uri.port).start do |client| + # request = Net::HTTP::Post.new(uri.path) + # request.body = body + # request["Content-Type"] = "application/json" + # client.request(request) + # end + # result = JSON.parse(res.body) + # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 homework.homework_detail_programing = homework_detail_programing else @@ -352,7 +353,20 @@ class HomeworkCommonController < ApplicationController end def programing_test - + test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]} + @index = params[:index] + # uri = URI('http://192.168.80.21:8080/api/realtime.json') + # body = test.to_json + # res = Net::HTTP.new(uri.host, uri.port).start do |client| + # request = Net::HTTP::Post.new(uri.path) + # request.body = body + # request["Content-Type"] = "application/json" + # client.request(request) + # end + # result = JSON.parse(res.body) + # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + # + # homework.homework_detail_programing = homework_detail_programing end private diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 1d4c52c71..5e53c4b15 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -96,8 +96,8 @@
  • - 测试 - + 测试 +
  • @@ -115,8 +115,8 @@
  • - 测试 - + 测试 +
  • @@ -134,7 +134,8 @@ src: $("textarea[name='standard_code']").val(), input: $("input[name='input[" + obj +"]']").val(), output: $("input[name='output[" + obj + "]']").val(), - language: $("select[name='language']").val() + language: $("select[name='language']").val(), + index: obj }, function (data) { diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb index e69de29bb..4f5b115db 100644 --- a/app/views/homework_common/programing_test.js.erb +++ b/app/views/homework_common/programing_test.js.erb @@ -0,0 +1,2 @@ +$("#test_send_<%= @index%>").replaceWith("错误"); +$("#test_result_<%= @index%>").val("1"); \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index dd2d300d1..c7b01cee1 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -550,8 +550,8 @@ function add_programing_test(obj) { "
  • " + "
  • " + "" + - "测试" + - "" + + "测试" + + "" + "
  • "); } //删除测试结果 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 7ccb783fe..5c6fd9867 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -88,8 +88,6 @@ a:hover.talk_edit{ color:#ff5722;} .talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} .talk_new ul li{ } .sb{width:70px; height:26px; color:#606060; cursor:pointer;} -a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} -a:hover.blue_btn{ background:#329cbd;} a.grey_btn{ background:#d9d9d9; color:#656565;font-size:14px; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} a:hover.grey_btn{ background:#717171; color:#fff;} /****资源库***/ diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 2a9e71e7d..1bf889cba 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -169,8 +169,10 @@ a:hover.grey_btn{ background:#717171; color:#fff;} .green_btn{ background:#28be6c; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;cursor: pointer;} a:hover.green_btn{ background:#14ad5a;} -.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} -a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} +.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;} +.red_btn{ background:red; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +a.red_btn{background:red; color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;} a.orange_btn_homework{background:#d63502;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;cursor: pointer;} a.orange_btn{ background:#ff5722;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center; } From c507a97ac6a2022a7ef055d5bb6817d092dab683 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 21:07:43 +0800 Subject: [PATCH 38/39] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=98=AF=E5=90=A6=E6=88=90?= =?UTF-8?q?=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 42 +++++++++---------- .../homework_common/programing_test.js.erb | 4 +- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a6fae032f..918c1b8b9 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -120,16 +120,16 @@ class HomeworkCommonController < ApplicationController # http.request(req) # end - # uri = URI('http://192.168.80.21:8080/api/questions.json') - # body = question.to_json - # res = Net::HTTP.new(uri.host, uri.port).start do |client| - # request = Net::HTTP::Post.new(uri.path) - # request.body = body - # request["Content-Type"] = "application/json" - # client.request(request) - # end - # result = JSON.parse(res.body) - # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + uri = URI('http://192.168.80.21:8080/api/questions.json') + body = question.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + result = JSON.parse(res.body) + homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 homework.homework_detail_programing = homework_detail_programing else @@ -355,18 +355,16 @@ class HomeworkCommonController < ApplicationController def programing_test test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]} @index = params[:index] - # uri = URI('http://192.168.80.21:8080/api/realtime.json') - # body = test.to_json - # res = Net::HTTP.new(uri.host, uri.port).start do |client| - # request = Net::HTTP::Post.new(uri.path) - # request.body = body - # request["Content-Type"] = "application/json" - # client.request(request) - # end - # result = JSON.parse(res.body) - # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 - # - # homework.homework_detail_programing = homework_detail_programing + uri = URI('http://192.168.80.21:8080/api/realtime.json') + body = test.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + result = JSON.parse(res.body) + @result = result[:result][0][:status] end private diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb index 4f5b115db..b6bcfdc86 100644 --- a/app/views/homework_common/programing_test.js.erb +++ b/app/views/homework_common/programing_test.js.erb @@ -1,2 +1,2 @@ -$("#test_send_<%= @index%>").replaceWith("错误"); -$("#test_result_<%= @index%>").val("1"); \ No newline at end of file +$("#test_send_<%= @index%>").replaceWith(" fl ml5 mt1'><%= @result == 0 ? '正确' : '错误'%>"); +$("#test_result_<%= @index%>").val("<%= @result%>"); \ No newline at end of file From 41cba6db6ac9c24eea57c84a013d678208d032fa Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 30 Jul 2015 21:10:05 +0800 Subject: [PATCH 39/39] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AF=8F=E7=BB=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9A=84=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150730130816_add_errormsg_to_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20150730130816_add_errormsg_to_test.rb diff --git a/db/migrate/20150730130816_add_errormsg_to_test.rb b/db/migrate/20150730130816_add_errormsg_to_test.rb new file mode 100644 index 000000000..31b1b2246 --- /dev/null +++ b/db/migrate/20150730130816_add_errormsg_to_test.rb @@ -0,0 +1,9 @@ +class AddErrormsgToTest < ActiveRecord::Migration + def up + add_column :homework_tests,:error_msg,:text + end + + def down + remove_column :homework_tests,:error_msg + end +end