From 6bdd6d3e032b95c6b6795778048311ca001a3c1a Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Dec 2015 10:15:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=8F=9C=E5=8D=95=EF=BC=8C=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 19 +++++ app/views/courses/private_or_public.js.erb | 8 ++ app/views/courses/settings.html.erb | 6 +- app/views/layouts/_project_info.html.erb | 92 ++++++++++++++++++++++ app/views/layouts/base_courses.html.erb | 76 +----------------- config/routes.rb | 1 + public/stylesheets/courses.css | 2 + 7 files changed, 127 insertions(+), 77 deletions(-) create mode 100644 app/views/courses/private_or_public.js.erb create mode 100644 app/views/layouts/_project_info.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8bd91b089..57e365aff 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -399,6 +399,25 @@ class CoursesController < ApplicationController end + def private_or_public + if @course.is_public == 0 + @course.update_attributes(:is_public => 1) + else + @course.update_attributes(:is_public => 0) + end + if @course.is_public == 0 + course_status = CourseStatus.find_by_course_id(@course.id) + course_status.destroy if course_status + elsif @course.is_public == 1 + course_status = CourseStatus.find_by_course_id(@course.id) + course_status.destroy if course_status + course_status = CourseStatus.create(:course_id => @course.id, :grade => 0) + end + respond_to do |format| + format.js + end + end + def search_member if User.current.allowed_to?(:as_teacher,@course) || User.current.admin q = "#{params[:name].strip}" diff --git a/app/views/courses/private_or_public.js.erb b/app/views/courses/private_or_public.js.erb new file mode 100644 index 000000000..71315e910 --- /dev/null +++ b/app/views/courses/private_or_public.js.erb @@ -0,0 +1,8 @@ +$("#project_info_<%=@course.id %>").html('<%=escape_javascript(render :partial=>'layouts/project_info') %>'); +if(document.getElementById("course_is_public")) { + <% if @course.is_public == 0%> + $("#course_is_public").attr("checked",false); + <% elsif @course.is_public == 1 %> + $("#course_is_public").attr("checked",true); + <% end %> +} \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 634f26495..d330551d1 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -66,19 +66,19 @@
  • id="course_is_public" name="course[is_public]" type="checkbox"> - (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) + (选中后课外用户可见该课程,否则仅对课内成员可见。)
  • id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> - (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) + (选中后课外用户可见学生列表,否则仅对课内成员可见)
  • id="course_publish_resource" name="course[publish_resource]" type="checkbox" style="margin-left: 1px;"/> - (打钩为"允许学生上传资源",不打钩为"不允许学生上传资源") + (选中后允许学生上传课程资源,否则不允许)
  • diff --git a/app/views/layouts/_project_info.html.erb b/app/views/layouts/_project_info.html.erb new file mode 100644 index 000000000..b4a2996d0 --- /dev/null +++ b/app/views/layouts/_project_info.html.erb @@ -0,0 +1,92 @@ +<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> +<% teacher_num = searchTeacherAndAssistant(@course).count %> +<% student_num = studentCount(@course) %> +<% course_file_num = visable_attachemnts_incourse(@course).count%> + +
    <%= @course.is_public == 0 ? "私有课程" : "公开课程" %>
    +
    +ID:<%= @course.id%> +
    + +
    + + + + + + + + + + + + + + + + + + + + +
    + +
    + + <%= @course.name %> + + <%# if @course.is_public == 0%> + + + <%# end %> + + <%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %> + + <% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%> + + <% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%> + + <% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%> + + <%else%> + <%end %> + +
    +
    +
    +
    +<%= l(:label_account_identity_teacher)%>(<%= course_teacher_link teacher_num %>) + +<%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) + +<%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue',:id=>'courses_files_count_info' %>)
    +
    +<% if is_teacher %> +
    +
      +
    • +
        +
      • <%= link_to "课程配置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "postOptionLink" %>
      • +
      • <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
      • + +
      +
    • +
    +
    +<% end %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 1cb8efe01..a7af387b2 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,6 +1,4 @@ <%# course_model %> -<% teacher_num = searchTeacherAndAssistant(@course).count %> -<% student_num = studentCount(@course) %> <% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> @@ -51,78 +49,8 @@
    -
    - -
    - ID:<%= @course.id%> -
    -
    - <% if is_teacher%> - <%= link_to "#{l(:button_configure)}".html_safe, {:controller => 'courses', :action => 'settings', :id => @course}, :class => "pr_join_a" %> - <%= set_course_time @course%> - <%#= link_to "#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %> - <% else%> -
    <%= join_in_course_header(@course, User.current) %>
    - <% end%> -
    -
    - - - - - - - - - - - - - - - - - - - - -
    - -
    - - <%= @course.name %> - - <% if @course.is_public == 0%> - - - <%= l(:field_is_private)%> - - <% end %> - - <%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %> - - <% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%> - - <% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%> - - <% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%> - - <%else%> - <%end %> - -
    -
    -
    -
    - <%= l(:label_account_identity_teacher)%>(<%= course_teacher_link teacher_num %>) - - <%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) - - <%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue',:id=>'courses_files_count_info' %>)
    -
    +
    + <%=render :partial=>'layouts/project_info' %>
      diff --git a/config/routes.rb b/config/routes.rb index fb381e8ea..67a1c7e88 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -924,6 +924,7 @@ RedmineApp::Application.routes.draw do post 'join_in/join_group', :to => 'courses#join_group', :as => 'join_group' delete 'join_in/join_group', :to => 'courses#unjoin_group' get 'copy_course' + get 'private_or_public' match 'course_activity', :to => 'courses#course_activity', :via => :get, :as => "course_activity" get 'course_outline' post 'search_course_outline' diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 86586243d..441adce29 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1239,3 +1239,5 @@ div.disable_link {background-color: #c1c1c1 !important;} .support{ background:url(../images/public_icon.png) -66px -45px no-repeat; width:18px; height:21px;} .function{ background:url(../images/public_icon.png) -66px -70px no-repeat; width:18px; height:21px;} .weekly{ background:url(../images/public_icon.png) -66px -95px no-repeat; width:18px; height:21px;} + +.boxShadow {box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);} From 000f40ad42b12806886ed672cce69d31641e044d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Dec 2015 10:59:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=BD=93=E5=89=8D=E6=89=80=E5=A4=84=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9D=A5=E7=A1=AE=E5=AE=9A=E6=98=AF=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4=E8=BF=98=E6=98=AF=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_homework.html.erb | 6 +++++- app/views/users/_user_homework_detail.html.erb | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index da05ac946..a0ce84795 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -86,7 +86,11 @@ 分组人数:<%=activity.homework_detail_group.min_num %>-<%=activity.homework_detail_group.max_num %> 人
    <% end %> -
    截止时间:<%= activity.end_time.to_s %> 23:59
    + <% if activity.homework_detail_manual && activity.homework_detail_manual.comment_status < 2 %> +
    提交截止时间:<%= activity.end_time.to_s %> 23:59
    + <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 %> +
    匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
    + <% end %>
    diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index fb6ae0455..0472613e4 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -84,9 +84,11 @@ 分组人数:<%=homework_common.homework_detail_group.min_num %>-<%=homework_common.homework_detail_group.max_num %> 人
    <% end %> -
    - <%= l(:label_end_time)%>:<%= homework_common.end_time%> 23:59 -
    + <% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 %> +
    提交截止时间:<%= homework_common.end_time.to_s %> 23:59
    + <% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 %> +
    匿评截止时间:<%= homework_common.homework_detail_manual.evaluation_end.to_s %> 23:59
    + <% end %> <% if homework_common.homework_detail_manual.comment_status == 0 %>
    <%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00 From e6ebcb7ac6f0a2547f4e3ee29364392f9a336522 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Dec 2015 11:08:38 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=8F=90=E4=BA=A4=E6=88=AA=E6=AD=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4/=E5=8C=BF=E8=AF=84=E6=88=AA=E6=AD=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/index.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index c6d2bd313..b314bcf6d 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -170,7 +170,11 @@
    -
    截止时间:<%= @homework.end_time %> 23:59
    + <% if @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status < 2 %> +
    提交截止时间:<%= @homework.end_time %> 23:59
    + <% elsif @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status >= 2 %> +
    匿评截止时间:<%= @homework.homework_detail_manual.evaluation_end %> 23:59
    + <% end %> <% if @homework.homework_detail_manual.comment_status == 0 %>
    发布时间:<%= @homework.publish_time %> 00:00
    <% end %> From 179058f1aa648f3096f466f3b5a40481a46cd0d9 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Dec 2015 14:55:20 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=80=BB=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E4=B8=8D=E8=83=BD=E4=B8=BA=E8=B4=9F=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_evaluation_un_work.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index 0a4ab044a..bf022f64c 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -74,7 +74,7 @@ <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
  • - <%= score.nil? ? "--" : format("%.1f",score)%> + <%= score.nil? ? "--" : format("%.1f",score<0 ? 0 : score)%> <% unless score.nil?%>
    作品最终评分为 From 605ec52f8ac8efdf9559c9dbc3560c1f564eeac7 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Dec 2015 16:31:19 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E6=8F=90=E7=A4=BA=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/courses/settings.html.erb | 2 +- app/views/exercise/_exercise_student.html.erb | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 25b5dacec..9c073afa8 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -485,7 +485,7 @@ class ExerciseController < ApplicationController ea.answer_text = params[:answer_text] if ea.save @percent = get_percent(@exercise,User.current) - render :json => {:text => pv.vote_text,:percent => format("%.2f", @percent)} + render :json => {:text => ea.answer_text,:percent => format("%.2f", @percent)} else render :json => {:text => "failure"} end diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index d330551d1..ae6416c9d 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -66,7 +66,7 @@
  • id="course_is_public" name="course[is_public]" type="checkbox"> - (选中后课外用户可见该课程,否则仅对课内成员可见。) + (选中后课外用户可见该课程,否则仅对课内成员可见)
  • diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 8a1f3dbd6..4f4892b79 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -100,6 +100,9 @@ { obj.checked = false; } + }, + error: function () { + alert("网络异常,答题失败,请确认网络正常连接后再答题。"); } }); } @@ -154,6 +157,9 @@ { obj.checked = false; } + }, + error: function () { + alert("网络异常,答题失败,请确认网络正常连接后再答题。"); } }); } @@ -196,6 +202,9 @@ success: function (data) { var dataObj = eval(data); obj.value = dataObj.text; + }, + error: function () { + alert("网络异常,答题失败,请确认网络正常连接后再答题。"); } });