From 9002844188e3dacc0e3b424ea7b0efe54d443703 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 13 Sep 2016 16:18:57 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E6=96=B0=E7=89=88=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 1 + app/controllers/users_controller.rb | 2 +- app/helpers/application_helper.rb | 18 +++ app/views/homework_common/edit.html.erb | 14 +++ app/views/users/_user_group_attr.html.erb | 52 ++++---- .../users/_user_homework_attachment.html.erb | 11 -- app/views/users/_user_homework_form.html.erb | 116 +++++++++--------- .../users/_user_programing_attr.html.erb | 83 ++++++++----- app/views/users/user_select_homework.js.erb | 10 +- public/javascripts/course.js | 51 ++++++++ public/javascripts/new_user.js | 51 ++++++++ public/stylesheets/css/common.css | 1 + 12 files changed, 275 insertions(+), 135 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6704f7401..0fddd7e6c 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -85,6 +85,7 @@ class HomeworkCommonController < ApplicationController homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] + @homework.homework_type = params[:homework_type].to_i || @homework.homework_type anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0 if anonymous != @homework.anonymous_comment if anonymous == 1 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 559f29235..2a91b75ae 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1052,7 +1052,7 @@ class UsersController < ApplicationController else homework.publish_time = params[:homework_common][:publish_time] end - homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 + homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1 homework.homework_type = params[:homework_type].to_i || 1 homework.late_penalty = 10 homework.teacher_priority = 1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 94b0b2c6e..a370f226c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3521,3 +3521,21 @@ def get_forge_act_message(act, type) format_time(forge_act.nil? ? act.created_on : forge_act.try(:updated_at)) end +#作业类型 +def homework_type_option + type = [] + option1 = [] + option1 << "普通作业" + option1 << 1 + option2 = [] + option2 << "编程作业" + option2 << 2 + option3 = [] + option3 << "分组作业" + option3 << 3 + type << option1 + type << option2 + type << option3 + type +end + diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 1bd71e7a9..4a3de027b 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -41,6 +41,20 @@
+ <% committed_work_count = @homework.student_works.has_committed.count %> + <% stu_pro_count = @homework.student_work_projects.count %> + <% if committed_work_count != 0 %> + <% if @homework.homework_type == 1 %> +

已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。

+ <% elsif @homework.homework_type == 2 %> +

已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和测试集。

+ <% elsif @homework.homework_type == 3 %> +

已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和分组设置。

+ <% end %> + <% elsif stu_pro_count != 0 && @homework.homework_type == 3 %> +

已有<%=stu_pro_count %>个学生关联项目,不允许再修改作业类型。

+ <% end %> + <%= form_for @homework do |f| %> diff --git a/app/views/users/_user_group_attr.html.erb b/app/views/users/_user_group_attr.html.erb index 6d09f6896..4596ef411 100644 --- a/app/views/users/_user_group_attr.html.erb +++ b/app/views/users/_user_group_attr.html.erb @@ -1,27 +1,27 @@ -分组设置 - -
- 每组最小人数: - 人 - +
+
分组设置: +
每组最小人数: + />人 +
+
每组最大人数: + />人 +
+ +
+
+ +

提醒:勾选后各小组必须在Trustie平台创建项目,教师可随时观察平台对各小组最新进展的实时统计

+
+
+
-
- 每组最大人数: - 人 - -
-

-
- -

提醒:勾选后各小组必须在Trustie平台创建项目,教师可随时观察平台对各小组最新进展的实时统计

-
-
- 确定 -
-
- 取消 -
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index 6051d8de9..4f35326b0 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -71,17 +71,6 @@ 上传附件 <%= link_to "资源库", user_ref_resource_search_user_path(User.current.id, :homework_id => container.id), :class => "FilesBtn fl mt3 mr15", :title => "请从资源库中选择文件作为作业的附件", :remote => true %> - <% if defined?(has_program) && has_program %> -
- 编程 - -
- <% end %> - <% if defined?(has_group) && has_group %> -
- 分组 -
- <% end %>
<% content_for :header_tags do %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index b3f9970c6..231c78b91 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -1,3 +1,4 @@ +<% not_allow_select = edit_mode && homework.student_works.has_committed.count != 0 %> <% content_for :header_tags do %> <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> @@ -5,14 +6,31 @@ - - - - - - - - <% unless edit_mode %> +
From 0d12acd42a16f84576835b338abcd84c647d617b Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 14 Sep 2016 21:11:20 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_evaluation_un_group.html.erb | 2 +- .../_evaluation_un_group_work.html.erb | 2 +- .../student_work/_group_work_show.html.erb | 145 ------------------ 3 files changed, 2 insertions(+), 147 deletions(-) delete mode 100644 app/views/student_work/_group_work_show.html.erb diff --git a/app/views/student_work/_evaluation_un_group.html.erb b/app/views/student_work/_evaluation_un_group.html.erb index 91907aadf..75614a909 100644 --- a/app/views/student_work/_evaluation_un_group.html.erb +++ b/app/views/student_work/_evaluation_un_group.html.erb @@ -1,6 +1,6 @@
<% @stundet_works.each_with_index do |student_work, i| %> -
+
<%= render :partial => 'evaluation_un_group_work', :locals => {:student_work => student_work} %>
diff --git a/app/views/student_work/_evaluation_un_group_work.html.erb b/app/views/student_work/_evaluation_un_group_work.html.erb index 3c3a02281..5ce2545e7 100644 --- a/app/views/student_work/_evaluation_un_group_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_work.html.erb @@ -1,5 +1,5 @@
- + diff --git a/app/views/student_work/_group_work_show.html.erb b/app/views/student_work/_group_work_show.html.erb deleted file mode 100644 index 00e90b2d0..000000000 --- a/app/views/student_work/_group_work_show.html.erb +++ /dev/null @@ -1,145 +0,0 @@ -
-
- <% is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? %> - <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> - <% is_my_work = pro && pro.student_work_id == work.id%> -
    -
  • - 上交时间: - <%=format_time work.created_at %> -
  • - - <% if work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %> - -
  • - <%= link_to("", student_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %> -
  • -
  • - <%= link_to "",edit_student_work_path(work),:class => "pic_edit",:title => "修改"%> -
  • - <% end%> - <% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %> - -
  • - <%= render :partial => 'student_work_praise',:locals => {:work => work} %> -
  • - <% end%> -
    - - - - <% if work.student_work_projects && (@homework.homework_detail_manual.comment_status != 2 || is_my_work || is_teacher ) %> -
    -
  • - 参与人员: - <%= link_to(work.user.show_name+"(组长)", user_path(work.user.id), :class => "linkBlue" )%> - <% members = work.student_work_projects.where("is_leader = 0") %> - <% members.each do |member| if !members.empty? %> - 、<%=link_to((User.find member.user_id).show_name, user_path(member.user.id), :class => "linkBlue" ) %> - <% end %> - <% end %> -
  • - <% if @homework.homework_detail_group.base_on_project == 1 %> -
  • - 关联项目: - <% if work.project_id == 0 || work.project_id.nil? %> - 暂无 - <% elsif work.project.is_public || User.current.member_of?(work.project) || User.current.admin? %> - <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> - (综合评分:<%=static_project_score(work.project.project_score).to_i %>) - <% else %> - <%=work.project.name %> - (综合评分:<%=static_project_score(work.project.project_score).to_i %>) - <% end %> - <%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> -
  • - <% end %> -
  • - 内容: -
    - <%= work.description.html_safe if work.description%> -
    -
    -
  • -
  • - 附件: - <% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %> - <% if com_attachments.empty?%> - 尚未提交附件 - <% else%> -
    - <%= render :partial => 'work_attachments_status', :locals => {:attachments => com_attachments, :status => @homework.homework_detail_manual.comment_status} %> -
    - <% end%> -
    -
  • - <% end%> - -
  • - <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%> - -
    - <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> -
    - <% end%> -
    -
  • -
- -
- <%= render :partial => 'student_work/revise_attachment', :locals => {:work => work} %> -
-
- -
- <%student_work_scores.each do |student_score|%> -
- <%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%> -
- <% end%> -
-
- - 收起 -
-
- \ No newline at end of file From cfc5a2457c1895d232c699591ef5c97695a141c1 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 17 Sep 2016 11:26:29 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E8=AF=BE=E7=A8=8B500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 37 ++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 39c61a318..f119e0e69 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -14,21 +14,30 @@ module CoursesHelper # 推荐的精品课程 - def excellent_course_recommend current_course - q = "%#{current_course.name.strip}%" - recomment_courses = [] - # 推荐过程过滤掉自身 - sql = "SELECT distinct c.* FROM course_activities cs, courses c where cs.course_id = c.id - and (c.is_excellent =1 or c.excellent_option =1) and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;" - ex_courses = Course.find_by_sql(sql) - # 使用课程的tag去和课程名称进行匹配 - c_courses = ex_courses.select{|ex_course| ex_course.tags.any?{|tag| q.include?(tag.to_s)}} - if c_courses.count < 3 - results = c_courses.length == 0 ? ex_courses.first(3) : (c_courses + ex_courses.first(3 - ex_courses.count)) - else - results = c_courses.first(3) + def excellent_course_recommend new_course + q = "%#{new_course.name.strip}%" + result = find_excelletn_course(q, new_course) + end + + # 查询符合条件的精品课程 + # 用新课程名去匹配精品课程中按课程名和Tag名 + def find_excelletn_course keywords, current_course + # 获取tag匹配结果ID + a_tags = [] + Course.where("is_excellent =? and is_public =?", 1, 1).each do |ec| + if ec.tags.any?{|value| current_course.name.include?(value.to_s)} + a_tags << ec.id + end end - results + # 课程本身不能搜索显示自己 + excellent_ids = a_tags.uniq.delete_if{|i| i == current_course.id} + sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id + and (c.is_excellent =1 or c.excellent_option =1) and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;" + default_ids = Course.find_by_sql(sql).flatten.map { |c| c.id } + excellent_ids << default_ids.flatten + arr_result = excellent_ids.flatten.uniq.first(3) + excellent_courses = Course.find(arr_result) + return excellent_courses end # 判断精品课程是否可见,非课程成员无法查看私有课程