Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
da21e61afd
|
@ -53,7 +53,7 @@ module Mobile
|
|||
c[:course].teacher
|
||||
end
|
||||
end
|
||||
expose :my_homework,using: Mobile::Entities::HomeworkAttach do |f, opt|
|
||||
expose :my_homework,using: Mobile::Entities::Homework do |f, opt|
|
||||
f[:my_homework] if f.is_a?(Hash) && f.key?(:my_homework)
|
||||
end
|
||||
course_expose :current_user_is_member
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Homework < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.homework_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
if field == :created_on
|
||||
format_time(f[field])
|
||||
else
|
||||
f[field]
|
||||
end
|
||||
elsif f.is_a?(::Bid)
|
||||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
|
@ -18,6 +23,8 @@ module Mobile
|
|||
homework_expose :id
|
||||
#课程名称
|
||||
homework_expose :course_name
|
||||
|
||||
homework_expose :course_id
|
||||
#作业发布者
|
||||
expose :author,using: Mobile::Entities::User do |f, opt|
|
||||
f[:author]
|
||||
|
@ -42,6 +49,9 @@ module Mobile
|
|||
#只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评
|
||||
homework_expose :homework_state
|
||||
|
||||
homework_expose :created_on
|
||||
homework_expose :deadline
|
||||
|
||||
expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt|
|
||||
f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments)
|
||||
end
|
||||
|
|
|
@ -383,8 +383,9 @@ class CoursesService
|
|||
end
|
||||
#end
|
||||
open_anonymous_evaluation = bid.open_anonymous_evaluation
|
||||
{:course_name => course.name,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments}
|
||||
{:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_on,:deadline => bid.deadline}
|
||||
|
||||
end
|
||||
|
||||
#显示作业列表的同时显示分配给当前学生匿评的作业
|
||||
|
|
|
@ -26,8 +26,8 @@ class HomeworkService
|
|||
state = @bid.comment_status
|
||||
#end
|
||||
open_anonymous_evaluation = @bid.open_anonymous_evaluation
|
||||
{:course_name => course.name,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
|
||||
{:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:created_on => @bid.created_on,:deadline => @bid.deadline}
|
||||
end
|
||||
|
||||
# 启动作业匿评前提示信息
|
||||
|
@ -274,10 +274,26 @@ class HomeworkService
|
|||
membership.each do |mp|
|
||||
my_homeworks = []
|
||||
mp.course.homeworks.each do |bid|
|
||||
hw = bid.homeworks.where("user_id = #{current_user.id}")
|
||||
my_homeworks << hw[0] unless (hw.nil? || hw[0].nil?)
|
||||
#hw = bid.homeworks.where("user_id = #{current_user.id}")
|
||||
@bid = bid
|
||||
course = @bid.courses.first
|
||||
author = @bid.author.lastname + @bid.author.firstname
|
||||
many_times = course.homeworks.index(@bid) + 1
|
||||
name = @bid.name
|
||||
homework_count = @bid.homeworks.count #已提交的作业数量
|
||||
student_questions_count = @bid.commit.nil? ? 0 : @bid.commit
|
||||
description = @bid.description
|
||||
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
|
||||
state = @bid.comment_status
|
||||
#end
|
||||
open_anonymous_evaluation = @bid.open_anonymous_evaluation
|
||||
|
||||
my_homeworks << {:course_name => course.name,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
|
||||
end
|
||||
if mp.course.homeworks.count != 0
|
||||
course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks,:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
|
||||
end
|
||||
course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks,:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
|
||||
end
|
||||
course_list
|
||||
end
|
||||
|
|
|
@ -8,12 +8,10 @@ RedmineApp::Application.configure do
|
|||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
config.logger = Logger.new('log/development.log', 'daily') # daily, weekly or monthly
|
||||
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = true
|
||||
config.cache_store = :dalli_store
|
||||
config.action_controller.perform_caching = false
|
||||
config.cache_store = :file_store, "#{Rails.root }/public/tmp/"
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ RedmineApp::Application.configure do
|
|||
# The production environment is meant for finished, "live" apps.
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
config.cache_store = :dalli_store
|
||||
|
||||
#####
|
||||
# Customize the default logger (http://ruby-doc.org/core/classes/Logger.html)
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue