From 96220a014762e0d54ed910e819c62b6998f5371d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 15 Jun 2015 10:08:05 +0800 Subject: [PATCH 01/17] schema.rb --- db/schema.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/db/schema.rb b/db/schema.rb index 68f00c1cd..32e8cd7a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -721,6 +721,16 @@ ActiveRecord::Schema.define(:version => 20150604153000) 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" From d73a2c100336f9f24e488cbfe9513e81ed2e7d8a Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 19 Jun 2015 15:05:25 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=96=B0=E7=89=88api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 2 +- app/api/mobile/entities/attachment.rb | 8 +- app/api/mobile/entities/course_dynamic.rb | 103 ++++++++++++++++++++++ app/api/mobile/entities/homework.rb | 10 ++- app/services/courses_service.rb | 95 +++++++++++++++++++- 5 files changed, 214 insertions(+), 4 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 73d1e357c..c325639f9 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -247,7 +247,7 @@ module Mobile end get "course_dynamic/:id" do cs = CoursesService.new - count = cs.course_dynamic(params,current_user) + count = cs.all_course_dynamics(params,current_user) present :data, count, with: Mobile::Entities::CourseDynamic present :status, 0 end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 080b24558..b7424fac9 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -1,13 +1,18 @@ module Mobile module Entities class Attachment < Grape::Entity + include Redmine::I18n def self.attachment_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) f[field] elsif f.is_a?(::Attachment) if f.respond_to?(field) - f.send(field) + if field == :created_on + format_time(f.send(field)) + else + f.send(field) + end else #case field # when "" @@ -21,6 +26,7 @@ module Mobile attachment_expose :description attachment_expose :downloads attachment_expose :quotes + attachment_expose :created_on end end end \ No newline at end of file diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb index b6e4630e4..56b83d513 100644 --- a/app/api/mobile/entities/course_dynamic.rb +++ b/app/api/mobile/entities/course_dynamic.rb @@ -6,6 +6,62 @@ module Mobile expose field do |c,opt| if field == :update_time (format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) + elsif field == :news_count + obj = nil + c[:dynamics].each do |d| + if d[:type] == 1 + obj = d[:count] + end + end + obj + elsif field == :document_count + obj = nil + c[:dynamics].each do |d| + if d[:type] == 3 + obj = d[:count] + end + end + obj + elsif field == :jour_message_count + obj = nil + c[:dynamics].each do |d| + if d[:type] == 2 + obj = d[:count] + end + end + obj + elsif field == :homework_count + obj = nil + c[:dynamics].each do |d| + if d[:type] == 4 + obj = d[:count] + end + end + obj + elsif field == :homework_submit_num + obj = nil + c[:dynamics].each do |d| + if d[:type] == 4 + obj = d[:submit_count] + end + end + obj + elsif field == :homework_submit_students + obj = nil + c[:dynamics].each do |d| + if d[:type] == 4 + obj = d[:studentlist] + end + end + obj + elsif field == :homework_status + obj = nil + c[:dynamics].each do |d| + if d[:type] == 4 + obj = d[:homework_status] + end + end + obj else c[field] if (c.is_a?(Hash) && c.key?(field)) end @@ -21,6 +77,53 @@ module Mobile course_dynamic_expose :course_img_url course_dynamic_expose :message course_dynamic_expose :update_time + course_dynamic_expose :count + course_dynamic_expose :news_count + course_dynamic_expose :document_count + course_dynamic_expose :jour_message_count + course_dynamic_expose :homework_count + course_dynamic_expose :homework_submit_students + course_dynamic_expose :homework_submit_num + course_dynamic_expose :homework_status + #在dynamics里解析出四种动态 + expose :document,using:Mobile::Entities::Attachment do |f,opt| + obj = nil + f[:dynamics].each do |d| + if d[:type] == 3 + obj = d[:documents] + end + end + obj + end + expose :jour_message,using:Mobile::Entities::Jours do |f,opt| + obj = nil + f[:dynamics].each do |d| + if d[:type] == 2 + obj = d[:jour_message] + end + end + obj + end + expose :homework,using:Mobile::Entities::Homework do |f,opt| + obj = nil + f[:dynamics].each do |d| + if d[:type] == 4 + obj = d[:homework] + end + end + obj + end + + expose :news,using:Mobile::Entities::News do |f,opt| + obj = nil + f[:dynamics].each do |d| + if d[:type] == 1 + obj = d + end + end + obj + end + end end end \ No newline at end of file diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index ee623d9ff..18dbe0d3b 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -1,3 +1,4 @@ +# 这个模块由于作业模块的改变,里边的注释以及属性不可信 module Mobile module Entities class Homework < Grape::Entity @@ -14,7 +15,12 @@ module Mobile if f.respond_to?(field) f.send(field) else - + case field + when :homework_name + f.send(:name) + when :homework_notsubmit_num + f.course.members.count - f.student_works.count + end end end end @@ -60,6 +66,8 @@ module Mobile f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments) end + homework_expose :homework_notsubmit_num + end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index d4a197aff..3856a7642 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -615,9 +615,102 @@ class CoursesService homework_scores end + #app新版api + # + # + #课程动态 + public + def all_course_dynamics params, current_user + #获取当前用户的所有课程 + @user = User.find(params[:id]) + if current_user.nil? && !current_user.admin? && !@user.active? + raise '404' + return + end + if current_user == @user || current_user.admin? + membership = @user.coursememberships.all + else + membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user)) + end + if membership.nil? || membership.count == 0 + raise l(:label_no_courses, :locale => get_user_language(current_user)) + end + membership.sort! { |older, newer| newer.created_on <=> older.created_on } + + #定义一个数组集合,存放hash数组,该hash数组包括课程的信息,并包含课程的最新发布的资源,最新的讨论区留言,最新的作业,最新的通知 + result = [] + #对用户所有的课程进行循环,找到每个课程最新发布的资源,最新的讨论区留言,最新的作业,最新的通知,并存进数组 + membership.each do |mp| + course = mp.course + latest_course_dynamics = [] + dynamics_count = 0 + # 课程通知 + latest_news = course.news.order("created_on desc").first + unless latest_news.nil? + latest_course_dynamics << {:type => 1, :time => latest_news.created_on,:count=>course.news.count, + :news => latest_news} + dynamics_count += 1 + end + # 课程讨论区 + latest_message = course.journals_for_messages.where("m_parent_id is null").order("created_on desc").first + unless latest_message.nil? + latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.journals_for_messages.where('m_parent_id is null').count, :jour_message => latest_message} + dynamics_count += 1 + end + # 课程资源 + latest_attachment = course.attachments.order("created_on desc").first + unless latest_attachment.nil? + latest_course_dynamics << {:type => 3, :time => latest_attachment.created_on,:count =>course.attachments.count , :documents=>latest_attachment} + dynamics_count += 1 + end + #课程作业 已经交的学生列表(暂定显示6人),未交的学生列表,作业的状态 + homework = course.homework_commons.order('created_at desc').first + homework_status = ""; + # 判断作业所处的状态,如果是刚发布,就获取剩余时间 + #如果是匿评状态,显示正在匿评 + #如果是匿评结束,显示匿评结束 + #获取作业提交的前6个人,不足6个显示所有 + studentlist = [] + if !homework.nil? + if homework.homework_type == 1 && homework.homework_detail_manual + case homework.homework_detail_manual.comment_status + when 1 + homework_status = show_homework_deadline homework + when 2 + homework_status = "正在匿评中" + when 3 + homework_status = "匿评已结束" + end + elsif homework.homework_type == 0 + homework_status = "未启用匿评" + elsif homework.homework_type == 2 + homework_status = "编程作业" + else + end + # 获取提交作业的前六个学生的名字 和 头像路径 + homework.student_works.order("created_at desc").page(1).per(6).each do |work| + studentlist << {:image_url=> url_to_avatar(work.user),:user_name=>work.user.realname} + end + latest_course_dynamics << {:type => 4, :time => homework.updated_at, :count=>course.homework_commons.count,:submit_count => homework.student_works.count , :homework => homework, :homework_status => homework_status, :studentlist => studentlist} + dynamics_count += 1 + end + latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] } + latest_course_dynamic = latest_course_dynamics.first + unless latest_course_dynamic.nil? + result << {:course_name => course.name, :course_id => course.id, :course_img_url => url_to_avatar(course), :course_time => course.time, :course_term => course.term,:message => dynamics_count, :dynamics => latest_course_dynamics, :count => dynamics_count} + end + end + #返回数组集合 + result.sort! { |order, newer| newer[:update_time] <=> order[:update_time] } + result + end + #计算作业的截止日期,剩余日期 + def show_homework_deadline homework + "截止日期:" << homework.end_time.to_s << ",剩余时间:" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天" + end + end -end \ No newline at end of file From 358c344ca5908c4bdb3fabf7c9044bcfc37e1827 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 16:10:49 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150619060110_homework_common_time.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/migrate/20150619060110_homework_common_time.rb b/db/migrate/20150619060110_homework_common_time.rb index c574ad93c..f5294bc66 100644 --- a/db/migrate/20150619060110_homework_common_time.rb +++ b/db/migrate/20150619060110_homework_common_time.rb @@ -10,7 +10,6 @@ class HomeworkCommonTime < ActiveRecord::Migration end end end - puts i.to_s end end From 5d9c730fd14a3e9614025c943f86220af2c678c2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 16:17:29 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E4=BD=9C=E4=B8=9A=E4=B8=8D=E7=8E=B0=E5=AE=9E=E7=BC=BA?= =?UTF-8?q?=E8=AF=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 6325abc09..0c5983a36 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -36,7 +36,7 @@ <% if @show_all%> 搜索 - <%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher%> + <%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher && @homework.homework_type == 1%> <% end%> <% if @is_teacher%>
From 95ab6dd6c0bcd276c823aa57d42069e22571a40b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 16:20:18 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E4=BD=9C=E4=B8=9A=E4=B8=8D=E5=8F=AF=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E7=BC=BA=E8=AF=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 0c5983a36..38fcb78c9 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -36,7 +36,7 @@ <% if @show_all%> 搜索 - <%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher && @homework.homework_type == 1%> + <%= link_to "缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank" if @is_teacher && @homework.homework_type == 1 && @homework.homework_detail_manual.comment_status != 1 %> <% end%> <% if @is_teacher%>
From a9ff9f96bdf3fee15afd7fa376fd85b3c3046a27 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 16:23:28 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6=E7=BC=BA=E8=AF=84=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 3ca836773..2693eea82 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -245,15 +245,19 @@ class StudentWorkController < ApplicationController def student_work_absence_penalty render_403 unless User.current.allowed_to?(:as_teacher,@course) order = params[:order] || "desc" - work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" - @stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM( + if @homework.student_works.empty? + @stundet_works = [] + else + work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" + @stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM( SELECT * , (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count, (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count FROM `student_works` WHERE homework_common_id = #{@homework.id} - ) AS table_1 - ORDER BY absence #{order}") + ) AS table_1 + ORDER BY absence #{order}") + end @order = order == "desc" ? "asc" : "desc" respond_to do |format| format.html From 8ebfe57fe0014ef181aefe3a0b8330c299416412 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Tue, 23 Jun 2015 16:05:08 +0800 Subject: [PATCH 07/17] =?UTF-8?q?bug#2901:=E8=AF=BE=E7=A8=8B=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=EF=BC=9A=E4=BB=8E=E4=B8=AA=E4=BA=BA=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E5=88=B0=E4=BA=86=E5=A6=82=E4=B8=8B=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E4=BB=8E=E8=AF=BE=E7=A8=8B=E8=AE=BA=E5=9D=9B?= =?UTF-8?q?=E5=B0=B1=E5=86=8D=E4=B9=9F=E8=BF=9B=E4=B8=8D=E5=88=B0=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E9=A1=B5=E9=9D=A2=E4=BA=86=20MessagesController#show?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=88=B0BoardsController#index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b1da35cfc..a242587fb 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -37,6 +37,14 @@ class MessagesController < ApplicationController # Show a topic and its replies def show + if @course + topic_id = params[:r]?params[:r]:params[:id] + parent_id = params[:id] + url = course_boards_path(@course,:topic_id => topic_id,:parent_id=>parent_id); + redirect_to url + return; + end + @isReply = true page = params[:page] # Find the page of the requested reply From be9cf478e540b28b5b4c69af1339be6c0c1e16a9 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Wed, 24 Jun 2015 15:39:16 +0800 Subject: [PATCH 08/17] =?UTF-8?q?bug#2911:=E7=94=A8=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E8=BF=9B=E5=85=A5admin=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=AA=97=E5=8F=A3=EF=BC=8C=E7=82=B9=E5=87=BB=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E2=80=9C=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E2=80=9D?= =?UTF-8?q?=EF=BC=8C=E6=90=9C=E7=B4=A2=E6=9F=90=E7=94=A8=E6=88=B7=EF=BC=8C?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=AF=A5=E7=94=A8=E6=88=B7=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81=E4=B8=AD?= =?UTF-8?q?=E5=AD=97=E8=A2=AB=E6=88=AA=E6=96=AD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_preferences.html.erb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/users/_preferences.html.erb b/app/views/users/_preferences.html.erb index 995e2076e..bad60c963 100644 --- a/app/views/users/_preferences.html.erb +++ b/app/views/users/_preferences.html.erb @@ -1,6 +1,9 @@ + <%= labelled_fields_for :pref, @user.pref do |pref_fields| %> -

<%= pref_fields.check_box :hide_mail %>

-

<%= pref_fields.time_zone_select :time_zone, nil, :include_blank => true %>

-

<%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %>

+

<%= pref_fields.check_box :hide_mail %>

+

<%= pref_fields.time_zone_select :time_zone, nil, :include_blank => true %>

+

<%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %>

<% end %> From 81187dea363380051cb1a58b5803eb34e683b356 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 24 Jun 2015 16:07:54 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E6=9C=89=E5=B8=A6+=E5=8F=B7=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=97=A0=E6=B3=95=E6=89=93=E5=8C=85=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/application.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c514e8940..b90011a4f 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -880,7 +880,8 @@ $(function(){ } if(res.length==1){ - location.href = '/zipdown/download?file='+res[0].file;return; + var file = encodeURI(res[0].file).replace(/\+/g, '%2B'); + location.href = '/zipdown/download?file='+file;return; } document.getElementById('light').style.display='block'; From c92bd138bb3423bf7c6e97caf98fb130f73a7b4b Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Wed, 24 Jun 2015 16:12:45 +0800 Subject: [PATCH 10/17] =?UTF-8?q?bug#2915:=E6=AD=A3=E5=BC=8F=E7=89=88?= =?UTF-8?q?=E2=80=94=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA=EF=BC=9A?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=86=85=E5=AE=B9=E8=BF=87=E5=A4=9A=E4=B8=94?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E8=A1=A8=E6=83=85=E6=97=B6=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=AE=8C=E6=95=B4=EF=BC=8C=E4=B9=9F=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=B1=95=E5=BC=80=E6=8F=90=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 27 ++++++++++++++++--------- app/views/boards/_project_show.html.erb | 27 ++++++++++++++++--------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 7eed593d9..417a5a8ba 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -70,26 +70,35 @@ //解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug $(function(){ function nh_show_btn(){ - if($("#contentmessage<%=topic.id %>").height()>182){ - $("#project_show_<%= topic.id%>").show(); + if($("#project_show_<%= topic.id%>").is(':hidden')){ + if($("#contentmessage<%=topic.id %>").height()>182){ + $("#project_show_<%= topic.id%>").show(); + } } } var div = $("#contentmessage<%=topic.id %>"); var imgs = $('img',div); var lens = imgs.length; function nh_load_img_end(){ - lens--; - if(lens <= 0){ - nh_show_btn(); - } - } - if(lens <= 0){ nh_show_btn(); - }else{ +// lens--; +// if(lens <= 0){ +// nh_show_btn(); +// } + } + if(lens > 0){ $('img',div).load(function(){ nh_load_img_end(); }); } + nh_show_btn(); +// if(lens <= 0){ +// nh_show_btn(); +// }else{ +// $('img',div).load(function(){ +// nh_load_img_end(); +// }); +// } });
diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index bb36c6f19..03d283031 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -62,26 +62,35 @@ //解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug $(function(){ function nh_show_btn(){ - if($("#contentmessage<%=topic.id %>").height()>182){ - $("#project_show_<%= topic.id%>").show(); + if($("#project_show_<%= topic.id%>").is(':hidden')){ + if($("#contentmessage<%=topic.id %>").height()>182){ + $("#project_show_<%= topic.id%>").show(); + } } } var div = $("#contentmessage<%=topic.id %>"); var imgs = $('img',div); var lens = imgs.length; function nh_load_img_end(){ - lens--; - if(lens <= 0){ - nh_show_btn(); - } - } - if(lens <= 0){ nh_show_btn(); - }else{ +// lens--; +// if(lens <= 0){ +// nh_show_btn(); +// } + } + if(lens > 0){ $('img',div).load(function(){ nh_load_img_end(); }); } + nh_show_btn(); +// if(lens <= 0){ +// nh_show_btn(); +// }else{ +// $('img',div).load(function(){ +// nh_load_img_end(); +// }); +// } });
From 251c08e431c2cb96bc6ae71adf88fa1e9e7cec62 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 24 Jun 2015 16:15:44 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=90=8D=E5=B8=A6+=E5=8F=B7=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/application.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b90011a4f..aca077d91 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -911,8 +911,10 @@ $(function(){ else { if(res.length==1){ - location.href = '/zipdown/download?file='+res[0].file;return; + var file = encodeURI(res[0].file).replace(/\+/g, '%2B'); + location.href = '/zipdown/download?file='+file;return; } + document.getElementById('light').style.display='block'; $container = $('#light .upload_box_ul'); $container.empty(); From 38b97aa55877a351bc23b375b5175d061ed6d837 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 24 Jun 2015 16:23:15 +0800 Subject: [PATCH 12/17] =?UTF-8?q?=E4=B8=8B=E8=BD=BDurl=E6=9C=89=E4=B8=A4?= =?UTF-8?q?=E5=A4=84=E9=9C=80=E8=A6=81=E5=A4=84=E7=90=86=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/application.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b90011a4f..ce5a960cf 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -863,6 +863,10 @@ function redo() { window.location.reload() } +function encodeHomeworkUrl(url){ + var file = encodeURI(url).replace(/\+/g, '%2B'); + return '/zipdown/download?file='+file; +} //// 作业附件删除 $(function(){ @@ -880,8 +884,7 @@ $(function(){ } if(res.length==1){ - var file = encodeURI(res[0].file).replace(/\+/g, '%2B'); - location.href = '/zipdown/download?file='+file;return; + location.href = encodeHomeworkUrl(res[0].file);return; } document.getElementById('light').style.display='block'; @@ -894,7 +897,7 @@ $(function(){ } else { des = '第'+res[i].index+'个学生的作品下载'; } - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } } @@ -911,7 +914,7 @@ $(function(){ else { if(res.length==1){ - location.href = '/zipdown/download?file='+res[0].file;return; + location.href = encodeHomeworkUrl(res[0].file);return; } document.getElementById('light').style.display='block'; $container = $('#light .upload_box_ul'); @@ -923,7 +926,7 @@ $(function(){ } else { des = '第'+res[i].index+'个学生的作品下载'; } - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } } From 046a593f42473861b09c7293f239d64932b412c9 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Thu, 25 Jun 2015 14:51:29 +0800 Subject: [PATCH 13/17] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E6=9C=89?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9C=89=E8=BF=99=E7=A7=8D=E8=BE=93=E5=85=A5?= =?UTF-8?q?:=20=E5=8A=A0?= =?UTF-8?q?=E4=B8=AA=E5=85=88=E5=B0=86=E5=B0=B1=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 6 +++++- app/views/boards/_project_show.html.erb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 417a5a8ba..3e1530e3f 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -104,6 +104,7 @@
    <%= topic.content.html_safe %> +
    @@ -166,7 +167,10 @@
    <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
    -
    <%= textAreailizable message,:content,:attachments => message.attachments %>
    +
    + <%= textAreailizable message,:content,:attachments => message.attachments %> + +

    <%= format_time(message.created_on) %> diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 03d283031..e7071d2a1 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -98,6 +98,7 @@
    <%= topic.content.html_safe %> +
    <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
    -
    <%= textAreailizable message,:content,:attachments => message.attachments %>
    +
    + <%= textAreailizable message,:content,:attachments => message.attachments %> + +

    <%= format_time(message.created_on) %> From ffd254b7bb75ed8e55b429b1fcd83d9e238cbc7d Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 26 Jun 2015 09:16:37 +0800 Subject: [PATCH 14/17] =?UTF-8?q?bug#2920:=E8=AF=BE=E7=A8=8B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=EF=BC=9A=E5=AF=B9=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=AF=84=E8=AE=BA=E6=97=B6=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=AD=97=E7=AC=A6=EF=BC=8C=E7=82=B9=E5=87=BB?= =?UTF-8?q?ENTER=E9=94=AE=E4=B9=9F=E5=8F=AF=E4=BB=A5=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/show.html.erb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 6e5888363..846be063f 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -3,3 +3,15 @@ <% elsif @course %> <%= render :partial => 'course_show', locals: {course: @course} %> <% end %> + From e5082ff4898178012dfaa78bbe6fab5365a4b6b1 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 26 Jun 2015 09:18:12 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E6=96=B0=E7=89=88=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=20=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course_dynamic.rb | 8 ++--- app/api/mobile/entities/homework.rb | 4 +++ app/services/courses_service.rb | 38 ++++++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb index 56b83d513..f086f1dd1 100644 --- a/app/api/mobile/entities/course_dynamic.rb +++ b/app/api/mobile/entities/course_dynamic.rb @@ -22,7 +22,7 @@ module Mobile end end obj - elsif field == :jour_message_count + elsif field == :topic_count obj = nil c[:dynamics].each do |d| if d[:type] == 2 @@ -80,7 +80,7 @@ module Mobile course_dynamic_expose :count course_dynamic_expose :news_count course_dynamic_expose :document_count - course_dynamic_expose :jour_message_count + course_dynamic_expose :topic_count course_dynamic_expose :homework_count course_dynamic_expose :homework_submit_students course_dynamic_expose :homework_submit_num @@ -95,11 +95,11 @@ module Mobile end obj end - expose :jour_message,using:Mobile::Entities::Jours do |f,opt| + expose :topic,using:Mobile::Entities::Message do |f,opt| obj = nil f[:dynamics].each do |d| if d[:type] == 2 - obj = d[:jour_message] + obj = d[:topic] end end obj diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 18dbe0d3b..e2c181048 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -68,6 +68,10 @@ module Mobile homework_expose :homework_notsubmit_num + expose :submit_student_list ,using:Mobile::Entities::User do |f,opt| + f[:studentlist] + end + end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 3856a7642..fd2cfe4a5 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -330,7 +330,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homework_commons.order('end_time DESC') + bids = course.homework_commons.page(1).per(3).order('end_time DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -540,14 +540,35 @@ class CoursesService #student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 - state = bid.homework_detail_manual.comment_status + #state = bid.homework_detail_manual.comment_status + if !bid.nil? + if bid.homework_type == 1 && bid.homework_detail_manual + case bid.homework_detail_manual.comment_status + when 1 + state = show_homework_deadline bid + when 2 + state = "正在匿评中" + when 3 + state = "匿评已结束" + end + elsif bid.homework_type == 0 + state = "未启用匿评" + elsif bid.homework_type == 2 + state = "编程作业" + else + end + end + studentlist = [] + bid.student_works.order("created_at desc").page(1).per(6).each do |work| + studentlist << work.user + end unless is_course_teacher homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user end #end open_anonymous_evaluation = bid.homework_detail_manual.comment_status {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.user,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0, - :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time} + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time,:studentlist => studentlist} end @@ -628,9 +649,9 @@ class CoursesService return end if current_user == @user || current_user.admin? - membership = @user.coursememberships.all + membership = @user.coursememberships.page(1).per(10) else - membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user)) + membership = @user.coursememberships.page(1).per(10).all(:conditions => Course.visible_condition(current_user)) end if membership.nil? || membership.count == 0 raise l(:label_no_courses, :locale => get_user_language(current_user)) @@ -653,9 +674,10 @@ class CoursesService end # 课程讨论区 - latest_message = course.journals_for_messages.where("m_parent_id is null").order("created_on desc").first + latest_message = course.boards.first.topics[0] unless latest_message.nil? - latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.journals_for_messages.where('m_parent_id is null').count, :jour_message => latest_message} + latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count, + :topic => latest_message} dynamics_count += 1 end @@ -710,7 +732,7 @@ class CoursesService #计算作业的截止日期,剩余日期 def show_homework_deadline homework - "截止日期:" << homework.end_time.to_s << ",剩余时间:" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天" + "距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天" end end From a8377f7dcb3f7901a4d6d8548489a4e302e0d6cf Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 26 Jun 2015 09:19:23 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/message.rb | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/api/mobile/entities/message.rb diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb new file mode 100644 index 000000000..6a2ca1fb0 --- /dev/null +++ b/app/api/mobile/entities/message.rb @@ -0,0 +1,46 @@ +module Mobile + module Entities + class Message < Grape::Entity + include ApplicationHelper + include ApiHelper + def self.message_expose(f) + expose f do |u,opt| + if u.is_a?(Hash) && u.key?(f) + u[f] + elsif u.is_a?(::Message) + if u.respond_to?(f) + if f == :created_on + format_time( u.send(f)) + else + u.send(f) + end + else + # case f + # when :xx + # # + # end + end + end + + end + end + + expose :user, using: Mobile::Entities::User do |c, opt| + if c.is_a?(::Message) + c.author + end + end + message_expose :board_id + message_expose :subject + message_expose :content + message_expose :replies_count + message_expose :created_on + message_expose :id + expose :message_children,using:Mobile::Entities::Message do |c,opt| + if c.is_a? (::Message) + c.children + end + end + end + end +end \ No newline at end of file From e6a15a45c4317d7301973d3a45ff18c3d53d5198 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 26 Jun 2015 09:42:17 +0800 Subject: [PATCH 17/17] =?UTF-8?q?bug#2782:=E8=AE=A8=E8=AE=BA=E5=8C=BA?= =?UTF-8?q?=EF=BC=9A=E8=8B=A5=E6=9F=90=E4=B8=80=E7=BA=A7=E5=9B=9E=E5=B8=96?= =?UTF-8?q?=E6=98=AF=E8=A7=86=E9=A2=91=EF=BC=8C=E5=86=8D=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=AF=A5=E5=9B=9E=E5=A4=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E6=98=BE=E7=A4=BA=E6=97=B6=E8=B6=85=E5=87=BA=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/public.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index b688b495f..e015fbe57 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -439,7 +439,7 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;} /*文本左对齐*/ .tl{text-align: left;} -img{max-width: 100%;} +img,embed{max-width: 100%;} .attachments {clear: both;} .is_public_checkbox{margin-left: 15px;margin-right: 10px;} .author_name{color: #3ca5c6 !important;}