Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into cxt_course

Conflicts:
	db/schema.rb
	public/stylesheets/css/common.css
	public/stylesheets/css/courses.css
This commit is contained in:
cxt 2017-02-28 10:15:33 +08:00
commit baabce13b2
247 changed files with 4946 additions and 2168 deletions

View File

@ -4,9 +4,9 @@ unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
if RUBY_PLATFORM =~ /darwin/
gem "rmagick", "= 2.15.4" ## osx must be this version
# gem "rmagick", "= 2.15.4" ## osx must be this version
elsif RUBY_PLATFORM =~ /linux/
gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
# gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
end
gem 'certified'
gem 'net-ssh', '2.9.1'

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the training_tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -42,7 +42,7 @@ class AccountController < ApplicationController
redirect_to user_path(User.current)
end
else
render :layout => 'login'
render :layout => 'login'
end
else
authenticate_user
@ -279,6 +279,14 @@ class AccountController < ApplicationController
render :json => result
end
def change_email
user = User.find params[:user_id].to_i
user.update_attributes(:mail => params[:value])
result = {:email => user.mail}
render :json => result
end
def email_activation

View File

@ -783,8 +783,8 @@ class AdminController < ApplicationController
begin
#更新消息表的status
applied_message_id = aas.school_id
applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools")
applied_message.update_all(:status => 2)
#applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools")
#applied_message.update_all(:status => 2)
aas.update_attribute(:status, 2)
AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name )
users = UserExtensions.where("school_id = #{aas.school_id}")
@ -978,7 +978,11 @@ class AdminController < ApplicationController
#作业
def homework
#@homework = HomeworkCommon.order('end_time desc')
@homework = HomeworkCommon.order( 'created_at desc ')
if params[:type] == "2"
@homework = HomeworkCommon.where(:homework_type => 2).order( 'created_at desc ')
else
@homework = HomeworkCommon.order( 'created_at desc ')
end
@homework = paginateHelper @homework,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|

View File

@ -312,7 +312,11 @@ class ApplicationController < ActionController::Base
def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false)
#modify by NWB
if @project
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
if ctrl == "repositories" && action == "show" && @project.hidden_repo
allowed = User.current.admin? || (User.current.member_of?(@project) && !(role_of_members_in_project(@project.id, User.current.id) == "Reporter"))
else
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
end
elsif @course
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
else

View File

@ -29,6 +29,8 @@ class AtController < ApplicationController
case type
when "Issue"
find_issue(id)
whne 'TrainingTask'
find_training_task(id)
when 'Project'
find_project(id)
when 'Course'
@ -69,6 +71,13 @@ class AtController < ApplicationController
at_persons.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }
end
def find_training_task(id)
training_task = TrainingTask.find(id)
journals = training_task.journals
at_persons = journals.map(&:user) + training_task.project.users
at_persons.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }
end
def find_project(id)
return [] if id.to_i<0
at_persons = Project.find(id).users

View File

@ -39,6 +39,9 @@ class BlogCommentsController < ApplicationController
end
end
def show
# 更新博客消息为已读
update_messsages_to_viewed("BlogMessage", params[:blog_id])
@article = BlogComment.find(params[:id])
@replies = BlogComment.where("root_id = #{@article.id}").reorder("created_on desc")
@reply_count = @replies.count

View File

@ -199,7 +199,7 @@ class BoardsController < ApplicationController
end
else
respond_to do |format|
format.js
format.js {render "show.js.erb"}
format.html {
if @project
render :action => 'show', :layout => 'base_projects'

View File

@ -24,7 +24,7 @@ class CommentsController < ApplicationController
before_filter :authorize, :except => [:destroy]
def create
raise Unauthorized unless @news.commentable?
#raise Unauthorized unless @news.commentable?
if !@news.org_subfield_id.nil?
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
end

View File

@ -7,7 +7,8 @@ class ContestsController < ApplicationController
helper :attachments
helper :files
include AvatarHelper
include ApplicationHelper
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :private_or_public, :switch_role, :set_invite_code_halt, :renew,
:member, :export_all_members, :feedback]
before_filter :is_logged, :only => [:index, :new, :create]
@ -18,10 +19,37 @@ class ContestsController < ApplicationController
def show
#更新创建课程消息状态
contest_request_messages = ContestMessage.where("user_id = #{User.current.id} and contest_id = #{@contest.id} and contest_message_type in ('ContestRequestDealResult', 'JoinContest', 'RemoveFromContest') and viewed = 0")
contest_request_messages.update_all(:viewed => true)
update_messsages_to_viewed("ContestMessage", @contest)
@left_nav_type = 1
contest_activities = @contest.contest_activities
@page = params[:page] ? params[:page].to_i + 1 : 0
if params[:type].present?
case params[:type]
when "work"
@contest_activities = contest_activities.where("contest_act_type = 'Work'").order('updated_at desc')
when "news"
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
when "message"
@contest_activities = contest_activities.where("contest_act_type = 'Message'").order('updated_at desc')
when "poll"
@contest_activities = contest_activities.where("contest_act_type = 'Poll'").order('updated_at desc')
when "attachment"
@contest_activities = contest_activities.where("contest_act_type = 'Attachment'").order('updated_at desc')
when "journalsForMessage"
@contest_activities = contest_activities.where("contest_act_type = 'JournalsForMessage'").order('updated_at desc')
when "news"
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
else
@contest_activities = contest_activities.order('updated_at desc')
end
else
@contest_activities = contest_activities.order('updated_at desc')
end
@contest_activities_count = @contest_activities.count
@contest_activities = @contest_activities.limit(10).offset(@page * 10)
@type = params[:type]
respond_to do |format|
format.js
format.html

View File

@ -9,6 +9,7 @@ class CoursesController < ApplicationController
helper :attachments
helper :files
helper :activity_notifys
include ApplicationHelper
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
menu_item :overview
@ -354,6 +355,44 @@ class CoursesController < ApplicationController
#search_group_members group
end
def change_manager
if params[:chooseteacher]
man_member = Member.where(:course_id => @course.id, :user_id => @course.tea_id).first
cha_member = Member.find params[:chooseteacher]
if man_member && cha_member
cha_member.member_roles.where("role_id = 9 || role_id = 7").first.update_attributes(:role_id => 3, :is_current => 1)
if cha_member.member_roles.where("role_id = 10").count > 0
cha_member.member_roles.where("role_id = 10").first.destroy
StudentsForCourse.where(:course_id => @course.id, :student_id => cha_member.user_id).destroy_all
end
@course.update_attributes(:tea_id => cha_member.user_id)
man_member.member_roles.first.update_attributes(:role_id => 9)
course_act = CourseActivity.where(:course_id => @course.id, :course_act_id => @course.id, :course_act_type => 'Course').first
course_act.update_column('user_id', cha_member.user_id)
UserActivity.where(:act_id => @course.id, :container_type => 'Course', :act_type => 'Course', :container_id => @course.id).first.update_column('user_id', cha_member.user_id)
ws = WechatService.new
title = "您已成为班级管理员"
ws.create_class_notice cha_member.user_id, "create_course_notice", @course.id,title, @course.name, man_member.user.show_name, @course.members.count, "点击查看班级详情。"
end
end
end
def search_course_teacher_list
q = params[:search] ? "#{params[:search].strip}" : ""
@members = searchTeacherAndAssistantNoManager(@course)
if q.nil? || q == ""
else
members = []
@members.each do |m|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
if m && m.user && (m.user[:login].to_s.downcase.include?(q) || m.user[:mail].to_s.downcase.include?(q) || username.include?(q))
members << m
end
end
@members = members
end
end
#查找未分班的学生
def search_not_group_member
@group = CourseGroup.find params[:group_id]
@ -454,6 +493,8 @@ class CoursesController < ApplicationController
end
def member
# 当前用户查看班级消息时,设置消息为已读
update_messsages_to_viewed("CourseMessage", @course)
## 有角色参数的才是课程,没有的就是项目
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@render_file = 'new_member_list'
@ -512,7 +553,7 @@ class CoursesController < ApplicationController
@all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q)
end
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc")
filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}";
respond_to do |format|
@ -715,8 +756,8 @@ class CoursesController < ApplicationController
new_homework.name = homework.name
new_homework.user_id = User.current.id
new_homework.description = homework.description
new_homework.publish_time = Date.today + 30
new_homework.end_time = Date.today + 60
new_homework.publish_time = Time.now + 30.days
new_homework.end_time = Time.now + 60
new_homework.homework_type = homework.homework_type
new_homework.late_penalty = homework.late_penalty
new_homework.course_id = @course.id
@ -780,7 +821,7 @@ class CoursesController < ApplicationController
attach_copied_obj.author_id = User.current.id
attach_copied_obj.copy_from = attachment.copy_from.nil? ? attachment.id : attachment.copy_from
attach_copied_obj.is_publish = 0
attach_copied_obj.publish_time = Date.today + 30
attach_copied_obj.publish_time = Time.now + 30.days
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@ -1366,7 +1407,7 @@ class CoursesController < ApplicationController
if @is_teacher
@homeworks = @course.homework_commons.where("name like '%#{@search}%'").order("created_at desc").limit(10).offset(@page * 10)
else
@homeworks = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
@homeworks = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Time.now}'").order("created_at desc").limit(10).offset(@page * 10)
end
end
@ -1388,11 +1429,19 @@ class CoursesController < ApplicationController
@members = @course.course_homework_statisticss.reorder("#{@type} #{@order}, total_score #{@order}")
elsif params[:tab] == "3"
@homework_id = params[:homework_id] ? params[:homework_id].to_i : 0
@type = params[:type] ? params[:type] : 'project_act_score'
sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score,
if @homework_id == 0
sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score,
changeset_num, issue_num, issue_journal_num, attach_num, board_num, board_message_num, pss.project_id FROM project_scores pss
JOIN student_work_projects ON student_work_projects.project_id = pss.project_id AND student_work_projects.course_id = #{@course.id}
GROUP BY pss.project_id ORDER BY #{@type} #{@order}, project_act_score #{@order}"
else
sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score,
changeset_num, issue_num, issue_journal_num, attach_num, board_num, board_message_num, pss.project_id FROM project_scores pss
JOIN student_work_projects ON student_work_projects.project_id = pss.project_id AND student_work_projects.course_id = #{@course.id} AND student_work_projects.homework_common_id = #{@homework_id}
GROUP BY pss.project_id ORDER BY #{@type} #{@order}, project_act_score #{@order}"
end
@members = ProjectScore.find_by_sql(sql)
end

View File

@ -143,7 +143,7 @@ class ForumsController < ApplicationController
reorder(order).
preload(:author, {:last_reply => :author}).
all
@forums = Forum.reorder("topic_count desc,updated_at desc")
@forums = Forum.find_by_sql("SELECT *,topic_count + memo_count tm FROM `forums` order by tm desc;")
@my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count
@my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count
@errors = params[:errors]

View File

@ -6,8 +6,12 @@ class HomeworkCommonController < ApplicationController
include StudentWorkHelper
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_homework]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_homework]
before_filter :member_of_course, :only => [:index]
def index
@ -25,7 +29,7 @@ class HomeworkCommonController < ApplicationController
@homework_commons = @course.homework_commons.where("name like '%#{search}%'").order("created_at desc")
else
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
@homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
@homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Time.now}'").order("created_at desc")
end
#update_homework_time @homework_commons
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@ -80,88 +84,105 @@ class HomeworkCommonController < ApplicationController
def update
if params[:homework_common]
is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description] || params[:homework_type].to_i != @homework.homework_type
if params[:homework_type].to_i == 2
is_update = is_update || params[:language_type] != @homework.homework_detail_programing.language
if !is_update && params[:sample] && params[:program]
is_update = params[:sample][:input] != @homework.homework_samples.map(&:input) || params[:sample][:output] != @homework.homework_samples.map(&:output) || params[:program][:input] != @homework.homework_tests.map(&:input)|| params[:program][:output] != @homework.homework_tests.map(&:output)
end
elsif params[:homework_type].to_i == 3
base_on_project = params[:base_on_project] ? 1 : 0
is_update = is_update || params[:min_num].to_i != @homework.homework_detail_group.min_num || params[:max_num].to_i != @homework.homework_detail_group.max_num || base_on_project != @homework.homework_detail_group.base_on_project
end
@homework.is_update = @homework.is_update || is_update
@homework.name = params[:homework_common][:name]
@homework.description = params[:homework_common][:description]
if params[:homework_common][:publish_time] == ""
@homework.publish_time = Date.today
else
@homework.publish_time = params[:homework_common][:publish_time]
end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
homework_end_time = @homework.end_time ? Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") : ''
if homework_end_time != param_end_time
if homework_end_time > param_end_time
@homework.student_works.where("work_status = 1").each do |st|
if param_end_time < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
st.late_penalty = @homework.late_penalty
st.work_status = 2
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
end
end
if params[:homework_common][:end_time] != ""
if params[:homework_common][:publish_time] == ""
@homework.publish_time = Time.now
else
@homework.student_works.where("work_status = 2").each do |st|
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
st.late_penalty = 0
st.work_status = 1
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
@homework.publish_time = params[:homework_common][:publish_time]
end
param_end_time = Time.parse(params[:homework_common][:end_time])
homework_end_time = @homework.end_time ? @homework.end_time : ''
if homework_end_time != param_end_time
if homework_end_time > param_end_time
@homework.student_works.where("work_status = 1").each do |st|
if param_end_time < st.commit_time
st.late_penalty = @homework.late_penalty
st.work_status = 2
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
end
end
else
@homework.student_works.where("work_status = 2").each do |st|
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
st.late_penalty = 0
st.work_status = 1
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
end
end
end
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
status = false
if @homework.publish_time > Time.now && homework_detail_manual.comment_status == 1
homework_detail_manual.comment_status = 0
@homework.student_works.destroy_all
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
end
elsif @homework.publish_time <= Time.now && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
create_works_list @homework if params[:homework_type].to_i != 3
status = true
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
end
end
eval_start = homework_detail_manual.evaluation_start
if eval_start.nil? || (Time.parse(eval_start.to_s) <= @homework.end_time && homework_detail_manual.comment_status <= 1)
homework_detail_manual.evaluation_start = @homework.end_time + 7
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
end
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
if params[:homework_type] && params[:homework_type].to_i != @homework.homework_type
if @homework.homework_type == 2
@homework.homework_detail_programing.destroy if @homework.homework_detail_programing
@homework.homework_tests.destroy_all
elsif @homework.homework_type == 3
@homework.homework_detail_group.destroy if @homework.homework_detail_group
create_works_list @homework
create_works_list @homework if homework_detail_manual.comment_status > 0 && @homework.student_works.empty?
end
if params[:homework_type].to_i == 3
@homework.student_works.destroy_all
end
@homework.homework_type = params[:homework_type].to_i
end
@homework.homework_type = params[:homework_type].to_i || @homework.homework_type
anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
if anonymous != @homework.anonymous_comment
if anonymous == 1
if anonymous == 1
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.4 : 1.0
else
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.3 : 0.6
end
end
status = false
if @homework.publish_time > Date.today && homework_detail_manual.comment_status == 1
homework_detail_manual.comment_status = 0
@homework.student_works.destroy_all
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
end
elsif @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
status = true
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
end
end
eval_start = homework_detail_manual.evaluation_start
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
homework_detail_manual.evaluation_start = @homework.end_time + 7
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
end
@homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework)
@ -178,6 +199,17 @@ class HomeworkCommonController < ApplicationController
end
end
@homework.homework_samples.delete_all if params[:sample]
sample_inputs = params[:sample][:input] if params[:sample]
if Array === sample_inputs
sample_inputs.each_with_index do |val, i|
@homework.homework_samples << HomeworkSample.new(
input: val,
output: params[:sample][:output][i]
)
end
end
@homework.homework_tests.delete_all if params[:program]
inputs = params[:program][:input] if params[:program]
if Array === inputs
@ -211,9 +243,9 @@ class HomeworkCommonController < ApplicationController
@homework_detail_programing.save if @homework_detail_programing
@homework_detail_group.save if @homework_detail_group
if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
create_works_list @homework
end
# if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
# create_works_list @homework
# end
@hw_status = params[:hw_status].to_i
if params[:is_manage] == "1"
@ -280,6 +312,85 @@ class HomeworkCommonController < ApplicationController
end
end
#加入到题库
def add_to_homework_bank
if params[:type] && (params[:type].to_i == 1 || params[:type].to_i == 3)
if params[:type].to_i == 3
old_banks = HomeworkBank.where(:homework_common_id => @homework.id)
unless old_banks.blank?
old_banks.each do |bank|
bank.update_attributes(:quotes => (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0)
end
end
end
homework_bank = add_to_homework_bank_f @homework
homework_bank.save
@homework.update_attributes(:homework_bank_id => homework_bank.id)
elsif params[:type].to_i == 2
homework_bank = HomeworkBank.where(:id => @homework.homework_bank_id).first
if homework_bank
homework_bank.update_attributes(:name => @homework.name, :description => @homework.description, :homework_type => @homework.homework_type)
if @homework.homework_type == 2 && @homework.homework_detail_programing
homework_bank.update_attributes(:language => @homework.homework_detail_programing.language)
homework_bank.homework_bank_tests.destroy_all
@homework.homework_tests.each_with_index do |homework_test|
homework_bank.homework_bank_tests << HomeworkBankTest.new(
test_type: 1,
input: homework_test.input,
output: homework_test.output
)
end
@homework.homework_samples.each_with_index do |homework_test|
homework_bank.homework_bank_tests << HomeworkBankTest.new(
test_type: 0,
input: homework_test.input,
output: homework_test.output
)
end
elsif @homework.homework_type == 3 && @homework.homework_detail_group
homework_bank.update_attributes(:min_num => @homework.homework_detail_group.min_num, :max_num => @homework.homework_detail_group.max_num, :base_on_project => @homework.homework_detail_group.base_on_project)
end
end
end
if @homework.is_update
@homework.update_attributes(:is_update => 0)
end
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
end
def publish_homework
if @homework.homework_detail_manual.comment_status > 0
@status = 1
elsif @homework.publish_time.nil?
@status = 2
else
homework_detail_manual = @homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1)
@homework.update_attributes(:publish_time => Time.now)
@status = 3
if @homework.homework_type != 3
create_works_list @homework
end
#更新CourseHomeworkStatistics中每个学生的未交作品数
@course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
end
@course.members.each do |m|
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => @course.id, :viewed => false, :status => nil)
end
if @homework.course_acts.size == 0
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
end
end
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
end
# 成绩公开范围弹框
def alert_score_open_modal
if params[:user_activity_id]
@ -301,7 +412,7 @@ class HomeworkCommonController < ApplicationController
#statue 1:启动成功2启动失败作业总数大于等于2份时才能启动匿评3:已开启匿评,请务重复开启,4:没有开启匿评的权限
def start_anonymous_comment
@statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
@statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
@statue = 5 and return if @homework.end_time >= Time.now
if @homework_detail_manual.comment_status == 1
student_works = @homework.student_works.has_committed
if student_works && student_works.size >= 2

View File

@ -260,7 +260,7 @@ class MessagesController < ApplicationController
elsif @course
redirect_to course_activity_path(@course)
elsif @contest
redirect_to contest_activities_contest_path(@contest)
redirect_to contest_path(@contest)
end
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
if @project
@ -351,7 +351,7 @@ class MessagesController < ApplicationController
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_contest_community_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
redirect_to contest_activities_contest_path(@contest)
redirect_to contest_path(@contest)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
redirect_to contest_boards_path(@contest)
elsif @message.parent

View File

@ -1,166 +1,168 @@
class PraiseTreadController < ApplicationController
accept_api_auth :tread_plus,:praise_plus
# before_filter :require_login,:only => [:praise_plus,:tread_plus]
before_filter :user_unlogged_check,:only => [:praise_plus,:tread_plus,:praise_minus]
def praise_plus
@obj = nil
@activity = false
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
# @is_in_list = nil
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id)
unless pts.empty?
respond_to do |format|
format.js
end
return
end
@horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal]
# if @obj.respond_to?("author_id")
# author_id = @obj.author_id
# elsif @obj.respond_to?("user_id")
# author_id = @obj.user_id
# end
# unless author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,1)
# end
respond_to do |format|
format.js
end
end
end
def praise_minus
@obj = nil
@activity = false
if request.get?
#@obj = params[:obj] # 传的是对象最后变成id了
#首先更新praise_tread 表 删除关注记录
#@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user")
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
@pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first
if @pt.nil?
respond_to do |format|
format.js
end
return
end
@pt.delete if !@pt.nil?
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
@ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first
@ptc.minus(1) if !@ptc.nil?
if @ptc.praise_num == 0
@ptc.delete
end
end
#@obj = User.find_by_id(@obj)
respond_to do |format|
format.js
end
end
def tread_plus
@obj = nil
# @is_in_list = nil
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
#@horizontal = params[:horizontal].downcase == "false" ? false:true
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,0)
end
end
end
def tread_minus
respond_to do |format|
format.html
format.js
end
end
private
def find_object_by_type_and_id(type,id)
@obj = nil
case type
when 'Memo'
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
when 'HomeworkCommon'
@obj = HomeworkCommon.find_by_id(id)
when 'JournalsForMessage'
@obj = JournalsForMessage.find_by_id(id)
when 'News'
@obj = News.find_by_id(id)
when 'Comment'
@obj = Comment.find_by_id(id)
when 'Journal'
@obj = Journal.find_by_id(id)
when 'BlogComment'
@obj = BlogComment.find_by_id(id)
when 'OrgDocumentComment'
@obj = OrgDocumentComment.find_by_id(id)
when 'User'
@obj = User.find_by_id(id)
when 'Issue'
@obj = Issue.find_by_id(id)
when 'Project'
@obj = Project.find_by_id(id)
when 'Bid'
@obj = Bid.find_by_id(id)
when 'Contest'
@obj = Contest.find_by_id(id)
when 'Syllabus'
@obj = Syllabus.find_by_id(id)
when 'Work'
@obj = Work.find_by_id(id)
else
@obj = nil
end
return @obj
end
def praise_tread_plus(type,id,flag)
unless id.nil? and type.nil?
#首先创建或更新praise_tread 表
@pt = PraiseTread.new
@pt.user_id = User.current.id
@pt.praise_tread_object_id = id.to_i
@pt.praise_tread_object_type = type
@pt.praise_or_tread = flag
@pt.save
# end
#再创建或更新praise_tread_cache表
#@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
@ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first
@ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc
@ptc.object_id = id.to_i
@ptc.object_type = type
@ptc.save
@ptc.plus(flag,1)
end
end
end
class PraiseTreadController < ApplicationController
accept_api_auth :tread_plus,:praise_plus
# before_filter :require_login,:only => [:praise_plus,:tread_plus]
before_filter :user_unlogged_check,:only => [:praise_plus,:tread_plus,:praise_minus]
def praise_plus
@obj = nil
@activity = false
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
# @is_in_list = nil
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id)
unless pts.empty?
respond_to do |format|
format.js
end
return
end
@horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal]
# if @obj.respond_to?("author_id")
# author_id = @obj.author_id
# elsif @obj.respond_to?("user_id")
# author_id = @obj.user_id
# end
# unless author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,1)
# end
respond_to do |format|
format.js
end
end
end
def praise_minus
@obj = nil
@activity = false
if request.get?
#@obj = params[:obj] # 传的是对象最后变成id了
#首先更新praise_tread 表 删除关注记录
#@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user")
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
@pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first
if @pt.nil?
respond_to do |format|
format.js
end
return
end
@pt.delete if !@pt.nil?
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
@ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first
@ptc.minus(1) if !@ptc.nil?
if @ptc.praise_num == 0
@ptc.delete
end
end
#@obj = User.find_by_id(@obj)
respond_to do |format|
format.js
end
end
def tread_plus
@obj = nil
# @is_in_list = nil
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
#@horizontal = params[:horizontal].downcase == "false" ? false:true
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,0)
end
end
end
def tread_minus
respond_to do |format|
format.html
format.js
end
end
private
def find_object_by_type_and_id(type,id)
@obj = nil
case type
when 'Memo'
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
when 'HomeworkCommon'
@obj = HomeworkCommon.find_by_id(id)
when 'JournalsForMessage'
@obj = JournalsForMessage.find_by_id(id)
when 'News'
@obj = News.find_by_id(id)
when 'Comment'
@obj = Comment.find_by_id(id)
when 'Journal'
@obj = Journal.find_by_id(id)
when 'BlogComment'
@obj = BlogComment.find_by_id(id)
when 'OrgDocumentComment'
@obj = OrgDocumentComment.find_by_id(id)
when 'User'
@obj = User.find_by_id(id)
when 'Issue'
@obj = Issue.find_by_id(id)
when 'TrainingTask'
@obj = TrainingTask.find_by_id(id)
when 'Project'
@obj = Project.find_by_id(id)
when 'Bid'
@obj = Bid.find_by_id(id)
when 'Contest'
@obj = Contest.find_by_id(id)
when 'Syllabus'
@obj = Syllabus.find_by_id(id)
when 'Work'
@obj = Work.find_by_id(id)
else
@obj = nil
end
return @obj
end
def praise_tread_plus(type,id,flag)
unless id.nil? and type.nil?
#首先创建或更新praise_tread 表
@pt = PraiseTread.new
@pt.user_id = User.current.id
@pt.praise_tread_object_id = id.to_i
@pt.praise_tread_object_type = type
@pt.praise_or_tread = flag
@pt.save
# end
#再创建或更新praise_tread_cache表
#@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
@ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first
@ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc
@ptc.object_id = id.to_i
@ptc.object_type = type
@ptc.save
@ptc.plus(flag,1)
end
end
end

View File

@ -21,19 +21,22 @@
class ProjectsController < ApplicationController
layout 'base_projects'
before_filter :authorize1, :only => [:show]
menu_item :overview, :only => :show
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
menu_item :homework, :only => [:homework, :new_homework]
menu_item :feedback, :only => :feedback
menu_item :share, :only => :share
# menu_item :overview, :only => :show
# menu_item :roadmap, :only => :roadmap
# menu_item :settings, :only => :settings
# menu_item :homework, :only => [:homework, :new_homework]
# menu_item :feedback, :only => :feedback
# menu_item :share, :only => :share
skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
skip_before_filter :check_if_login_required, :only => [:training_task_status]
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,
:view_homework_attaches,:join_project, :project_home]
:view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status]
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar]
before_filter :file
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
# before_filter :memberAccess, only: :member
@ -72,6 +75,7 @@ class ProjectsController < ApplicationController
include UsersHelper
### added by william
include ActsAsTaggableOn::TagsHelper
include ApplicationHelper
# 仅仅为了转换Gitlab地址
def project_home
@ -331,9 +335,11 @@ class ProjectsController < ApplicationController
if User.current.member_of?(@project) || User.current.admin?
case params[:type]
when nil
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'TrainingTask','Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
when 'issue'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
when 'training_task'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'TrainingTask'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
when 'news'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
when 'message'
@ -378,7 +384,9 @@ class ProjectsController < ApplicationController
def settings
# 顶部导航
@project_menu_type = 10
if @project.is_child_training_project?
return render_404
end
# 修改查看消息状态
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
applied_messages.update_all(:viewed => true)
@ -575,7 +583,7 @@ class ProjectsController < ApplicationController
if params[:message_id]
message_invite(params[:message_id], params[:key])
end
update_message_status(User.current, @project)
update_messsages_to_viewed("ForgeMessage", @project)
# params[:login]为邮箱邀请用户加入,主要功能:
# 1、自动注册
# 2、加入项目、创建角色
@ -764,6 +772,18 @@ class ProjectsController < ApplicationController
end
end
def add_script
if User.current.admin? || User.current.member_of?(@project)
if @project.update_attribute(:script, params[:project_script])
@notice = "脚本添加成功"
else
@notice = "脚本添加失败"
end
else
return render_403
end
end
def modules
@project.enabled_module_names = params[:enabled_module_names]
flash[:notice] = l(:notice_successful_update)
@ -804,6 +824,242 @@ class ProjectsController < ApplicationController
redirect_to admin_projects_url(:status => params[:status])
end
# 弹框提醒:
# 自己不能参加自己的实训项目
# 没有建立版本库的项目不能开启实训
# 已经实训过直接跳入
#
def training_chiled_project_exec
if !User.current.logged?
return render_403
end
respond_to do |format|
format.js
end
end
# training_status: 默认为0 1代表实训项目 2代表实训子项目
def training_project_execute
if @project.training_tasks.count == 0
@notice = "实训开启失败:请先发布实训任务"
return
elsif Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").count == 0
@notice = "实训开启失败:请先创建版本库"
return
end
jobName = "#{@project.id}"
pipeLine = "#{Base64.encode64(@project.script)}"
uri = URI("http://123.59.135.74:9999/jenkins-exec/api/createJob")
params = {jobName: jobName, pipeLine: pipeLine}
res = uri_exec uri, params
training_project_notice res
@project.update_attribute(:training_status, 1)
end
def training_project_update
jobName = "#{@project.id}"
pipeLine = "#{Base64.encode64(@project.script)}"
uri = URI("http://123.59.135.74:9999/jenkins-exec/api/updateJob")
params = {jobName: jobName, pipeLine: pipeLine}
res = uri_exec uri, params
training_project_notice res
@project.update_attribute(:training_status, 1)
end
def training_project_notice res
if res['code'] == 0
@notice = "实训开启成功"
elsif res['code'] == -2
@notice = "Job已存在"
else
@notice = res['msg'].nil? ? "实训开启失败" : res['msg']
end
end
# TrainintTask.status 0评测中 1评测成功 2评测进行中
# 非项目成员、非实训子项目不允许执行该方法
def task_execute
if !@project.is_child_training_project? || !User.current.member_of?(@project)
return render_403
end
taskId = params[:training_task_id]
jobName = @project.forked_from_project_id
@training_task = TrainingTask.find(taskId)
step = @training_task.position
rep_identify = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first.try(:identifier)
gitlab_address = Redmine::Configuration['gitlab_address']
gitUrl = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ rep_identify + "."+"git"
gitUrl = Base64.encode64(gitUrl)
if @training_task.status == 0
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"}
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
begin
res = uri_exec uri, params
# 任务开启成功后创建一条留言提示,并发布
@training_task.update_attribute(:status, 2)
return
rescue Exception => e
puts e
end
end
end
def uri_exec uri, params
res = Net::HTTP.post_form(uri, params).body
res = JSON.parse(res)
end
# 开启实训项目,学生会fork一个项目并自动发送任务
def training_project_extend
@project = Project.find(params[:id])
@repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab")
# 如果当前用户已经fork过该项目不会新fork项目则跳至已fork的项
unless has_forked?(@project, User.current)
project = project_from_current_project(@project.id, User.current.id)
redirect_to project_path(project)
else
ActiveRecord::Base.transaction do
g = Gitlab.client
if User.current.gid.nil?
s = Trustie::Gitlab::Sync.new
s.sync_user(User.current)
end
gproject = g.fork(@project.gpid, User.current.gid)
if gproject
new_training_project = copy_project_and_module(@project, gproject)
forked_count = @project.forked_count.to_i + 1
@project.update_attributes(:forked_count => forked_count)
# 发布实训任务,只发布实训任务的第一个
publish_training_tasks(@project.id, new_training_project.id, 1)
end
end
end
end
# 需要传Task ID
# 判断任务是否完成
# 如果完成则发送下一个任务直到任务结束
# TrainingTask.status 1 成功,其它失败
def training_task_status
status = params[:status].to_i
task_id = params[:taskId]
message = Base64.decode64(params[:msg])
begin
@training_task = TrainingTask.find(task_id)
# 如果已经执行成功过,则不重复执行
return if @training_task.status == 1
original_project_id = Project.find(@training_task.project_id).try(:forked_from_project_id)
original_project = Project.find(original_project_id)
rescue
return
end
original_tasks_count = original_project.training_tasks.count
position = @training_task.try(:position)
# 测试,默认成功
if status == 0
ActiveRecord::Base.transaction do
if position < original_tasks_count
# 继续发布下一个任务
publish_training_tasks original_project_id, @training_task.project_id, position + 1
end
@training_task.update_attribute(:status, 1)
# 创建一条回复提醒
content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务"
add_training_task_journal(content, original_project.user_id)
end
else
content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
add_training_task_journal(content, original_project.user_id)
# 失败的时候可以继续提交
@training_task.update_attribute(:status, 0)
end
end
# 创建一条回复
def add_training_task_journal content, user_id
jour = Journal.new
jour.user_id = user_id
jour.notes = content
jour.journalized = @training_task
jour.save
update_user_activity(@training_task.class, @training_task.id)
update_forge_activity(@training_task.class, @training_task.id)
end
# 实训开启成功后,发布第一个任务
# REDO:失败后提醒用户,及相关处理
def publish_training_tasks original_project_id, new_training_project_id, position
original_task = TrainingTask.where(:project_id => original_project_id, :position => position).first
training_task = TrainingTask.new
training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
training_task.subject = original_task.subject
training_task.description = original_task.description
training_task.position = original_task.position
training_task.project_id = new_training_project_id
training_task.author_id = User.current.id
if training_task.save
respond_to do |format|
format.html{redirect_to project_url(new_training_project_id)}
end
else
raise "create task failed"
end
end
# 复制项目
def copy_project_and_module tproject, gproject
project = Project.new
project.name = tproject.name
project.is_public = tproject.is_public
project.status = tproject.status
project.description = tproject.description
project.hidden_repo = tproject.hidden_repo
project.user_id = User.current.id
project.project_type = 0
project.project_new_type = tproject.project_new_type
project.gpid = gproject.id
project.forked_from_project_id = tproject.id
project.enabled_module_names = tproject.enabled_module_names
if project.save
project.update_attribute(:training_status,2)
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
if ProjectScore.where("project_id=?", project.id).first.nil?
ProjectScore.create(:project_id => project.id, :score => false)
end
project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id)
Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0)
Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
project.members << m
project.project_infos << project_info
copy_repository(project, gproject)
return project
else
respond_to do |format|
format.html { render :action => 'forked', :layout => 'base_projects'}
format.api { render_validation_errors(@project) }
end
end
end
# 判断用户是否已经fork过该项目
def has_forked?(project, user)
projects = Project.where("user_id =?", user)
projects.map(&:forked_from_project_id).detect{|s| s == @project.id}.nil? ? true : false
end
def copy_repository(project, gproject)
repository = Repository.factory('Git')
repository.project_id = project.id
repository.type = 'Repository::Gitlab'
repository.url = gproject.name
repository.identifier = gproject.name
repository = repository.save
end
# 资源库fork弹框
def forked_pop
respond_to do |format|

View File

@ -35,12 +35,13 @@ class RepositoriesController < ApplicationController
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :export_rep_static]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :export_rep_static, :training_project_extend]
# 连接gitlab
# before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff]
# before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff]
before_filter :authorize_visible , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff]
# 版本库新增权限
# before_filter :show_rep, :only => [:show, :stats, :revisions, :revision, :diff, :commit_diff ]
accept_rss_auth :revisions
@ -132,6 +133,94 @@ class RepositoriesController < ApplicationController
# send_file "/path/to/file.zip"
end
# 开启实训项目,学生会fork一个项目并自动发送任务
def training_project_extend
@project = Project.find(params[:id])
@repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab")
# 如果当前用户已经fork过该项目不会新fork项目则跳至已fork的项
unless has_forked?(@project, User.current)
project = project_from_current_project(@project.id, User.current.id)
redirect_to project_path(project)
else
ActiveRecord::Base.transaction do
g = Gitlab.client
if User.current.gid.nil?
begin
s = Trustie::Gitlab::Sync.new
s.sync_user(User.current)
ensure
logger.error "Syn user failed ==>#{User.current.id}"
end
end
gproject = g.fork(@project.gpid, User.current.gid)
if gproject
new_training_project = copu_project_and_module(@project, gproject)
forked_count = @project.forked_count.to_i + 1
@project.update_attributes(:forked_count => forked_count)
# 发布实训任务,只发布实训任务的第一个
publish_training_tasks(@project, new_training_project)
end
end
end
end
def copu_project_and_module tproject, gproject
project = Project.new
project.name = tproject.name
project.is_public = tproject.is_public
project.status = tproject.status
project.description = tproject.description
project.hidden_repo = tproject.hidden_repo
project.user_id = User.current.id
project.project_type = 0
project.project_new_type = tproject.project_new_type
project.gpid = gproject.id
project.forked_from_project_id = tproject.id
project.enabled_module_names = tproject.enabled_module_names
if project.save
project.update_attribute(:training_status,1)
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
if ProjectScore.where("project_id=?", project.id).first.nil?
ProjectScore.create(:project_id => project.id, :score => false)
end
project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id)
Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0)
Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
project.members << m
project.project_infos << project_info
copy_repository(project, gproject)
return project
else
respond_to do |format|
format.html { render :action => 'forked', :layout => 'base_projects'}
format.api { render_validation_errors(@project) }
end
end
end
# REDO: 如果实训项目还没有创建任务的时候应该跳出
def publish_training_tasks original_project, new_training_project
original_task = TrainingTask.where(:project_id => original_project.id, :position => 1).first
training_task = TrainingTask.new
training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
training_task.subject = original_task.subject
training_task.description = original_task.description
training_task.position = original_task.position
training_task.project_id = new_training_project.id
training_task.author_id = User.current.id
if training_task.save
respond_to do |format|
format.html{redirect_to project_training_tasks_url(:project_id => new_training_project.id)}
end
else
raise "create task failed"
end
end
# 判断用户是否已经fork过该项目
def has_forked?(project, user)
projects = Project.where("user_id =?", user)
@ -183,6 +272,7 @@ class RepositoriesController < ApplicationController
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => project.id) }
format.js
end
return project
else
respond_to do |format|
format.html { render :action => 'forked', :layout => 'base_projects'}
@ -396,11 +486,12 @@ update
redirect_to :controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab'
end
# 权限:
# 如果项目隐藏了版本库,则非项目成员及项目报告人员不能够访问版本库
# 如果没有隐藏版本库,只要项目公开,其它成员都可以看到版本库
# 项目关联了课程,课程的老师是可以看到版本库的
# 超级管理员可以看到项目版本库
def show
if !User.current.admin? && (@project.hidden_repo && (role_of_members_in_project(@project.id, User.current.id) == "Reporter" || !is_project_member?(User.current.id, @project.id)))
render_403
return
else
# 顶部导航
@project_menu_type = 5
@ -410,7 +501,6 @@ update
if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else
unless @entries.blank?
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# 总的提交数
@ -426,7 +516,6 @@ update
# token值解密
# gitlab_token = aes_dicrypt("priEn3UwXfJs3Pmy", token)
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + token
end
@creator = @project.owner.to_s
gitlab_address = Redmine::Configuration['gitlab_address']
@ -448,7 +537,6 @@ update
render :layout => 'base_projects'
end
end
end
alias_method :browse, :show
@ -698,6 +786,19 @@ update
end
end
def authorize_visible
allowed = authorize_allowed(params[:controller], params[:action], global = false)
if allowed || User.current.admin? || (@project.hidden_repo && User.current.member_of?(@project) && !role_of_members_in_project(@project.id, User.current.id) == "Reporter")
true
else
if @project && @project.archived?
render_403 :message => :notice_not_authorized_archived_project
else
deny_access
end
end
end
private
# 更新项目统计数
def update_commits_count project, count

View File

@ -41,7 +41,7 @@ class StudentWorkController < ApplicationController
else
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
if @homework.end_time < Time.now.to_s
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
@ -160,7 +160,7 @@ class StudentWorkController < ApplicationController
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
if @homework.end_time < Time.now.to_s
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
@ -365,7 +365,7 @@ class StudentWorkController < ApplicationController
end
##################################################################################################################
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name].to_s.strip || "",params[:group]
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now).order("created_at desc")
@all_homework_commons = @course.homework_commons.order("created_at desc")
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
@ -398,7 +398,7 @@ class StudentWorkController < ApplicationController
end
#开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && @homework.end_time < Time.now && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
if @order == 'lastname'
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif @order == 'student_id'
@ -464,7 +464,7 @@ class StudentWorkController < ApplicationController
@student_work_count = (search_homework_member @homework.student_works.has_committed.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
else
if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && @homework.end_time < Time.now && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
if @order == 'lastname'
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif @order == 'student_id'
@ -596,7 +596,7 @@ class StudentWorkController < ApplicationController
student_work.project_id = @student_work_project.project_id
end
#提交作品时,计算是否迟交
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
if @homework.end_time < Time.now.to_s
student_work.late_penalty = @homework.late_penalty
student_work.work_status = 2
# 缺评扣分
@ -669,7 +669,7 @@ class StudentWorkController < ApplicationController
def edit
@user = User.current
if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
if (!User.current.admin? && @homework.homework_type == 2) || @homework.end_time < Time.now #编程作业不能修改作业|| 截止日期已到不能修改作业
render_403
else
respond_to do |format|
@ -1131,7 +1131,7 @@ class StudentWorkController < ApplicationController
unless @homework.late_penalty.to_s == params[:late_penalty].to_s
@homework.late_penalty = params[:late_penalty].to_s
@homework.student_works.where("commit_time > '#{@homework.end_time} 23:59:59'").each do |student_work|
@homework.student_works.where("commit_time > '#{@homework.end_time}'").each do |student_work|
student_work.late_penalty = params[:late_penalty].to_i
student_work.save
end
@ -1253,7 +1253,7 @@ class StudentWorkController < ApplicationController
def appeal_anonymous_score
@student_work_score = StudentWorksScore.where("id = #{params[:score_id].to_i}").first
@is_last = params[:is_last]
@is_last = params[:is_last] == "true" ? true : false
if @student_work_score
@student_work_score.update_column('appeal_status', 1)
score_appeal = StudentWorksScoresAppeal.create(:user_id => User.current.id, :student_works_score_id => @student_work_score.id, :comment => params[:appeal][:comment], :appeal_status => 1)
@ -1274,8 +1274,8 @@ class StudentWorkController < ApplicationController
def deal_appeal_score
@student_work_score = StudentWorksScore.where("id = #{params[:score_id].to_i}").first
@is_last = params[:is_last]
if @student_work_score
@is_last = params[:is_last] == "true" ? true : false
if @student_work_score && @student_work_score.appeal_status == 1
@student_work_score.update_column('appeal_status', params[:status].to_i)
score_appeal = @student_work_score.student_works_scores_appeal
score_appeal.applied_messages.update_all(:status => params[:status].to_i == 2 ? 3 : (params[:status].to_i == 3 ? 1 : 2))
@ -1306,23 +1306,31 @@ class StudentWorkController < ApplicationController
CourseMessage.create(:user_id => @student_work_score.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
CourseMessage.create(:user_id => score_appeal.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
end
@homework = @student_work_score.student_work.homework_common
@is_teacher = User.current.allowed_to?(:as_teacher, course) || User.current.admin?
@work = @student_work_score.student_work
@is_group_leader = !@work.student_work_projects.empty?
end
@homework = @student_work_score.student_work.homework_common
@is_teacher = User.current.allowed_to?(:as_teacher, course) || User.current.admin?
@work = @student_work_score.student_work
@is_group_leader = !@work.student_work_projects.empty?
end
def forbidden_anonymous_comment
@homework.update_column('anonymous_comment', @homework.anonymous_comment == 0 ? 1 : 0)
homework_detail_manual = @homework.homework_detail_manual
homework_detail_programing = @homework.homework_detail_programing
if homework_detail_programing
homework_detail_manual.update_column('ta_proportion', 0.4)
homework_detail_programing.update_column('ta_proportion', 0.6)
if @homework.anonymous_comment == 1
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.4 : 1.0
else
homework_detail_manual.update_column('ta_proportion', 1.0)
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.3 : 0.6
end
if @homework.homework_type == 2 && homework_detail_programing
if @homework.anonymous_comment == 1
homework_detail_programing.ta_proportion = 0.6
else
homework_detail_programing.ta_proportion = 0.5
end
end
homework_detail_manual.save
homework_detail_programing.save if homework_detail_programing
@homework.student_works.each do |student_work|
set_final_score @homework,student_work
student_work.save

View File

@ -118,7 +118,7 @@ class SyllabusesController < ApplicationController
if @order.to_i == 2
@type = 2
@courses.each do |course|
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Time.now}'").count + visable_attachemnts_incourse(course).count)
if course[:infocount] < 0
course[:infocount] = 0
end

View File

@ -0,0 +1,403 @@
# encoding: utf-8
class TrainingTasksController < ApplicationController
layout 'base_projects'
before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task]
before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete, :destroy]
before_filter :allow_manager, :only => [:index, :show]
before_filter :allow_members, :only => [:new, :create]
before_filter :build_new_task_from_params, :only => [:new, :create, :update_form]
# before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
# before_filter :authorize, :except => [:index, :show]
# before_filter :authorize, :except => [:new, :index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue, :issue_commit_delete]
before_filter :check_for_default_issue_status, :only => [:new, :create]
before_filter :build_new_task_from_params, :only => [:new, :create, :update_form]
accept_rss_auth :index, :show
accept_api_auth :index, :show, :create, :update, :destroy
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
helper :journals
helper :projects
include ProjectsHelper
helper :custom_fields
include CustomFieldsHelper
helper :issue_relations
include IssueRelationsHelper
helper :watchers
include WatchersHelper
helper :attachments
include AttachmentsHelper
helper :queries
include QueriesHelper
helper :repositories
include RepositoriesHelper
helper :sort
include SortHelper
include IssuesHelper
helper :timelog
include Redmine::Export::PDF
helper :project_score
include ApplicationHelper
def issue_commit_delete
commit_id = params[:commit_id].split(",")
issue_commit_ids = params[:issue_commit_ids]
# issue_id存在则为issue详情或者编辑的时候否则为新建Issue
# 编辑和详情的时候需要在数据库中删除记录,新建的时候在内存中删除
if params[:issue_id]
commit_issue = CommitIssues.where(:commit_id => commit_id, :issue_id => params[:issue_id], :project_id => @project.id).first
commit_issue.delete if commit_issue
end
@issue_commit_ids = issue_commit_ids - commit_id
end
# over
def index
# 顶部导航
@project_menu_type = 11
@training_tasks = TrainingTask.where(:project_id => @project.id).order('position desc')
@training_tasks_count = @training_tasks.count
@limit = 10
@is_remote = true
@training_tasks_pages = Paginator.new @training_tasks_count, @limit, params['page'] || 1
@offset ||= @training_tasks_pages.offset
@training_tasks = paginateHelper @training_tasks, @limit
respond_to do |format|
format.js
format.html
end
rescue ActiveRecord::RecordNotFound
render_404
end
def show
# 顶部导航
@project_menu_type = 11
# 打开编辑内容
@is_edit = true unless params[:edit].nil?
@jour_reply = Journal.new
@journals = @training_task.journals.includes(:user, :details).reorder("#{Journal.table_name}.id desc").all
@journals = get_no_children_comments_all @journals
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @training_task.project)
@journals.reverse! if User.current.wants_comments_in_reverse_order?
@journal = Journal.new(:journalized => @training_task)
respond_to do |format|
format.html
format.js
end
end
# Add a new issue
# The new issue will be created from an existing one if copy_from parameter is given
def new
if @project.is_child_training_project?
return render_404
end
# 顶部导航
@project_menu_type = 11
respond_to do |format|
format.html { render :action => 'new', :layout => 'base_projects' }
end
end
# 用户发布新任务
def create
if @project.is_child_training_project?
return render_404
end
@training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
@training_task.subject = params[:training_task][:subject]
@training_task.description = params[:training_task][:description]
@training_task.tracker_id = params[:training_task][:tracker_id]
@training_task.position = params[:training_task][:position].to_i
if @training_task.save
respond_to do |format|
format.html {
render_attachment_warning_if_needed(@training_task)
redirect_to training_task_url(@training_task)
}
end
return
else
respond_to do |format|
format.html { render :action => 'new' }
end
end
end
def complete_training_task
taskId = @training_task.position
end
def edit
@project_menu_type = 11
# 修改实例变量的值
return unless build_new_task_from_params
respond_to do |format|
format.html {render :layout => 'base_projects' }
format.xml { }
end
end
# 用户编辑更改issue
def update
return unless build_new_task_from_params
@training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
# params[:training_task][:position] = params[:training_task][:position].to_i
@training_task.position = params[:training_task][:position].to_i
@training_task.subject = params[:training_task][:subject]
@training_task.description = params[:training_task][:description]
if @training_task.save
respond_to do |format|
format.js
format.html{redirect_to training_task_url(@training_task)}
end
end
end
def update_user_issue_detail(issue, params)
case params[:type]
when "status"
issue.update_attribute(:status_id, params[:status_id])
when "assigned"
issue.update_attribute(:assigned_to_id, params[:assigned_to_id])
when "ratio"
issue.update_attribute(:done_ratio, params[:done_ratio])
when "prior"
issue.update_attribute(:priority_id, params[:priority_id])
end
end
# Updates the issue form when changing the project, status or tracker
# on issue creation/update
def update_form
end
def destroy
return unless build_new_task_from_params
@training_task.destroy
respond_to do |format|
if params[:type] == "project_show"
format.html {redirect_to project_path(@project)}
else
format.html {redirect_to project_training_tasks_path(@project)}
end
end
end
def add_journal
if User.current.logged?
jour = Journal.new
jour.user_id = User.current.id
jour.notes = params[:notes]
jour.journalized = @training_task
jour.save_attachments(params[:attachments])
jour.save
update_user_activity(@training_task.class, @training_task.id)
update_forge_activity(@training_task.class, @training_task.id)
# @allowed_statuses = @training_task.new_statuses_allowed_to(User.current)
@user_activity_id = params[:user_activity_id]
@priorities = IssuePriority.active
respond_to do |format|
# Issue详情单独处理
if params[:is_issue_show]
format.js{ redirect_to training_task_path(@training_task) }
else
format.js
end
end
end
end
def add_journal_in_org
if User.current.logged?
jour = Journal.new
jour.user_id = User.current.id
jour.notes = params[:notes]
jour.journalized = @issue
jour.save
org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first
org_activity.updated_at = jour.created_on
org_activity.save
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
end
end
end
#对某个journ回复,显示回复框
def reply
@training_task = TrainingTask.find(params[:id])
@jour = Journal.find(params[:journal_id])
respond_to do |format|
format.js
end
end
#给issue添加journ。回复内容包含 对某个被回复的journ的内容
def add_reply
if User.current.logged?
jour = Journal.find(params[:journal_id])
@training_task = TrainingTask.find params[:id]
@project = @training_task.project
# @allowed_statuses = @training_task.new_statuses_allowed_to(User.current)
@priorities = IssuePriority.active
new_jour = Journal.new
new_jour.user_id = User.current.id
new_jour.reply_id = params[:journal_id]
new_jour.parent_id = jour.id
new_jour.notes = params[:content]
new_jour.journalized = @training_task
new_jour.save_attachments(params[:attachments])
# new_jour = @issue.journals.build(:user_id => User.current.id, :reply_id => params[:journal_id], :notes => params[:content], :parent_id => jour.id)
@user_activity_id = params[:user_activity_id]
if new_jour.save
update_user_activity(@training_task.class, @training_task.id)
update_forge_activity(@training_task.class, @training_task.id)
respond_to do |format|
if params[:is_issue_show]
format.js{ redirect_to training_task_path(@training_task) }
else
format.js
end
end
end
=begin
@journals = @training_task.journals.includes(:user, :details).reorder("#{Journal.table_name}.id desc").all
@journals = get_no_children_comments_all @journals
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @training_task.project)
@journals.reverse! if User.current.wants_comments_in_reverse_order?
@journal = Journal.new(:journalized => @training_task)
respond_to do |format|
#if params[:is_issue_show]
# format.js{ redirect_to training_task_path(@training_task) }
#else
format.js
#end
end
=end
end
end
# 需要刷新详情页面,代码同步一致
# 获取project和issue状态是为了刷新页面
# 值所以用delete是因为issue和journal在act_as_attachment中是同一个类型
# 非动态页面直接刷新,动态页面手动刷新
def delete_journal
@is_project = params[:is_project]
@training_task = TrainingTask.find(params[:id])
begin
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id])
forge_acts.destroy_all unless forge_acts.empty?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id])
at_message.destroy_all unless at_message.empty?
Journal.delete(params[:journal_id])
rescue Exception => e
puts e
end
@user_activity_id = params[:user_activity_id]
respond_to do |format|
if @user_activity_id
format.js
else
format.js{ redirect_to training_task_path(@training_task)}
end
end
end
private
def find_project
project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
@project = Project.find(project_id)
rescue ActiveRecord::RecordNotFound
render_404
end
def find_training_task
end
def allow_members
if !(User.current.member_of?(@project) || User.current.admin?)
render_403
end
end
def allow_manager
if !(User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) )
return render_403
end
end
def retrieve_previous_and_next_issue_ids
retrieve_query_from_session
if @query
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
sort_update(@query.sortable_columns, 'issues_index_sort')
limit = 500
issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
if (idx = issue_ids.index(@issue.id)) && idx < limit
if issue_ids.size < 500
@issue_position = idx + 1
@issue_count = issue_ids.size
end
@prev_issue_id = issue_ids[idx - 1] if idx > 0
@next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
end
end
end
def build_new_task_from_params
if params[:id].blank?
@training_task = TrainingTask.new
@training_task.project = @project
else
@training_task = @project.training_tasks.find(params[:id])
end
@training_task.project = @project
@training_task.author ||= User.current
end
def check_for_default_issue_status
if IssueStatus.default.nil?
render_error l(:error_no_default_issue_status)
return false
end
end
def parse_params_for_bulk_issue_attributes(params)
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
if custom = attributes[:custom_field_values]
custom.reject! {|k,v| v.blank?}
custom.keys.each do |k|
if custom[k].is_a?(Array)
custom[k] << '' if custom[k].delete('__none__')
else
custom[k] = '' if custom[k] == '__none__'
end
end
end
attributes
end
# Find the issue whose id is the :id parameter
# Raises a Unauthorized exception if the issue is not visible
def find_training_task
@training_task = TrainingTask.find(params[:id])
@project = @training_task.project
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -310,6 +310,11 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Issue'
when 'Training_task'
@reply = Journal.find params[:reply_id]
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Training_task'
when 'Syllabus'
@reply = JournalsForMessage.find params[:reply_id]
@type = 'Syllabus'
@ -417,6 +422,11 @@ class UsersController < ApplicationController
comment = @root.journals.build(:user_id => User.current.id, :reply_id => params[:reply_id], :notes => params[:reply_message], :parent_id => reply.id)
comment.save
@is_project = params[:is_project] if params[:is_project]
when 'TrainingTask'
@root = reply.training_task
comment = @root.journals.build(:user_id => User.current.id, :reply_id => params[:reply_id], :notes => params[:reply_message], :parent_id => reply.id)
comment.save
@is_project = params[:is_project] if params[:is_project]
when 'Syllabus'
@root = Syllabus.find reply.jour_id
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => User.current.id,:m_parent_id => params[:reply_id].to_i,:m_reply_id => params[:reply_id].to_i, :root_id => reply.root_id}
@ -907,17 +917,19 @@ class UsersController < ApplicationController
#用户作业列表
def user_homeworks
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@user = User.current
@r_sort = @b_sort == "desc" ? "asc" : "desc"
if(params[:type].blank? || params[:type] == "1") #我的题库
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
# courses = @user.courses.where("is_delete = 1")
# course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
@homeworks = @user.homework_banks.order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #公共题库
visible_course = Course.where("is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
# visible_course = Course.where("is_delete = 0")
# visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
@homeworks = HomeworkBank.where(:is_public => true).order("#{@order} #{@b_sort}")
end
@type = params[:type] ? params[:type] : '1'
@limit = 10
@ -941,7 +953,7 @@ class UsersController < ApplicationController
visibleCourse = @user.courses.empty? ? [] : @user.courses.where("is_delete = 0").visible
homework_ids = []
visibleCourse.each do |course|
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Time.now}'")
homework_ids << homeworks.pluck(:id) unless homeworks.empty?
end
visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
@ -958,7 +970,7 @@ class UsersController < ApplicationController
end
def choose_user_course
homework = HomeworkCommon.find params[:homework].to_i
#homework = HomeworkCommon.find params[:homework].to_i
# if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)
# ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
# if ah.empty?
@ -969,9 +981,9 @@ class UsersController < ApplicationController
# end
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("is_delete = 0 and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
else
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("is_delete = 0").select { |course| @user.allowed_to?(:as_teacher,course)}
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@ -982,7 +994,7 @@ class UsersController < ApplicationController
end
def send_homework_to_course
homework = HomeworkCommon.find params[:send_id].to_i
homework = HomeworkBank.find params[:send_id].to_i
course_ids = params[:course_ids]
course_ids.each do |course_id|
course = Course.find course_id.to_i
@ -991,49 +1003,60 @@ class UsersController < ApplicationController
new_homework.user_id = User.current.id
new_homework.description = homework.description
new_homework.homework_type = homework.homework_type
new_homework.late_penalty = homework.late_penalty
new_homework.late_penalty = 0
new_homework.course_id = course.id
new_homework.teacher_priority = homework.teacher_priority
new_homework.anonymous_comment = homework.anonymous_comment
new_homework.teacher_priority = 1
new_homework.anonymous_comment = 1
new_homework.quotes = 0
new_homework.is_open = homework.is_open
homework.attachments.each do |attachment|
att = attachment.copy
att.container_id = nil
att.container_type = nil
att.copy_from = attachment.id
att.save
new_homework.attachments << att
end
homework_detail_manual = homework.homework_detail_manual
homework_detail_programing = homework.homework_detail_programing
homework_detail_group = homework.homework_detail_group
if homework_detail_manual
new_homework.is_open = 0
# homework.attachments.each do |attachment|
# att = attachment.copy
# att.container_id = nil
# att.container_type = nil
# att.copy_from = attachment.id
# att.save
# new_homework.attachments << att
# end
#homework_detail_manual = homework.homework_detail_manual
#homework_detail_programing = homework.homework_detail_programing
#homework_detail_group = homework.homework_detail_group
#if homework_detail_manual
new_homework.homework_detail_manual = HomeworkDetailManual.new
new_homework_detail_manual = new_homework.homework_detail_manual
new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
new_homework_detail_manual = new_homework.homework_detail_manual
new_homework_detail_manual.ta_proportion = new_homework.homework_type == 2 ? 0.4 : 1.0
new_homework_detail_manual.comment_status = 0
new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
end
if homework_detail_programing
new_homework_detail_manual.evaluation_num = 3
new_homework_detail_manual.absence_penalty = 0
#end
#if homework_detail_programing
if new_homework.homework_type == 2
new_homework.homework_detail_programing = HomeworkDetailPrograming.new
new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
new_homework.homework_detail_programing.language = homework_detail_programing.language
homework.homework_tests.each_with_index do |homework_test|
new_homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
new_homework.homework_detail_programing.ta_proportion = 0.6
new_homework.homework_detail_programing.language = homework.language
homework.homework_bank_tests.each_with_index do |homework_test|
if homework_test.test_type
new_homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
else
new_homework.homework_samples << HomeworkSample.new(
input: homework_test.input,
output: homework_test.output
)
end
end
end
#end
if homework_detail_group
#if homework_detail_group
if new_homework.homework_type == 3
new_homework.homework_detail_group = HomeworkDetailGroup.new
new_homework.homework_detail_group.min_num = homework_detail_group.min_num
new_homework.homework_detail_group.max_num = homework_detail_group.max_num
new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
new_homework.homework_detail_group.min_num = homework.min_num
new_homework.homework_detail_group.max_num = homework.max_num
new_homework.homework_detail_group.base_on_project = homework.base_on_project
end
#end
if new_homework.save
new_homework_detail_manual.save if new_homework_detail_manual
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
@ -1052,9 +1075,9 @@ class UsersController < ApplicationController
@user = User.current
@select_course = params[:select_course] ? 1 : 0
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
#courses = @user.courses.where("is_delete = 1")
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = @user.homework_banks.order("#{@order} #{@b_sort}")
@type = params[:type]
@limit = 15
@is_remote = true
@ -1068,17 +1091,17 @@ class UsersController < ApplicationController
end
def user_homework_type
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
if(params[:type].blank? || params[:type] == "1") #我的题库
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
#courses = @user.courses.where("is_delete = 1")
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = @user.homework_banks
elsif params[:type] == "2" #公共题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
#visible_course = Course.where("is_public = 1 && is_delete = 0")
#visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkBank.where(:is_public => true)
# elsif params[:type] == "3" #申请题库
# none_visible_course = Course.where("is_delete = 1")
# none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
@ -1090,18 +1113,20 @@ class UsersController < ApplicationController
# @homeworks = HomeworkCommon.find_by_sql(sql)
end
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
if params[:property] == "1"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
#@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
elsif params[:property] == "2"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
#@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
elsif params[:property] == "3"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
#@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
end
@homeworks = @homeworks.where(:homework_type => params[:property].to_i)
# all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
# if params[:property] == "1"
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
# #@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
# elsif params[:property] == "2"
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
# #@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
# elsif params[:property] == "3"
# @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
# #@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
# end
end
@homeworks = @homeworks.reorder("#{@order} #{@b_sort}")
@type = params[:type] ? params[:type] : '1'
@property = params[:property]
@is_import = params[:is_import]
@ -1117,7 +1142,7 @@ class UsersController < ApplicationController
end
def show_homework_detail
@homework = HomeworkCommon.find params[:homework].to_i
@homework = HomeworkBank.find params[:homework].to_i
# if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) && User.current != homework.user
# ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework].to_i)
# if ah.empty?
@ -1140,44 +1165,46 @@ class UsersController < ApplicationController
#用户主页过滤作业
def user_search_homeworks
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
search = params[:name].to_s.strip.downcase
type_ids = (params[:property]=="" || params[:property].nil? || params[:property]=="0") ? "(1, 2, 3)" : "(" + params[:property] + ")"
if(params[:type].blank? || params[:type] == "1") #我的题库
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
end
#courses = @user.courses.where("is_delete = 1")
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = @user.homework_banks.where("name like '%#{search}%' and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
# if @order == "course_name"
# sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
# @homeworks = HomeworkCommon.find_by_sql(sql)
# elsif @order == "user_name"
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
# else
# @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
# end
elsif params[:type] == "2" #题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
#visible_course = Course.where("is_public = 1 && is_delete = 0")
#visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
all_homeworks = HomeworkBank.where(:is_public => true)
all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
end
@homeworks = HomeworkBank.where("is_public = 1 and (name like '%#{search}%' or user_id in #{user_ids}) and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
# if @order == "course_name"
# sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
# @homeworks = HomeworkCommon.find_by_sql(sql)
# elsif @order == "user_name"
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
# else
# @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
# end
elsif params[:type] == "3" #申请题库
apply_homeworks = ApplyHomework.where("user_id = ?",@user.id)
homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
none_visible_course = Course.where("is_delete = 1")
none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Time.now}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("homework_commons.id in #{homework_ids} and course_id not in #{none_visible_course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
@ -1211,11 +1238,16 @@ class UsersController < ApplicationController
#检查改作业是否可以选用
def check_homework
homework = HomeworkCommon.find_by_id params[:homework]
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
resultObj = {status: 2}
if student_ids.include?(User.current.id.to_s)
resultObj[:status] = 1
homework_bank = HomeworkBank.find params[:homework]
if homework_bank.homework_common_id && HomeworkCommon.find(homework_bank.homework_common_id)
homework = HomeworkCommon.find(homework_bank.homework_common_id)
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
if student_ids.include?(User.current.id.to_s)
resultObj[:status] = 1
else
resultObj[:status] = 0
end
else
resultObj[:status] = 0
end
@ -1224,47 +1256,58 @@ class UsersController < ApplicationController
#导入作业,确定按钮
def user_select_homework
homework = HomeworkCommon.find_by_id params[:checkMenu]
homework_detail_programing = homework.homework_detail_programing
homework_detail_group = homework.homework_detail_group
homework = HomeworkBank.find_by_id params[:checkMenu]
#homework_detail_programing = homework.homework_detail_programing
#homework_detail_group = homework.homework_detail_group
@homework = HomeworkCommon.new
@select_course = params[:select_course] || 0
if homework
@ref_homework = homework
@homework.name = homework.name
@homework.description = homework.description
@homework.end_time = homework.end_time
#@homework.end_time = homework.end_time
@homework.homework_type = homework.homework_type
@homework.course_id = homework.course_id
homework.attachments.each do |attachment|
att = attachment.copy
att.container_id = nil
att.container_type = nil
att.copy_from = attachment.id
att.save
@homework.attachments << att
end
#@homework.course_id = homework.course_id
# homework.attachments.each do |attachment|
# att = attachment.copy
# att.container_id = nil
# att.container_type = nil
# att.copy_from = attachment.id
# att.save
# @homework.attachments << att
# end
if homework_detail_programing
#if homework_detail_programing
if homework.homework_type == 2
@homework.homework_detail_programing = HomeworkDetailPrograming.new
@homework_detail_programing = @homework.homework_detail_programing
@homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
@homework_detail_programing.language = homework_detail_programing.language
homework.homework_tests.each_with_index do |homework_test|
@homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
#@homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
@homework_detail_programing.language = homework.language
homework.homework_bank_tests.each_with_index do |homework_test|
if homework_test.test_type
@homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
else
@homework.homework_samples << HomeworkSample.new(
input: homework_test.input,
output: homework_test.output
)
end
end
end
#end
if homework_detail_group
#if homework_detail_group
if homework.homework_type == 3
@homework.homework_detail_group = HomeworkDetailGroup.new
@homework_detail_group = @homework.homework_detail_group
@homework_detail_group.min_num = homework_detail_group.min_num
@homework_detail_group.max_num = homework_detail_group.max_num
@homework_detail_group.base_on_project = homework_detail_group.base_on_project
@homework_detail_group.min_num = homework.min_num
@homework_detail_group.max_num = homework.max_num
@homework_detail_group.base_on_project = homework.base_on_project
end
#end
end
respond_to do |format|
format.js
@ -1310,7 +1353,7 @@ class UsersController < ApplicationController
if student_work
# 提交作品时,计算是否迟交
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
if homework.end_time < Time.now
student_work.late_penalty = homework.late_penalty
student_work.work_status = 2
# 缺评扣分
@ -1347,12 +1390,12 @@ class UsersController < ApplicationController
homework = HomeworkCommon.new
homework.name = params[:homework_common][:name]
homework.description = params[:homework_common][:description]
homework.end_time = params[:homework_common][:end_time] || Date.today
if params[:homework_common][:publish_time] == ""
homework.publish_time = Date.today
else
homework.publish_time = params[:homework_common][:publish_time]
end
# homework.end_time = params[:homework_common][:end_time] || Time.now
# if params[:homework_common][:publish_time] == ""
# homework.publish_time = Time.now
# else
# homework.publish_time = params[:homework_common][:publish_time]
# end
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 = 0
@ -1369,19 +1412,31 @@ class UsersController < ApplicationController
else
homework_detail_manual.ta_proportion = homework.homework_type == 2 ? 0.3 : 0.6
end
if homework.publish_time > Date.today
if params[:homework_common][:end_time] == ""
homework_detail_manual.comment_status = 0
else
homework_detail_manual.comment_status = 1
homework.end_time = params[:homework_common][:end_time]
if params[:homework_common][:publish_time] == ""
homework.publish_time = Time.now
else
homework.publish_time = params[:homework_common][:publish_time]
end
#更新CourseHomeworkStatistics中每个学生的未交作品数
homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
if homework.publish_time > Time.now
homework_detail_manual.comment_status = 0
else
homework_detail_manual.comment_status = 1
#更新CourseHomeworkStatistics中每个学生的未交作品数
homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
end
end
end
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start]
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
homework_detail_manual.evaluation_start = homework.end_time + 7 if homework.end_time
homework_detail_manual.evaluation_end = homework.end_time + 14 if homework.end_time
homework_detail_manual.evaluation_num = params[:evaluation_num] || 3
homework_detail_manual.absence_penalty = 0
homework.homework_detail_manual = homework_detail_manual
@ -1397,6 +1452,16 @@ class UsersController < ApplicationController
end
homework_detail_programing.language = params[:language_type].to_i
sample_inputs = params[:sample][:input]
if Array === sample_inputs
sample_inputs.each_with_index do |val, i|
homework.homework_samples << HomeworkSample.new(
input: val,
output: params[:sample][:output][i]
)
end
end
inputs = params[:program][:input]
if Array === inputs
inputs.each_with_index do |val, i|
@ -1427,10 +1492,15 @@ class UsersController < ApplicationController
end
if params[:quotes] && !params[:quotes].blank?
quotes_homework = HomeworkCommon.find params[:quotes].to_i
quotes_homework = HomeworkBank.find params[:quotes].to_i
quotes_homework.update_column(:quotes, quotes_homework.quotes+1)
end
if params[:add_to_bank]
homework_bank = add_to_homework_bank_f homework
homework_bank.save
homework.update_attributes(:homework_bank_id => homework_bank.id)
end
redirect_to homework_common_index_path(:course => homework.course_id)
end
end
@ -1844,7 +1914,7 @@ class UsersController < ApplicationController
@manage_homeworks = HomeworkCommon.where("course_id in #{tea_course_ids}").order("created_at desc").limit(5)
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc").limit(5)
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("created_at desc").limit(5)
if (@manage_homeworks.empty? && @receive_homeworks.empty?) || (@receive_homeworks.empty?) || (!@manage_homeworks.empty? && !@receive_homeworks.empty? && @manage_homeworks.first.created_at > @receive_homeworks.first.created_at)
@manage_pre = true
else
@ -1897,7 +1967,7 @@ class UsersController < ApplicationController
@type = @type.to_i
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("#{@order} #{@b_sort}")
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
if params[:property] == "1"
@ -1934,7 +2004,7 @@ class UsersController < ApplicationController
else
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").order("#{@order} #{@b_sort}")
end
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
@ -1975,7 +2045,7 @@ class UsersController < ApplicationController
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
#user_ids = hw_publisher_user_ids search, stu_course_ids
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and name like '%#{search}%'")
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and homework_type in #{type_ids} and publish_time <= '#{Time.now}' and name like '%#{search}%'")
if @order == "status"
@homeworks.each do |homework|
work = cur_user_works_for_homework homework
@ -2033,7 +2103,7 @@ class UsersController < ApplicationController
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).
where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
# 用户待完成的作业
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
@unfinished_homework_count = homeworks.count - student_works.count
@ -2175,11 +2245,11 @@ class UsersController < ApplicationController
# 待完成的作业
def unfinished_homework_list
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
finished_works_id = student_works.blank? ? "(-1)" : "(" + student_works.map{ |sw| sw.homework_common_id.to_i }.join(",") + ")"
@unfinished_homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}' and id not in #{finished_works_id}").order("updated_at desc")
@unfinished_homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}' and id not in #{finished_works_id}").order("updated_at desc")
@unfinished_homeworks_count = @unfinished_homeworks.count
@limit = 20
@unfinished_homework_pages = Paginator.new @unfinished_homeworks_count, @limit, params['page'] || 1
@ -4130,7 +4200,7 @@ class UsersController < ApplicationController
count = 0
courses = syllabus.courses.not_deleted
courses.each do |c|
count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count)
count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Time.now}'").count + visable_attachemnts_incourse(c).count)
end
syllabus[:infocount] = count
end
@ -4343,6 +4413,11 @@ class UsersController < ApplicationController
@journals = @activity.journals.reorder("created_on desc")
@user_activity_id = params[:div_id].to_i if params[:div_id]
@user_activity = ForgeActivity.where(params[:div_id].to_i).first if params[:div_id]
when 'is_project_training_task'
@activity = TrainingTask.where('id = ?', params[:id].to_i).first
@journals = @activity.journals.reorder("created_on desc")
@user_activity_id = params[:div_id].to_i if params[:div_id]
@user_activity = ForgeActivity.where(params[:div_id].to_i).first if params[:div_id]
when 'BlogComment'
obj = BlogComment.where('id = ?', params[:id].to_i).first
@user_activity_id = params[:div_id].to_i if params[:div_id]

View File

@ -126,7 +126,7 @@ class WordsController < ApplicationController
if params[:user_activity_id] == params[:activity_id]
redirect_to feedback_contest_path(@contest)
else
redirect_to contest_activities_contest_path(@contest)
redirect_to contest_path(@contest)
end
return
end

View File

@ -16,7 +16,7 @@ class WorksController < ApplicationController
if @is_teacher
@homework_commons = @contest.works.where("name like '%#{search}%'").order("created_at desc")
else
@homework_commons = @contest.works.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
@homework_commons = @contest.works.where("name like '%#{search}%' and work_status > 0").order("created_at desc")
end
@is_new = params[:is_new]
@ -108,10 +108,16 @@ class WorksController < ApplicationController
else
@contestwork.publish_time = params[:homework_common][:publish_time]
end
if @contestwork.publish_time > Date.today
@contestwork.work_status = 0
elsif @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
@contestwork.work_status = 1
end
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
homework_end_time = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d")
work_detail_manual = @contestwork.work_detail_manual
if homework_end_time != param_end_time
@contestwork.end_time = params[:homework_common][:end_time]
eval_start = Time.parse(work_detail_manual.evaluation_start.to_s).strftime("%Y-%m-%d")
if eval_start.nil? || (eval_start <= param_end_time && @contestwork.work_status <= 2)
work_detail_manual.evaluation_start = @contestwork.end_time + 7
@ -133,8 +139,13 @@ class WorksController < ApplicationController
end
end
end
if @contestwork.end_time < Date.today && @contestwork.work_status == 1
@contestwork.work_status = 2
elsif @contestwork.end_time >= Date.today && @contestwork.work_status == 2
@contestwork.work_status = 1
#status = true
end
end
@contestwork.end_time = params[:homework_common][:end_time] || Time.now
if params[:homework_type] && params[:homework_type].to_i != @contestwork.work_type
if @contestwork.work_type == 3
@contestwork.work_detail_group.destroy if @contestwork.work_detail_group
@ -142,14 +153,6 @@ class WorksController < ApplicationController
end
@contestwork.work_type = params[:homework_type].to_i || @contestwork.work_type
#status = false
if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
@contestwork.work_status = 1
elsif @contestwork.end_time < Date.today && @contestwork.work_status == 1
@contestwork.work_status = 2
#status = true
end
@contestwork.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@contestwork)

View File

@ -102,7 +102,7 @@ module ApiHelper
#获取作业的是否可以匿评的描述
def homework_status_desc homework
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if homework.end_time >= Time.now
link = show_homework_deadline homework
elsif homework.student_works.count >= 2 #作业份数大于2
case homework.homework_detail_manual.comment_status

View File

@ -1036,6 +1036,32 @@ module ApplicationHelper
return @result
end
# 更新各类消息为已读
def update_messsages_to_viewed(message_type, forge_message_id)
if(message_type == "CourseMessage")
query = CourseMessage.where(:course_message_type => ["JoinCourse", "RemoveFromCourse"],
:user_id => User.current,
:course_id => forge_message_id,
:viewed => false)
elsif(message_type == "ForgeMessage")
query = ForgeMessage.where(:forge_message_type => ["ProjectInvite", "JoinProject", "RemoveFromProject"],
:user_id => User.current,
:project_id => forge_message_id,
:viewed => false)
elsif(message_type == "ContestMessage")
query = ContestMessage.where(:contest_message_type => ["ContestRequestDealResult", "JoinContest", "RemoveFromContest"],
:user_id => User.current,
:contest_id => forge_message_id,
:viewed => false)
elsif(message_type == "BlogMessage")
query = BlogMessage.where(:blog_message_type => "BlogComment",
:user_id => User.current,
:blog_id => forge_message_id,
:viewed => false)
end
query.update_all(:viewed => true) unless query.blank?
end
def show_attachment_tip container_id, container_type
atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0)
atts.count > 0 ? true :false
@ -2964,7 +2990,7 @@ module ApplicationHelper
def user_receive_homework_count
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").count
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Time.now}'").count
end
# 用户发布的issue数
@ -3044,7 +3070,7 @@ module ApplicationHelper
#获取匿评相关连接代码
def homework_anonymous_comment (homework, hw_status, user_activity_id = -1)
if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if homework.homework_detail_manual.comment_status == 0 || homework.end_time >= Time.now
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status
@ -3103,13 +3129,13 @@ module ApplicationHelper
else #学生显示提交作品、修改作品等按钮
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if work.nil? && homework.end_time >= Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品'
else
link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
end
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
else
@ -3129,9 +3155,9 @@ module ApplicationHelper
end
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束"
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品(#{count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue'
else
link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品"
@ -3178,13 +3204,13 @@ module ApplicationHelper
else User.current.member_of_course?(homework.course)
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if work.nil? && homework.end_time >= Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
end
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
@ -3195,9 +3221,9 @@ module ApplicationHelper
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
else
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
@ -3276,7 +3302,7 @@ module ApplicationHelper
#获取当前作业的提交截止时间/互评截止时间
def cur_homework_end_time homework
str = ""
if homework.anonymous_comment == 0 && homework.end_time && homework.end_time < Date.today && homework.homework_detail_manual
if homework.anonymous_comment == 0 && homework.end_time && homework.end_time < Time.now && homework.homework_detail_manual
str = "互评截止:#{format_date homework.homework_detail_manual.evaluation_end}"
else
str = "提交截止:#{homework.end_time ? (format_date homework.end_time) : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}"
@ -3671,7 +3697,7 @@ def get_reply_by_type type, reply_id
reply = OrgDocumentComment.find reply_id
when 'News','Comment'
reply = Comment.find reply_id
when 'Issue'
when 'Issue', 'TrainingTask'
reply = Journal.find reply_id
when 'Journal'
reply = Journal.find reply_id
@ -3949,7 +3975,7 @@ def get_hw_index(hw,is_teacher)
if is_teacher
homeworks = hw.course.homework_commons.order("created_at asc")
else
homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
homeworks = hw.course.homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc")
end
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty?
index = hw_ids.index(hw.id)
@ -3969,9 +3995,9 @@ def get_hw_status homework_common
else
str += '<span class="grey_homework_btn_cir ml5">匿评已禁用</span>'
end
if Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if homework_common.end_time >= Time.now
str += '<span class="green_homework_btn_cir ml5">作品提交中</span>'
elsif Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && homework_common.anonymous_comment == 1 && User.current.allowed_to?(:as_teacher, homework_common.course)
elsif homework_common.end_time < Time.now && homework_common.anonymous_comment == 1 && User.current.allowed_to?(:as_teacher, homework_common.course)
str += '<span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span>'
else
str += '<span class="red_homework_btn_cir ml5">作品补交中</span>'
@ -4091,6 +4117,33 @@ def create_works_list homework
end
end
def add_to_homework_bank_f homework
homework_bank = HomeworkBank.new(:name => homework.name, :description => homework.description, :user_id => homework.user_id, :homework_type => homework.homework_type,
:quotes => 1, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id)
if homework.homework_type == 2 && homework.homework_detail_programing
homework_bank.language = homework.homework_detail_programing.language
homework.homework_tests.each_with_index do |homework_test|
homework_bank.homework_bank_tests << HomeworkBankTest.new(
test_type: 1,
input: homework_test.input,
output: homework_test.output
)
end
homework.homework_samples.each_with_index do |homework_test|
homework_bank.homework_bank_tests << HomeworkBankTest.new(
test_type: 0,
input: homework_test.input,
output: homework_test.output
)
end
elsif homework.homework_type == 3 && homework.homework_detail_group
homework_bank.min_num = homework.homework_detail_group.min_num
homework_bank.max_num = homework.homework_detail_group.max_num
homework_bank.base_on_project = homework.homework_detail_group.base_on_project
end
homework_bank
end
# 获取项目动态更新时间
def get_forge_act_message(act, type)
forge_act = ForgeActivity.where(:forge_act_id => act.id, :forge_act_type => type).first
@ -4146,7 +4199,7 @@ def visable_contest_work contest
if User.current.admin? || User.current.admin_of_contest?(contest)
work_num = contest.works.count
else
work_num = contest.works.where("publish_time <= '#{Date.today}'").count
work_num = contest.works.where("work_status > 0").count
end
work_num
end

View File

@ -257,6 +257,14 @@ module CoursesHelper
count.to_s << '+'
end
def searchTeacherAndAssistantNoManager course
members = []
course.members.includes(:user).each do |m|
members << m if m && m.user && m.user != course.teacher && m.user.has_teacher_role(course)
end
members
end
# =====================================================================================
# return people list
def searchTeacherAndAssistant project
@ -816,7 +824,7 @@ module CoursesHelper
if User.current.admin? || User.current.allowed_to?(:as_teacher,course)
homework_num = course.homework_commons.count
else
homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count
homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count
end
homework_num
end
@ -928,5 +936,11 @@ module CoursesHelper
result = !m_roles.blank?
result
end
#获取该班级下已关联项目的分组作业
def select_group_homeworks course
student_work_pros = course.student_work_projects.where("project_id != -1 && project_id != 0")
homeworks = @course.homework_commons.where(:id => student_work_pros.map(&:homework_common_id))
end
end

View File

@ -544,6 +544,8 @@ module ProjectsHelper
result = "manage_versions"
elsif user.allowed_to?(:manage_repository, @project)
result = "manage_repository"
elsif @project.is_training_project?
result = "training_task"
end
result
end

View File

@ -161,7 +161,7 @@ module StudentWorkHelper
def revise_attachment_status homework, attach
date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d")
status = ""
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time.to_s < date))
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < attach.created_on))
status = "此时其他同学作品已公开"
else
status = "此时其他同学作品尚未公开"

View File

@ -0,0 +1,44 @@
module TrainingTasksHelper
include ApplicationHelper
include TagsHelper
require 'iconv'
# Returns the textual representation of a journal details
# as an array of strings
def details_to_strings(details, no_html=false, options={})
options[:only_path] = (options[:only_path] == false ? false : true)
options[:token] = options[:token] if options[:token]
strings = []
values_by_field = {}
details.each do |detail|
if detail.property == 'cf'
field_id = detail.prop_key
field = CustomField.find_by_id(field_id)
if field && field.multiple?
values_by_field[field_id] ||= {:added => [], :deleted => []}
if detail.old_value
values_by_field[field_id][:deleted] << detail.old_value
end
if detail.value
values_by_field[field_id][:added] << detail.value
end
next
end
end
strings << show_detail(detail, no_html, options)
end
values_by_field.each do |field_id, changes|
detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
if changes[:added].any?
detail.value = changes[:added]
strings << show_detail(detail, no_html, options)
elsif changes[:deleted].any?
detail.old_value = changes[:deleted]
strings << show_detail(detail, no_html, options)
end
end
strings
end
end

View File

@ -0,0 +1,9 @@
class HomeworkBank < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :user
has_many :homework_bank_tests
def language_name
%W(C C++ Python Java).at(self.language.to_i - 1)
end
end

View File

@ -0,0 +1,4 @@
class HomeworkBankTest < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :homework_bank
end

View File

@ -15,6 +15,7 @@ class HomeworkCommon < ActiveRecord::Base
has_one :homework_detail_group, :dependent => :destroy
has_many :student_work_projects, :dependent => :destroy
has_many :homework_tests, :dependent => :destroy
has_many :homework_samples, :dependent => :destroy
has_many :student_works, :dependent => :destroy, :conditions => "is_test=0 and is_delete != 1"
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
@ -35,6 +36,17 @@ class HomeworkCommon < ActiveRecord::Base
after_update :update_activity
after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets
before_destroy :update_homework_bank_quotes
#删除时更新题库中的引用数
def update_homework_bank_quotes
old_banks = HomeworkBank.where(:homework_common_id => self.id)
unless old_banks.blank?
old_banks.each do |bank|
bank.update_attributes(:quotes => (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, :homework_common_id => nil)
end
end
end
#作业类型
def homework_type_ch

View File

@ -0,0 +1,4 @@
class HomeworkSample < ActiveRecord::Base
belongs_to :homework_common
attr_accessible :input, :output, :homework_common_id
end

View File

@ -23,7 +23,8 @@ class Journal < ActiveRecord::Base
belongs_to :journalized, :polymorphic => true,:touch => true
# added as a quick fix to allow eager loading of the polymorphic association
# since always associated to an issue, for now
belongs_to :issue, :foreign_key => :journalized_id,:touch => true
belongs_to :issue, :foreign_key => :journalized_id, :touch => true
belongs_to :training_task, :foreign_key => :journalized_id, :touch => true
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
@ -192,27 +193,44 @@ class Journal < ActiveRecord::Base
def act_as_forge_message
receivers = []
# 直接回复
if self.user_id != self.issue.author_id
receivers << self.issue.author_id
end
if self.user_id != self.issue.assigned_to_id && self.issue.assigned_to_id != self.issue.author_id # 指派人不是自己的话,则给指派人发送
receivers << self.issue.assigned_to_id
end
receivers.each do |r|
self.forge_messages << ForgeMessage.new(:user_id => r, :project_id => self.issue.project_id, :viewed => false)
if self.journalized_type == 'Issue'
if self.user_id != self.issue.author_id
receivers << self.issue.author_id
end
if self.user_id != self.issue.assigned_to_id && self.issue.assigned_to_id != self.issue.author_id # 指派人不是自己的话,则给指派人发送
receivers << self.issue.assigned_to_id
end
receivers.each do |r|
self.forge_messages << ForgeMessage.new(:user_id => r, :project_id => self.issue.project_id, :viewed => false)
end
elsif self.journalized_type == 'TrainingTask'
if self.user_id != self.training_task.author_id
receivers << self.training_task.author_id
end
receivers.each do |r|
self.forge_messages << ForgeMessage.new(:user_id => r, :project_id => self.training_task.project, :viewed => false)
end
end
end
# 更新用户分数 -by zjc
def be_user_score
if (self.journalized_type == 'Issue')
#新建了缺陷留言且留言不为空,不为空白
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
end
elsif( self.journalized_type == 'TrainingTask')
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分
UserScore.joint(:post_issue_message, self.user, self.training_task.author, self, { message_id: self.id })
update_messges_for_issue(self.user, 1)
update_messges_for_issue(self.user, 2, self.training_task.project)
end
end
end
# 减少用户分数 -by zjc
def down_user_score
@ -237,12 +255,18 @@ class Journal < ActiveRecord::Base
# issue留言总数更新
def add_journals_count
if !self.issue.project.nil? && self.journalized_type == "Issue" && !self.issue.project.project_score.nil?
project = self.issue.project
project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num + 1)
if self.journalized_type == 'Issue'
if !self.issue.project.nil? && self.journalized_type == "Issue" && !self.issue.project.project_score.nil?
project = self.issue.project
project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num + 1)
end
elsif self.journalized_type == 'TrainingTask'
if !self.training_task.project.nil? && self.journalized_type == "TrainingTask" && !self.training_task.project.project_score.nil?
project = self.training_task.project
project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num + 1)
end
end
end
# 回复issue的时候更新issue的时候
def update_issue_time
if self.journalized_type == "Issue"

View File

@ -159,7 +159,7 @@ class Member < ActiveRecord::Base
#当前课程的作业列表
def homework_common_list
HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Date.today}'", self.course_id)
HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Time.now}'", self.course_id)
end
#当前学生在指定作业内的得分

View File

@ -103,6 +103,19 @@ class News < ActiveRecord::Base
user.allowed_to?(:comment_news, project)
end
def news_object
object = self.project
if object == nil && self.has_attribute?('course_id')
object = self.course
if object.nil? && self.has_attribute?('contest_id')
object = self.contest
elsif object.nil? && self.has_attribute?('org_subfield_id')
object = self.org_subfield
end
end
object
end
def recipients
project.users.select {|user| user.notify_about?(self)}.map(&:mail)
end

View File

@ -1,98 +1,100 @@
class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
#after_create :be_user_score
#after_destroy :down_user_score
include UserScoreHelper
def self.find_object_by_type_and_id(type,id)
@obj = nil
case type
when 'User'
@obj = User.find_by_id(id)
when 'Issue'
@obj = Issue.find_by_id(id)
when 'Project'
@obj = Project.find_by_id(id)
when 'Bid'
@obj = Bid.find_by_id(id)
when 'Contest'
@obj = Contest.find_by_id(id)
when 'Memo'
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
end
return @obj
end
# 获取裁定对象为Message时Message所属的项目或课程
def project
project = nil
if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues'
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
project = obj.project
end
project
end
#更新用户分数 - by zjc
def be_user_score
#踩贴吧或讨论区帖子
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
end
def down_user_score
#踩贴吧或讨论区帖子
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
end
def self.praised(activity)
self.where(praise_tread_object_id: activity.id,
praise_tread_object_type: activity.class.to_s,
user_id: User.current.id).empty?
end
end
class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
#after_create :be_user_score
#after_destroy :down_user_score
include UserScoreHelper
def self.find_object_by_type_and_id(type,id)
@obj = nil
case type
when 'User'
@obj = User.find_by_id(id)
when 'Issue'
@obj = Issue.find_by_id(id)
when 'TrainingTask'
@obj = TrainingTask.find_by_id(id)
when 'Project'
@obj = Project.find_by_id(id)
when 'Bid'
@obj = Bid.find_by_id(id)
when 'Contest'
@obj = Contest.find_by_id(id)
when 'Memo'
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
end
return @obj
end
# 获取裁定对象为Message时Message所属的项目或课程
def project
project = nil
if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues'
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
project = obj.project
end
project
end
#更新用户分数 - by zjc
def be_user_score
#踩贴吧或讨论区帖子
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
end
def down_user_score
#踩贴吧或讨论区帖子
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
end
def self.praised(activity)
self.where(praise_tread_object_id: activity.id,
praise_tread_object_type: activity.class.to_s,
user_id: User.current.id).empty?
end
end

View File

@ -57,6 +57,7 @@ class Project < ActiveRecord::Base
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "issues.id ASC"
has_many :training_tasks, :dependent => :destroy, :order => "training_tasks.id ASC"
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
has_many :time_entries, :dependent => :delete_all
@ -159,6 +160,7 @@ class Project < ActiveRecord::Base
after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index
before_destroy :delete_all_members,:delete_project_ealasticsearch_index
after_update :update_project_ealasticsearch_index
def remove_references_before_destroy
return if self.id.nil?
Watcher.delete_all ['watchable_id = ?', id]
@ -193,6 +195,7 @@ class Project < ActiveRecord::Base
scope :project_entities, -> { where(project_type: ProjectType_project) }
scope :course_entities, -> { where(project_type: ProjectType_course) }
scope :indexable,lambda { where('is_public = 1')} #用于elastic建索引的scope
def self.search(query)
__elasticsearch__.search(
{
@ -219,6 +222,17 @@ class Project < ActiveRecord::Base
}
)
end
# 判断项目是否为实训项目
def is_training_project?
(!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false
end
# 判断项目是否为开启实训的项目eg学生开启实训
def is_child_training_project?
self.training_status == 2 ? true :false
end
def new_course
self.where('project_type = ?', 1)
end

View File

@ -190,7 +190,7 @@ class StudentWork < ActiveRecord::Base
# status == 0 : delay
def act_as_message
if self.work_status != 0 && self.created_at > self.homework_common.end_time + 1
if self.work_status != 0 && self.created_at > self.homework_common.end_time
self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false)
end
end

View File

@ -31,7 +31,7 @@ class StudentsForCourse < ActiveRecord::Base
#加入班级时创建已发布作业的作品
def create_student_works
course = self.course
course.homework_commons.each do |hw|
course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").each do |hw|
if hw.homework_type != 3 && hw.student_works.where("user_id = #{self.student_id}").count == 0
hw.student_works << StudentWork.new(:user_id => self.student_id, :name => hw.name.to_s+"的作品提交", :work_status => 0)
end

View File

@ -0,0 +1,28 @@
class TrainingTask < ActiveRecord::Base
attr_accessible :description, :project_id, :subject, :tracker_id
belongs_to :project,:touch=> true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
belongs_to :tracker
has_many :journals, :as => :journalized, :dependent => :destroy
has_many :visible_journals,
:class_name => 'Journal',
:as => :journalized,
:conditions => Proc.new {
["(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(User.current, :view_private_notes)}))", false]
},
:readonly => true
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_one :praise_tread_cache, as: :object, dependent: :destroy
has_many :forge_acts, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy
acts_as_attachable
validates_presence_of :subject, :author
validates_length_of :subject, :maximum => 255
after_create :act_as_forge_activity
def act_as_forge_activity
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.project_id)
end
end

View File

@ -114,6 +114,8 @@ class User < Principal
has_many :apply_homeworks, :dependent => :destroy
has_many :apply_resources, :dependent => :destroy
#end
#题库
has_many :homework_banks, :dependent => :destroy
#竞赛
has_many :contests, :dependent => :destroy
has_many :works, :dependent => :destroy
@ -1237,6 +1239,16 @@ class User < Principal
Thread.current[:current_user] ||= User.anonymous
end
def user_real_extension
ue = self.user_extensions
if ue.nil?
ue = UserExtensions.new
ue.user_id = self.id
ue.save
end
ue
end
# Returns the anonymous user. If the anonymous user does not exist, it is created. There can be only
# one anonymous user per database.
def self.anonymous

View File

@ -8,7 +8,7 @@ class CommentService
if @course.nil?
raise 'news in unknown course'
end
raise Unauthorized unless @news.commentable?(current_user)
#raise Unauthorized unless @news.commentable?(current_user)
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
raise '403'
end

View File

@ -702,7 +702,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.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC')
bids = course.homework_commons.where("publish_time <= ?",Time.now).page(params[:page] || 1).per(20).reorder('created_at DESC')
bids = bids.like(params[:name]) if params[:name].present?
homeworks = []
bids.each do |bid|

View File

@ -105,7 +105,7 @@ class HomeworkService
def start_anonymous_comment params,current_user
homework = HomeworkCommon.find(params[:homework_id])
return {:status=> 4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
return {:status=>5} if homework.end_time >= Time.now
homework_detail_manual = homework.homework_detail_manual
if homework_detail_manual.comment_status == 1
student_works = homework.student_works

View File

@ -193,7 +193,7 @@ class ResourcesService
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now).order("created_at desc")
# homeworks.each do |v|
# course = Course.where("id=?",v.course_id).first

View File

@ -0,0 +1,72 @@
<div id="muban_popup_box" style="width:400px;">
<div class="muban_popup_top">
<h3 class="fl">更换邮箱</h3>
<a href="javascript:void(0);" class="muban_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="sy_popup_con" style="width:380px;">
<ul class="sy_popup_add" >
<li class="center mb5" style="line-height:20px;text-align: center;">
<li style="margin-left: 40px">
<span class="c_red f12"></span>&nbsp;原邮箱&nbsp;&nbsp;:&nbsp;
<span style="width: 200px"><%= user.mail %></span>
</li>
<div class="c1"></div>
<li style="margin-left: 40px">
<span class="c_red f12"></span>&nbsp;新邮箱&nbsp;&nbsp;:&nbsp;
<input type="text" style="width:200px" id="user_mail" name="user[mail]" placeholder="请输入邮箱地址">
<p class="new_login_error fl" id="mail_req" style="display: none;margin-left: 68px;">请输入正确的邮箱</p>
</li>
</li>
<div class="clear"></div>
<li class="mt10">
<label class="mr27">&nbsp;</label>
<a href="javascript:void(0);" class="sy_btn_grey fl" onclick="hideModal()">取&nbsp;&nbsp;消</a>
<a href="javascript:void(0);" class="sy_btn_blue fl ml20" onclick="submit_user_emails()">确&nbsp;&nbsp;定</a>
<div class="cl"></div>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
var $mail_correct = false;
var $mail = $('#user_mail');
$mail.blur(function (event) {
if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){
$('#mail_req').html( '<span style="color: #c00202">邮件格式不对</span>').show();
$mail_correct = false;
return ;
}
if ($(this).is('#user_mail')) {
$.get('<%= account_valid_ajax_path %>',
{ valid: "mail",
value: this.value },
function (data) {
if (data.valid) {
$('#mail_req').html( '<span style="color: green">'+data.message+'</span>' );
$mail_correct = true;
} else {
$('#mail_req').html( '<span style="color: #c00202">'+data.message+'</span>' );
$mail_correct = false;
}
$('#mail_req').css('display','block');
});
}
});
function submit_user_emails(){
if($mail_correct == false){
return
}else{
$.get('<%= account_change_email_path(:user_id => @user.id) %>',
{ valid: "mail",
value: document.getElementById("user_mail").value },
function (data){
$("#user_email_show").html(data.email);
hideModal();
return;
});
}
}
</script>

View File

@ -1,22 +1,31 @@
<div class="new_content">
<div class="email_verify">
<p class="email_verify_prompt"><span class="icons_email_prompt"></span>您的账号尚未激活,请先进入您的注册邮箱,激活您的账号。</p>
<p class="email_verify_prompt"><span class="icons_email_prompt"></span>您的账号尚未激活,请先进入您的注册邮箱<span class="c_red" id="user_email_show"><%= @user.mail %></span>,激活您的账号。</p>
<button class="email_verify_btn mt30 ml30" onclick = "resendMail('<%= resendmail_path(@user) %>','<%= @user.id %>');">重新发送激活邮件</button>
<%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %>
<ul class="email_prompt_txt ml30 mt30">
<ul class="email_prompt_txt ml30 mt30" style="width:580px;margin-bottom: 20px">
<p class="email_prompt_p">如果您尚未收到激活邮件,请按照以下步骤操作:</p>
<li>检查邮箱的“订阅邮件”、“垃圾邮件”,可能会发现激活邮件。 </li>
<li>如果激活邮件已无效,请点击重新发送激活邮件按钮。</li>
<li>如果您无法收到激活邮件,请您直接给我们管理员留言:</li>
<div class=" mt10">
<textarea style="resize: none;" class="email_prompt_mes" placeholder="请管理员尽快帮我解决邮箱激活问题"></textarea>
<button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button>
<div class="cl"></div>
<li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" onclick="change_user_email()">更换邮箱地址</a>,重新发送激活邮件</li>
<li>如果您始终无法收到激活邮件,请直接给我们留言:</li>
<div class="mt10">
<% get_memo %>
<%= form_for(@new_memo, :url => mail_feedback_forum_path(@public_forum, :user_id => @user.id), :remote => true) do |f| %>
<%= f.text_area :subject, :id => "subject", :class => "email_prompt_mes", :style => "width: 568px;", :placeholder => l(:label_email_feedback_tips) %>
<%= f.hidden_field :content, :id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<span class="c_red fl" id="mail_valid_feedback_tip" style="display: none;">内容不能为空</span>
<a href="javascript:void(0);" class="btn btn-blue fr" onclick="f_submit();">确定</a>
<% end %>
</div>
</ul>
</div>
</div>
<script type="text/javascript">
function change_user_email(){
var htmlvalue = "<%= j (render :partial => 'account/change_user_email', :locals => {:user => @user}) %>";
pop_box_new(htmlvalue,520,316);
}
function resendMail(url,id)
{
$.get(
@ -55,4 +64,26 @@
}
});
}
function regex_mv_name()
{
var name = $.trim($("#subject").val());
if(name.length == 0)
{
$("#mail_valid_feedback_tip").show();
return false;
}
else
{
$("#mail_valid_feedback_tip").hide();
return true;
}
}
function f_submit()
{
if(regex_mv_name()){
$("#new_memo").submit();
}
}
</script>

View File

@ -5,7 +5,7 @@
<div class="email_verify" style="width: 580px;">
<p class="fb f18" style="color:green;"><i class="icon-ok mr5 f18"></i>注册成功!
<span style=" color:#3b94d6; font-size:12px; font-weight:normal;">请在24小时内点击邮件中的链接来激活您的账号。</span></p>
<p class="f14 mt30 mb5">请登录邮箱(<span class="c_red"><%= @user.mail %></span>)收取账号激活邮件。<br/>点击邮件中的激活链接,方可使用该账号
<p class="f14 mt30 mb5">请登录邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>)收取账号激活邮件。<br/>点击邮件中的激活链接,方可使用该账号
</p>
<p>
<a href="http://mail.<%= email %>" class="btn btn-blue" target="_blank"><%= l(:label_check_email)%></a>
@ -14,14 +14,15 @@
<ul class="email_prompt_txt mt30" style="width: 580px;">
<p class="email_prompt_p">如果您一直收不到激活邮件,请按照以下步骤操作:</p>
<li>1.请确认是否填写了正确的邮箱地址 </li>
<li>2.请注意查看邮箱中的“订阅邮件”、“垃圾邮件”可能Trustie的邮件被误杀了</li>
<li>3.请点击重新发送激活邮件按钮</li>
<li>4.如果您无法收到激活邮件,请直接给我们留言:</li>
<li>请确认是否填写了正确的邮箱地址 </li>
<li>请注意查看邮箱中的“订阅邮件”、“垃圾邮件”可能Trustie的邮件被误杀了</li>
<li>请点击重新发送激活邮件按钮</li>
<li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" onclick="change_user_email()">更换邮箱地址</a>,重新发送激活邮件</li>
<li>如果您始终无法收到激活邮件,请直接给我们留言:</li>
<div class="mt10 clearfix">
<% get_memo %>
<%= form_for(@new_memo, :url => mail_feedback_forum_path(@public_forum, :user_id => @user.id), :remote => true) do |f| %>
<%= f.text_area :subject, :id => "subject", :class => "email_prompt_mes", :style => "width: 568px;", :placeholder => l(:label_feedback_tips) %>
<%= f.text_area :subject, :id => "subject", :class => "email_prompt_mes", :style => "width: 568px;", :placeholder => l(:label_email_feedback_tips) %>
<%= f.hidden_field :content, :id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<span class="c_red fl" id="mail_valid_feedback_tip" style="display: none;">内容不能为空</span>
<a href="javascript:void(0);" class="btn btn-blue fr" onclick="f_submit();">确定</a>
@ -33,6 +34,11 @@
</div>
<script>
function change_user_email(){
var htmlvalue = "<%= j (render :partial => 'account/change_user_email', :locals => {:user => @user}) %>";
pop_box_new(htmlvalue,520,316);
}
function regex_mv_name()
{
var name = $.trim($("#subject").val());
@ -51,7 +57,6 @@
function f_submit()
{
if(regex_mv_name()){
alert("222");
$("#new_memo").submit();
}
}

View File

@ -1,7 +1,7 @@
<h3>
<%=l(:label_user_homework)%>
</h3>
<p><%= link_to "编程作业", admin_homework_path(:type => "2") %></p>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>

View File

@ -84,6 +84,16 @@
#:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %>
<% end %>
<% elsif attachment.container_type == 'TrainingTask' %>
<% if User.current == attachment.author %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
#:remote => true,
#:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %>
<% end %>
<% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},

View File

@ -59,5 +59,5 @@
<% if contest_activities.count + page * 10 < @contest_activities_count %>
<!--<div id="show_more_course_activities" class="loadMore mt10 f_grey">点击展开更多<%#= link_to "", course_activity_path(@course.id, :type => type, :page => page), :id => "more_course_activities_link", :remote => "true", :class => "none" %></div>-->
<%= link_to "点击展开更多",contest_activities_contest_path(@contest.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
<%= link_to "点击展开更多",contest_path(@contest.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end %>

View File

@ -36,7 +36,7 @@
<%= link_to '管理员身份', switch_role_contest_path(@contest, :user_id => User.current.id, :curr_role => 14, :tar_role => 13), :class => "fr sy_btn_blue mt28 ml10", :title => "由评委身份切换至管理员身份" %>
<% end %>
<% end %>
<% else %>
<% elsif User.current.logged? %>
<%= link_to "加入竞赛",join_contest_contests_path(),:remote => true, :method => "get", :class => "fr sy_btn_blue mt28 ml10" %>
<% end %>
<span class="fr mt30 f16"> 邀请码:

View File

@ -5,7 +5,7 @@
<div class="cl"></div>
<div id="messageContent">
<div class="resources"><%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %>
<div class="resources " ><%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %>
<div class="fl" style="width:658px;">
<%= form_for('new_form',:url => leave_contest_message_path(@contest.id), :html =>{:id => "contest_feedback_new"}, :method => "post") do |f|%>
<%= render :partial => "users/jour_form", :locals => {:f => f, :object => @contest} %>

View File

@ -1,30 +1,57 @@
<div class="homepageRight mt0 ml10" onmouseover="$('#edit_link').show(); " onmouseout="$('#edit_link').hide();" style="background-color: #fff;">
<div class="contestRightBanner border-bottom">
<div class="NewsBannerName">
竞赛介绍
</div>
<% if User.current.admin_of_contest?(@contest) %>
<%= link_to "编辑", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "link-blue fr mt5 none", :id => "edit_link" %>
<% end %>
</div>
<div class="cl"></div>
<div>
<% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">请尽快补充竞赛说明,赢得更多参赛者的青睐吧~</p>
<% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">尚未发布竞赛说明,敬请期待~</p>
<% else %>
<div class="description_div">
<div class="syllabuscon upload_img ke-block break_word" id="syllabus_description_<%= @contest.id %>">
<%= @contest.description.html_safe %>
</div>
<div class="mt10" style="font-weight:normal; font-size: 12px;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @contest} %>
</div>
<div class="homepageRight mt0 ml10" onmouseover="$('#edit_link').show(); " onmouseout="$('#edit_link').hide();">
<div style="background-color: #fff;">
<div class="contestRightBanner border-bottom">
<div class="NewsBannerName">
竞赛介绍
</div>
<% end %>
<% if User.current.admin_of_contest?(@contest) %>
<%= link_to "编辑", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "link-blue fr mt5 none", :id => "edit_link" %>
<% end %>
</div>
<div class="cl"></div>
<div>
<% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p" style="margin-bottom: 0px; padding-bottom: 100px;">请尽快补充竞赛说明,赢得更多参赛者的青睐吧~</p>
<% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p" style="margin-bottom: 0px; padding-bottom: 100px;">尚未发布竞赛说明,敬请期待~</p>
<% else %>
<div class="description_div">
<div class="syllabuscon upload_img ke-block break_word" id="syllabus_description_<%= @contest.id %>">
<%= @contest.description.html_safe %>
</div>
<div class="mt10" style="font-weight:normal; font-size: 12px;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @contest} %>
</div>
</div>
<% end %>
</div>
</div>
<div class="mt10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
<%= get_acts_list_type @type %></div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="homepagePostType" style="width:90px; left:-80px;">
<li>
<ul class="homepagePostTypeHomework fl">
<li><%= link_to "全部动态", contest_path(@contest), :class =>"homepagePostTypeAll postTypeGrey"%></li>
<li><%= link_to "作品动态", contest_path(@contest, :type => 'work'), :class => "homepagePostTypeAssignment postTypeGrey"%></li>
<li><%= link_to "通知动态", contest_path(@contest, :type => 'news'), :class => "homepagePostTypeNotice postTypeGrey"%></li>
<!--<li><%#= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey"%></li>-->
<li><%= link_to "论坛动态", contest_path(@contest, :type => 'message'), :class => "homepagePostTypeForum postTypeGrey"%></li>
<li><%= link_to "留言动态", contest_path(@contest, :type => 'journalsForMessage'), :class => "homepagePostTypeMessage postTypeGrey"%></li>
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>-->
</ul>
</li>
</ul>
</li>
</ul>
</div>
<%= render :partial => 'contests/contest_activity', :locals => {:contest_activities => @contest_activities,:page => 0,:type => @type} %>
</div>
</div>

View File

@ -0,0 +1 @@
$("#show_more_course_activities").replaceWith("<%= escape_javascript( render :partial => 'contests/contest_activity',:locals => {:contest_activities => @contest_activities, :page => @page,:type => @type} )%>");

View File

@ -34,6 +34,15 @@
<li>
<a href="https://www.ucloud.cn/" target="_blank"><img src="images/footer_logo/p-ucloud.png" width="210" height="40" alt="ucloud"></a>
</li>
<li>
<a href="http://www.nju.edu.cn/" target="_blank"><img src="images/footer_logo/p-nju.png" width="210" height="40" alt="南京大学"></a>
</li>
<li>
<a href="http://www.xtu.edu.cn/" target="_blank"><img src="images/footer_logo/p-xtu.png" width="210" height="40" alt="湘潭大学"></a>
</li>
<li>
<a href="javascript:void(0)"><img src="images/footer_logo/p-zgkyrj.png" width="210" height="40" alt="中国开源软件推进联盟"></a>
</li>
</ul>
<div class="cl"></div>
</div>

View File

@ -4,7 +4,7 @@
<ul class="rankList">
<h3 style="font-size: 14px; font-weight: normal;">
<% if (User.current.logged? && course.open_student == 1) || (User.current.member_of_course?(course)) || User.current.admin? %>
<%= link_to "活跃度", course_member_path(course, :role => 2, :sort_type => 'act_score'), :class => 'fontGrey3' %>
<%= link_to "活跃度", course_statistics_course_path(@course), :class => 'fontGrey3' %>
<% else %>
<span class="fontGrey7"> 活跃度 </span>
<% end %>

View File

@ -3,7 +3,7 @@
<ul class="rankList">
<h4 style="font-size: 14px; font-weight: normal;">
<% if (User.current.logged? && course.open_student == 1) || (User.current.member_of_course?(course)) || User.current.admin? %>
<%= link_to "英雄榜", course_member_path(course, :role => 2), :class => 'fontGrey3' %>
<%= link_to "英雄榜", course_statistics_course_path(@course, :tab => 2), :class => 'fontGrey3' %>
<% else %>
<span class="fontGrey7">英雄榜</span>
<% end %>

View File

@ -20,7 +20,8 @@
<% elsif @sort_type == "score" && @score_sort_by == 'asc' %>
<a href="javascript:void(0)" class="sy_sortdownbtn"></a>
<% end %>
<div class="sy_fenban_show undis" >
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '484px;' : '481px;' %>">
<span style="top: 16px;"></span>
<p>积分规则<br/>
班级作业的得分总和</p>
</div>
@ -32,7 +33,8 @@
<% elsif @sort_type == "ex_score" && @score_sort_by == 'asc' %>
<a href="javascript:void(0)" class="sy_sortdownbtn"></a>
<% end %>
<div class="sy_fenban_show undis" >
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '399px' : '392px' %>;">
<span style="top: 16px;"></span>
<p>积分规则<br/>
班级测验的得分总和</p>
</div>
@ -44,7 +46,8 @@
<% elsif @sort_type == "act_score" && @score_sort_by == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
<div class="sy_fenban_show undis" >
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '315px' : '303px' %>;">
<span style="top: 16px;"></span>
<p>积分规则<br/>
资源发布:资源数 x 5 <br>
问答发布:发帖数 x 2 <br>
@ -58,7 +61,8 @@
</div>
</th>
<th class="<%= is_teacher ? 'sy_th0' : 'sy_th1' %> sy_fenban_tap">总得分
<div class="sy_fenban_show undis" style="width:180px;">
<div class="sy_fenban_show undis" style="left: <%=is_teacher ? '230px' : '214px' %>;">
<span style="top: 16px;"></span>
<p>积分规则<br/>
作业得分+测评得分+社区得分</p>
</div>
@ -83,7 +87,7 @@
<%= link_to user.show_name, user_path(user), :class => 'fl sy_class_users_st_name' ,:title => "#{user.show_name}", :target => '_blank' %>
</td>
<td>
<span class="sy_class_users_st_num" title="<%= user.user_extensions.student_id %>"><%= user.user_extensions.student_id %></span>
<span class="sy_class_users_st_num" title="<%= user.user_real_extension.student_id %>"><%= user.user_real_extension.student_id %></span>
</td>
<td>
<% if !is_teacher && User.current.id != member.user_id && course_has_score_open_common_homework(@course) %>
@ -212,6 +216,16 @@
});
});
$(".sy_fenban_tap").each(function(){
$(this).mouseenter(function(){
$(".sy_fenban_show").hide();
$(this).children('.sy_fenban_show').show();
});
$(this).mouseleave(function(){
$(this).children('.sy_fenban_show').hide(0);
});
});
$(".sy_tips_box_inner").each(function(){
$(this).mouseover(function(){
$(this).stop();

View File

@ -9,7 +9,7 @@
</div>
<div class="cl"></div>
<p class="sy_cgrey ml20">
<% homework_count = e_course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
<% homework_count = e_course.homework_commons.where("publish_time <= '#{Time.now}'").count %>
<% if homework_count > 0 %>
作业<span class="sy_cir_grey ml5 mr5"><%=homework_count %></span>
<% end %>

View File

@ -0,0 +1 @@
window.location.href = "<%= settings_course_path(@course.id, :tab => 'member') %>";

View File

@ -42,14 +42,17 @@
</div>
<div class=" clear ml10 mr10" >
<!--<div class="mb10 clear">-->
<!--<label class=" fl mt5 c_grey02">&nbsp;选择作业&nbsp;&nbsp;:&nbsp;</label>-->
<!--<select class=" fl newupload_select w150" style="width:150px; height:30px; background:#fff;">-->
<!--<option>全部</option>-->
<!--<option>第一作业</option>-->
<!--<option>第二次作业</option>-->
<!--</select>-->
<!--</div>-->
<div class="mb10 clear">
<label class=" fl mt5 c_grey02">&nbsp;选择作业&nbsp;&nbsp;:&nbsp;</label>
<% homeworks = select_group_homeworks @course %>
<% is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? %>
<select id="homework_select" class=" fl newupload_select w150" onchange="select_homework_projects();" style="width:150px; height:30px; background:#fff;">
<option value="0">全部</option>
<% homeworks.each do |homework| %>
<option value="<%= homework.id %>">作业<%= (get_hw_index(homework, is_teacher) + 1)%><%= homework.name %></option>
<% end %>
</select>
</div>
<div id="project_table_<%=@course.id %>">
<% if @tab == 3 %>
@ -71,6 +74,9 @@
g('game-setting-content-<%= @tab %>').className='dis';
g('game-setting-tab-nav-<%= @tab %>').className='game-setting-nav-hover';
<% end %>
<% if @homework_id != 0 %>
$("#homework_select option[value='<%= @homework_id %>']").attr("selected",true);
<% end %>
});
function g(o){
@ -83,6 +89,13 @@
}
g('game-setting-content-'+n).className='dis';
g('game-setting-tab-nav-'+n).className='game-setting-nav-hover';
$.get('<%= course_statistics_course_path() %>'+'?tab='+n);
if(n == 3){
$("#homework_select option[value='0']").attr("selected",true);
}
$.get('<%= course_statistics_course_path(@course) %>'+'?tab='+n);
}
function select_homework_projects(){
$.get('<%= course_statistics_course_path(@course) %>'+'?tab=3&homework_id='+$("#homework_select").val());
}
</script>

View File

@ -7,7 +7,7 @@
<li class="mt5 ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_syllabus_name)%>&nbsp;&nbsp;</label>
<% if @syllabus.nil? %>
<%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input w300 h28"} %>
<%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input w300 h28", :onchange => "change_course_name();"} %>
<% else %>
<span id="course_syllabus_title"><%=@syllabus.title %></span>
<input style="display: none;" name="syllabus_id" value="<%=@syllabus.id %>" />
@ -28,7 +28,7 @@
<!--<li class="ml125 mt10 mb10 fontGrey2" style="max-width: 544px;">班级是一个由教师、助教(教辅)和学生组成的临时的教学群体,在规定的时间内(如一个学期)完成一门课程规定的教学任务。本质上,一门课程就是一个教学计划。</li>-->
<li class="mt10 ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="new_class_period" class="hwork_input02 w289" onkeyup="regex_course_class_period('new');" placeholder="例如54" maxlength="6">
<input type="text" name="class_period" id="new_class_period" class="courses_input w289" onkeyup="regex_course_class_period('new');" placeholder="例如54" maxlength="6">
<span class="c_red" id="new_course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
@ -116,5 +116,15 @@
$("#new_term").change(function(){
document.getElementById("new_end_term").options[document.getElementById("new_term").selectedIndex].selected = true;
});
<% unless @syllabus.nil? %>
$("#new_course_name").val('<%= @syllabus.title %>');
$("#new_course_name").focus();
<% end %>
});
function change_course_name(){
if($("#new_syllabus_id").val() != '0') {
$("#new_course_name").val($("#new_syllabus_id").find("option:selected").text());
$("#new_course_name").focus();
}
}
</script>

View File

@ -0,0 +1 @@
$("#search_member_list").html("<%= escape_javascript(render :partial => 'courses/settings/search_teacher_list', :locals => {:members => @members}) %>");

View File

@ -42,7 +42,6 @@
<% elsif @select_tab == 'boards'%>
$("#tb_4").click();
<% end %>
$("#homework_page_right").css("min-height",$("#courseLSide").height()+45);
});
function g(o){

View File

@ -0,0 +1,76 @@
<div id="muban_popup_box" style="width:424px;">
<div class="muban_popup_top">
<h3 class="fl">更换管理员</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con clear">
<div class="mr10 ml10">
<div class="alert alert-orange mb10 mt10">
选择的成员将会成为新的管理员,您的角色将变更为“教师”
</div>
<div class="" style="border: 1px solid #ccc">
<input type="text" name="search" value="<%=@search %>" placeholder="支持姓名、邮箱、登录名搜索" class="subjectSearch" style="height: 32px; width: 380px; margin: 5px 7px 0 7px; border: 1px solid #e5e5e5;" />
<div class="cl"></div>
<%= form_tag(change_manager_course_path(@course), method: 'post', :remote => true, :class => "",:id => "change_manager_form") do %>
<div id="search_member_list" style="padding: 0 7px;">
<%=render :partial => 'courses/settings/search_teacher_list', :locals => {:members => nil} %>
</div>
<% end %>
<div class="cl"></div>
<div class="cl"></div>
</div>
<div class="mt10">
<span class="c_red none" id="add_members_notice"></span>
<a href="javascript:void(0);" class="fr sy_btn_blue" onclick="submit_add_members_form();">确定</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr10" onclick="hideModal();">取消</a>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<script>
var lastSearchCondition = '';
var count = 0;
function search_mems(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_course_teacher_list', :id => @course.id) %>'+'?search='+ e.target.value,
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='search']").on('input', function (e) {
throttle(search_mems,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_course_teacher_list', :id => @course.id) %>',
type:'get'
});
});
function submit_add_members_form(){
if($("input[name='chooseteacher']:checked").length == 0) {
$("#add_members_notice").show();
$("#add_members_notice").html("请先选择成员");
} else{
$("#change_manager_form").submit();
hideModal();
}
}
</script>

View File

@ -59,12 +59,16 @@
<% end %>
</td>
<td>
<% unless member.user == @course.teacher %>
<% if member.user == @course.teacher %>
<% if User.current == @course.teacher %>
<a href="javascript:void(0)" class="sy_btn_green" onclick="change_manager();">更换管理员</a>
<% end %>
<% else %>
<a href="javascript:void(0)" class="sy_btn_blue mr5" onclick="edit_member($(this), <%=member.id %>);">编辑</a>
<a href="javascript:void(0)" class="sy_btn_blue mr5" style="display: none;" onclick="$('#member-<%= member.id%>-roles-form').submit();">保存</a>
<a href="javascript:void(0)" class="sy_btn_grey mr5" style="display: none;" onclick="cancel_edit($(this), <%=member.id %>);">取消</a>
<a href="javascript:void(0)" class="sy_btn_grey mr5" id="delete_member_<%=member.id %>" onclick="delete_confirm_box_2('<%=membership_path(member) %>', '<%= l(:label_delete_confirm)%>')">删除</a>
<% end %>
<% end %>
</td>
</tr>
<% end %>
@ -87,4 +91,8 @@
$('#delete_member_' + id).show();
$(div).hide();
}
function change_manager(){
var htmlvalue = "<%= escape_javascript(render :partial => 'courses/settings/change_manager') %>";
pop_box_new(htmlvalue, 424, 366);
}
</script>

View File

@ -63,9 +63,9 @@
<% end %>
</ul>
<% if @course.is_delete == 1 %>
<div class="mt30 ml30"><%=link_to "恢复该班级", renew_course_path(@course) %></div>
<div class="mt30 ml30 mb15"><%=link_to "恢复该班级", renew_course_path(@course) %></div>
<% else %>
<div class="mt30 ml30">
<div class="mt30 ml30 mb15">
<img src="/images/pic_del.gif" class="mr5"><%=link_to "删除该班级", course_path(@course), :method => :delete, :confirm=>"确认要删除该班级吗?" %>
<span>(友情提示:删除该班级后如果您想恢复该班级,请联系系统管理员!)</span>
</div>

View File

@ -0,0 +1,12 @@
<ul class="mt10" style="height:160px; min-height:160px; max-height:160px; overflow:auto;">
<% unless members.nil? || members.empty? %>
<% members.each do |mem| %>
<li>
<input type="radio" name="chooseteacher" value="<%=mem.id %>" class="mr5" style="vertical-align:middle;" />
<span class="break_word" style="width: 350px;"><%=mem.user.show_name %><%= mem.user.login %></span>
</li>
<% end %>
<% end %>
</ul>
<div class="cl"></div>

View File

@ -20,7 +20,10 @@
var question_form = $("form.new_exercise_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存测验标题及测验基本信息。");
} else if(question_form.length > 0) {
} else if($("#show_exercise_time").html().trim() == ""){
notice_box("请先设置测验的截止时间");
}
else if(question_form.length > 0) {
alert("请先保存正在编辑的题目。");
} else{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'exercise_submit_info', locals: { :exercise => exercise}) %>');

View File

@ -9,17 +9,21 @@
</div>
<div class="cl"></div>
<div id="polls_list" class="polls_list">
<% if @exercises.count != 0 %>
<% @exercises.each_with_index do |exercise,index|%>
<ul id="exercises_<%= exercise.id %>" class="exercise_list_div" onmouseover="$('#exercise_opr_<%=exercise.id %>').show();" onmouseout="$('#exercise_opr_<%=exercise.id %>').hide();">
<%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %>
</ul>
<div class="cl"></div>
<% end%>
<% @exercises.each_with_index do |exercise,index|%>
<ul id="exercises_<%= exercise.id %>" class="exercise_list_div" onmouseover="$('#exercise_opr_<%=exercise.id %>').show();" onmouseout="$('#exercise_opr_<%=exercise.id %>').hide();">
<%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %>
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
<% end%>
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
<% else %>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div><!--列表end-->

View File

@ -6,7 +6,7 @@
<% unless exercise.publish_time.nil? %>
<span class="mr100">发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
<% end %>
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></span>
<span class="mr100">截止时间:<font id="show_exercise_time"><%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></font></span>
<% if exercise.time != -1 %>
<span>测验时长:<%= exercise.time %>分钟</span>
<% end %>

View File

@ -133,7 +133,7 @@
</div>
<% end %>
</div>
<div id="course_list">
<div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div>
</div>

View File

@ -1,14 +1,22 @@
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div id="resource_detail_<%=file.id %>">
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% if curse_attachments.count != 0 %>
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div id="resource_detail_<%=file.id %>">
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>
<% else %>
<div class="cl"></div>
<div style="background-color: #fff; height: 400px;">
<div class="icons_tishi" style="margin-top: 10px; padding-top: 125px;"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
</div>
<% end %>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>

View File

@ -1,10 +1,18 @@
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:course_id => course_id} %>
<% if homework_commons.count != 0 %>
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:course_id => course_id} %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true%>
</ul>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% else %>
<div class="cl"></div>
</div>
</div>
<div style="background-color: #fff; height: 400px;">
<div class="icons_tishi" style="margin-top: 10px; padding-top: 125px;"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
</div>
<% end %>

View File

@ -0,0 +1,19 @@
var str = "";
<% if params[:type].to_i == 1 %>
str = "加入题库已成功";
<% elsif params[:type].to_i == 2 %>
str = "已经同步更新到题库";
<% elsif params[:type].to_i == 3 %>
str = "已经另存到题库";
<% end %>
notice_box(str);
<% if @hw_status == 5 %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% end %>
<% if @user_activity_id != @homework.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
<% end %>

View File

@ -0,0 +1,17 @@
<% if @status == 1 %>
notice_box("该作业已发布");
<% elsif @status == 2 %>
notice_box("您还没有设置截止时间<br/>请先编辑作业并设置截止时间和发布时间");
<% else %>
notice_box("发布成功");
<% if @hw_status == 5 %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% end %>
<% if @user_activity_id != @homework.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
<% end %>
<% end %>

View File

@ -1,7 +1,7 @@
<% if @homework.homework_type == 2 %>
<% if @homework.anonymous_comment == 0 %>
var htmlvalue = "<%= escape_javascript(render :partial => 'homework_common/set_score_rule_pro',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 630, 914);
pop_box_new(htmlvalue, 630, 772);
<% else %>
var htmlvalue = "<%= escape_javascript(render :partial => 'homework_common/set_score_rule_pro_anon',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 530, 404);
@ -9,7 +9,7 @@
<% else %>
<% if @homework.anonymous_comment == 0 %>
var htmlvalue = "<%= escape_javascript(render :partial => 'homework_common/set_score_rule_non_pro',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 630, 885);
pop_box_new(htmlvalue, 630, 742);
<% else %>
var htmlvalue = "<%= escape_javascript(render :partial => 'homework_common/set_score_rule_none_pro_anon',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 530, 332);

View File

@ -1,99 +1,112 @@
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
<% project_issue_count = @project.issues.count %>
<% project_acts = ForgeActivity.where("project_id = ?", @project.id).count %>
<% raodmaps = Version.where("project_id = ?", @project.id).count %>
<% project_score = @project.project_score %>
<%# 更新访问数,刷新的时候更新访问次数 %>
<% update_visiti_count @project %>
<div class="pro_new_top clear mb10">
<div class="fl pro_new_name ml15 clear">
<% unless @project.is_public? %><span class="icons_newpro_lock fl "></span><% end %>
<%=link_to "#{@project.owner.try(:show_name)}<span class='ml5 mr5'>/</span>".html_safe, user_path(@project.owner), :class => "pro_new_username" %>
<%=link_to @project.name, project_path(@project), :class => "pro_new_username break_word" %>
</div>
<!--加入、退出、关注项目-->
<div class="fr clear mr15">
<ul><span id="join_in_project_applied"><%= render :partial => "projects/applied_status" %></span></ul>
</div>
<div class="cl"></div>
<% unless @project.forked_from_project_id.nil? %>
<div class="fl pro_new_name ml15 clear mt5">
<span class="vl_fork fl mr5 mt2">forked from</span> <%=link_to "#{get_fork_from_project(@project.forked_from_project_id).owner.try(:show_name)}<span class='ml5 mr5'>/</span>".html_safe, user_path(get_fork_from_project(@project.forked_from_project_id).owner), :class => "pro_new_username_fork fl", :target => "_blank" %>
<%=link_to get_fork_from_project(@project.forked_from_project_id).name, project_path(get_fork_from_project(@project.forked_from_project_id)), :class => "pro_new_username_fork fl", :target => "_blank" %>
</div>
<div class="cl"></div>
<% end %>
<div class="pro_new_topnav mt8">
<ul>
<li id="project_menu_01">
<%= link_to "#{l(:label_activity)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k(project_acts)}</span>".html_safe, {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "pro_new_proname", :title => "#{project_acts}" %>
</li>
<!--问题跟踪-->
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<li id="project_menu_02">
<%= link_to project_issue_count > 0 ? "#{l(:label_issue_tracking)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_issue_count}</span>".html_safe : "#{l(:label_issue_tracking)}", project_issues_path(@project, :remote => true), :class => "pro_new_proname", :title => "#{project_issue_count}" %>
</li>
<% end %>
<!--讨论区-->
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<li id="project_menu_03">
<%= link_to project_score.board_num > 0 ? "#{l(:project_module_boards)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.board_num}</span>".html_safe : "#{l(:project_module_boards)}", project_boards_path(@project), :class => "pro_new_proname", :title => "#{project_score.board_num}" %>
</li>
<% end %>
<!--资源库-->
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<li id="project_menu_04">
<%= link_to project_file_num > 0 ? "#{l(:project_module_files)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_file_num}</span>".html_safe : l(:project_module_files), project_files_path(@project), :class => "pro_new_proname", :title => "#{project_file_num}" %>
<% end %>
<!--版本库-->
<% if visible_repository?(@project) %>
<% if User.current.admin? || (is_project_member?(User.current.id, @project.id) && role_of_members_in_project(@project.id, User.current.id) != "Reporter" ) %>
<li id="project_menu_05"><%= link_to @project.project_score.changeset_num.to_i > 0 ? "#{l(:project_module_repository)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.changeset_num}</span>".html_safe : "#{l(:project_module_repository)}",({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}), :class => "pro_new_proname", :title => "#{project_score.changeset_num}" %>
</li>
<% end %>
<% end %>
<!--Pull Request-->
<% unless @project.gpid.nil? %>
<li id="project_menu_06">
<%= link_to project_score.pull_request_num >0 ? "Pull Requests <span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.pull_request_num}</span>".html_safe : "Pull Requests", project_pull_requests_path(@project), :class => "pro_new_proname", :title => "#{project_score.pull_request_num}" %>
<% if project_score.pull_request_num >0 %>
<% end %>
</li>
<% end %>
<!--里程碑-->
<li id="project_menu_07">
<%= link_to @project.versions.count >0 ? "#{l(:label_roadmap)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k @project.versions.count}</span>".html_safe : l(:label_roadmap) ,project_roadmap_path(@project), :class => "pro_new_proname", :title => "#{@project.versions.count}" %>
</li>
<!--日历-->
<% unless @project.enabled_modules.where("name = 'calendar'").empty? %>
<li id="project_menu_08">
<%= link_to l(:project_module_calendar),project_calendar_path(@project) %>
</li>
<% end %>
<!--甘特图-->
<% unless @project.enabled_modules.where("name = 'gantt'").empty? %>
<li id="project_menu_09">
<%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>
</li>
<% end %>
<% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %>
<li id="project_menu_010">
<%= link_to "#{l(:button_configure)}", settings_project_path(@project), :class => "pro_new_proname" %>
</li>
<% end %>
</ul>
</div>
</div>
<!--新版项目头部结束-->
<script>
$(function(){
$("#project_menu_0<%= @project_menu_type %>").addClass('pro_new_topnav_active');
})
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
<% project_issue_count = @project.issues.count %>
<% training_tasks_count = @project.training_tasks.count %>
<% project_acts = ForgeActivity.where("project_id = ?", @project.id).count %>
<% raodmaps = Version.where("project_id = ?", @project.id).count %>
<% project_score = @project.project_score %>
<%# 更新访问数,刷新的时候更新访问次数 %>
<% update_visiti_count @project %>
<div class="pro_new_top clear mb10">
<div class="fl pro_new_name ml15 clear">
<% unless @project.is_public? %><span class="icons_newpro_lock fl "></span><% end %>
<% if @project.is_training_project? %>
<%=link_to "#{@project.owner.try(:show_name)}导师<span class='ml5 mr5'>/</span>".html_safe, user_path(@project.owner), :class => "pro_new_username" %>
<% else %>
<%=link_to "#{@project.owner.try(:show_name)}<span class='ml5 mr5'>/</span>".html_safe, user_path(@project.owner), :class => "pro_new_username" %>
<% end %>
<%=link_to @project.name, project_path(@project), :class => "pro_new_username break_word" %>
</div>
<!--加入、退出、关注项目-->
<% if !@project.is_child_training_project? %>
<div class="fr clear mr15">
<ul><span id="join_in_project_applied"><%= render :partial => "projects/applied_status" %></span></ul>
</div>
<% end %>
<div class="cl"></div>
<% unless @project.forked_from_project_id.nil? %>
<div class="fl pro_new_name ml15 clear mt5">
<span class="vl_fork fl mr5 mt2">forked from</span> <%=link_to "#{get_fork_from_project(@project.forked_from_project_id).owner.try(:show_name)}<span class='ml5 mr5'>/</span>".html_safe, user_path(get_fork_from_project(@project.forked_from_project_id).owner), :class => "pro_new_username_fork fl", :target => "_blank" %>
<%=link_to get_fork_from_project(@project.forked_from_project_id).name, project_path(get_fork_from_project(@project.forked_from_project_id)), :class => "pro_new_username_fork fl", :target => "_blank" %>
</div>
<div class="cl"></div>
<% end %>
<div class="pro_new_topnav mt8">
<ul>
<li id="project_menu_01">
<%= link_to "#{l(:label_activity)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k(project_acts)}</span>".html_safe, {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "pro_new_proname", :title => "#{project_acts}" %>
</li>
<!--问题跟踪-->
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<li id="project_menu_02">
<%= link_to project_issue_count > 0 ? "#{l(:label_issue_tracking)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_issue_count}</span>".html_safe : "#{l(:label_issue_tracking)}", project_issues_path(@project, :remote => true), :class => "pro_new_proname", :title => "#{project_issue_count}" %>
</li>
<% end %>
<!--实训任务-->
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
<% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
<li id="project_menu_011">
<%= link_to training_tasks_count > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k training_tasks_count}</span>".html_safe : "#{l(:project_module_training_tasks)}", project_training_tasks_url(@project), :class => "pro_new_proname", :title => "#{training_tasks_count}" %>
</li>
<% end %>
<% end %>
<!--讨论区-->
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<li id="project_menu_03">
<%= link_to project_score.board_num > 0 ? "#{l(:project_module_boards)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.board_num}</span>".html_safe : "#{l(:project_module_boards)}", project_boards_path(@project), :class => "pro_new_proname", :title => "#{project_score.board_num}" %>
</li>
<% end %>
<!--资源库-->
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<li id="project_menu_04">
<%= link_to project_file_num > 0 ? "#{l(:project_module_files)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_file_num}</span>".html_safe : l(:project_module_files), project_files_path(@project), :class => "pro_new_proname", :title => "#{project_file_num}" %>
<% end %>
<!--版本库-->
<% if !@project.enabled_modules.where("name = 'repository'").empty? && !Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first.nil? %>
<li id="project_menu_05"><%= link_to @project.project_score.changeset_num.to_i > 0 ? "#{l(:project_module_repository)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.changeset_num}</span>".html_safe : "#{l(:project_module_repository)}",({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}), :class => "pro_new_proname", :title => "#{project_score.changeset_num}" %></li>
<% end %>
<!--Pull Request-->
<% unless @project.gpid.nil? %>
<li id="project_menu_06">
<%= link_to project_score.pull_request_num >0 ? "Pull Requests <span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.pull_request_num}</span>".html_safe : "Pull Requests", project_pull_requests_path(@project), :class => "pro_new_proname", :title => "#{project_score.pull_request_num}" %>
<% if project_score.pull_request_num >0 %>
<% end %>
</li>
<% end %>
<!--里程碑-->
<li id="project_menu_07">
<%= link_to @project.versions.count >0 ? "#{l(:label_roadmap)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k @project.versions.count}</span>".html_safe : l(:label_roadmap) ,project_roadmap_path(@project), :class => "pro_new_proname", :title => "#{@project.versions.count}" %>
</li>
<!--日历-->
<% unless @project.enabled_modules.where("name = 'calendar'").empty? %>
<li id="project_menu_08">
<%= link_to l(:project_module_calendar),project_calendar_path(@project) %>
</li>
<% end %>
<!--甘特图-->
<% unless @project.enabled_modules.where("name = 'gantt'").empty? %>
<li id="project_menu_09">
<%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>
</li>
<% end %>
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) && !@project.is_child_training_project? %>
<li id="project_menu_010">
<%= link_to "#{l(:button_configure)}", settings_project_path(@project), :class => "pro_new_proname" %>
</li>
<% end %>
</ul>
</div>
</div>
<!--新版项目头部结束-->
<script>
$(function(){
$("#project_menu_0<%= @project_menu_type %>").addClass('pro_new_topnav_active');
})
</script>

View File

@ -74,7 +74,7 @@
</span>
</p>
</div>
<div class="sy_class_info fl ml15">
<div class="sy_class_info fl ml15 mt14">
<div class="sy_class_titbox">
<h3 class="fl sy_class_title">
<%=@course.name %>
@ -82,13 +82,11 @@
<span class="<%= @course.is_public == 0 ? 'hw_icon_private' : 'hw_icon_open' %> fl mr20 mt3"></span>
<div class="cl"></div>
</div>
<p class="sy_cgrey mb5">
<span class="mr25">学期:<span class="sy_cblack"><%= current_time_and_term @course %></span></span>
<p class="sy_cgrey mb5 f14 fl mt5">
<span class="mr25">教师:<%= course_teacher_link teacher_num %></span>
<span class="mr25">学生:<%= course_student_link student_num %></span>
</p>
<p class="sy_cgrey fl mt5">
<span class="mr25">单位:<span class="sy_cblack"><%= get_occupation_from_user(@course.teacher).blank? ? '无' : get_occupation_from_user(@course.teacher) %></span></span>
<span class="mr25"><%= current_time_and_term @course %></span>
<span class="mr25"><%= get_occupation_from_user(@course.teacher).blank? ? '无' : get_occupation_from_user(@course.teacher) %></span>
</p>
<% is_TA = get_user_member_roles_course @course, User.current, 7 %>
<% is_TE = get_user_member_roles_course @course, User.current, 9 %>
@ -101,7 +99,7 @@
<%= link_to '学生身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => (is_TA ? 7 : 9), :tar_role => 10), :class => "sy_btn_orange mr10 fl", :title => "由教师身份切换至学生身份" %>
<% end %>
<% unless (is_teacher || is_TA || is_TE || is_ST) %>
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
<div id="join_in_course_header" class="fl"><%= join_in_course_header(@course, User.current) %></div>
<% end %>
</div>
<div class="cl"></div>

View File

@ -38,9 +38,8 @@
<li class="fl"><a href="http://www.webxmf.com/" target="_blank"><img src="/images/footer_logo/bee_logo.png" width="167" height="40" style="display: inline-block;" alt="web小蜜蜂" /></a></li>
</ul>
<div class="cl"></div>-->
<ul class="copyright">
<li class="fl mr30"><%= l(:label_rights_reserved)%></li>
<li class="fl"><a href="http://www.miibeian.gov.cn/" class="fl f_grey" target="_blank"><%= l(:label_license)%></a></li>
</ul>
<div class="copyright">
<p ><%= l(:label_rights_reserved)%><span class="mr10"></span><a href="http://www.miibeian.gov.cn/" class=" f_grey" target="_blank"><%= l(:label_license)%></a></p>
</div>
</ul>
</div><!--Footer end-->

View File

@ -38,8 +38,7 @@
<li class="fl"><a href="http://www.webxmf.com/" target="_blank"><img src="/images/footer_logo/bee_logo.png" width="167" height="40" style="display: inline-block;" alt="web小蜜蜂" /></a></li>
</ul>
<div class="cl"></div>
<ul class="copyright">
<li class="fl mr30"><%= l(:label_rights_reserved)%></li>
<li class="fl"><a href="http://www.miibeian.gov.cn/" class="fl f_grey" target="_blank"><%= l(:label_license)%></a></li>
</ul>
<div class="copyright">
<p ><%= l(:label_rights_reserved)%><span class="mr10"></span><a href="http://www.miibeian.gov.cn/" class=" f_grey" target="_blank"><%= l(:label_license)%></a></p>
</div>
</div><!--Footer end-->

View File

@ -116,6 +116,7 @@
$("#navHomepageSearchType").hide();
});
<% unless @force %>
$("#user_messages").mouseenter(function(){
onNotice = true;
$("#user_messages_list").show();
@ -134,6 +135,7 @@
obj.html("<%=escape_javascript(render :partial => 'layouts/message_loading') %>");
} }, 500);
});
<% end %>
$("#message_list_detail").mouseenter(function(event){
event.stopPropagation();
onUserMessages = true;

View File

@ -132,7 +132,7 @@
role_str = "参赛者"
end
end %>
<li><a href="<%=contest_path(ma.contest_id) %>" target="_blank" title='<%= user.show_name%> <%= user.user_extensions.school_id.blank? ? "" : "来自"+user.user_extensions.school.name+"" %>申请以"<%= role_str%>"的身份加入竞赛:<%=Contest.find(ma.contest_id).name %> <%= User.find(ma.contest_message_id).show_name %><%= ma.status == 1 ? "已同意" : "已拒绝"%>'><span class="shadowbox_news_user"><%= user.show_name%> </span><%= user.user_extensions.school_id.blank? ? "" : "来自"+user.user_extensions.school.name+"" %>申请以"<%= role_str%>"的身份加入竞赛:<%=Contest.find(ma.contest_id).name %> <%= User.find(ma.contest_message_id).show_name %><%= ma.status == 1 ? "已同意" : "已拒绝"%></a></li>
<li><a href="<%=contest_path(ma.contest_id) %>" target="_blank" title='<%= user.show_name%> <%= user.user_extensions.school_id.blank? || user.user_extensions.school.nil? ? "" : "来自"+user.user_extensions.school.name+"" %>申请以"<%= role_str%>"的身份加入竞赛:<%=Contest.find(ma.contest_id).name %> <%= User.find(ma.contest_message_id).show_name %><%= ma.status == 1 ? "已同意" : "已拒绝"%>'><span class="shadowbox_news_user"><%= user.show_name%> </span><%= user.user_extensions.school_id.blank? || user.user_extensions.school.nil? ? "" : "来自"+user.user_extensions.school.name+"" %>申请以"<%= role_str%>"的身份加入竞赛:<%=Contest.find(ma.contest_id).name %> <%= User.find(ma.contest_message_id).show_name %><%= ma.status == 1 ? "已同意" : "已拒绝"%></a></li>
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %>
<li><a href="<%=contest_path(ma.contest) %>" target="_blank" title="<%=User.find(ma.contest_message_id).show_name %> 将您加入了竞赛:<%= ma.contest.name%>"><span class="shadowbox_news_user"><%=User.find(ma.contest_message_id).show_name %> </span>将您加入了竞赛:<%= ma.contest.name%></a></li>
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
@ -177,8 +177,8 @@
<% applied_contest = ma.applied %>
<% contest = Contest.find applied_contest.contest_id %>
<% message_user = User.find(applied_contest.user_id) %>
<% content = '<span class="shadowbox_news_user">'+message_user.show_name+' </span>'+(message_user.user_extensions.school_id.blank? ? "" : "来自")+message_user.user_extensions.school.name+""+'申请以"'+ get_role_str(ma.role) + '"的身份加入竞赛:' + contest.name%>
<%= link_to content.html_safe, contest_path(contest.id), :title => "#{message_user.show_name} #{message_user.user_extensions.school_id.blank? ? '' : '来自'+message_user.user_extensions.school.name}申请以'#{get_role_str(ma.role)}'的身份加入竞赛:#{contest.name}", :target => '_blank' %>
<% content = '<span class="shadowbox_news_user">'+message_user.show_name+' </span>'+(message_user.user_extensions.school_id.blank? || message_user.user_extensions.school.nil? ? "" : "来自"+message_user.user_extensions.school.name+"")+'申请以"'+ get_role_str(ma.role) + '"的身份加入竞赛:' + contest.name%>
<%= link_to content.html_safe, contest_path(contest.id), :title => "#{message_user.show_name} #{message_user.user_extensions.school_id.blank? || message_user.user_extensions.school.nil? ? '' : '来自'+message_user.user_extensions.school.name+""}申请以'#{get_role_str(ma.role)}'的身份加入竞赛:#{contest.name}", :target => '_blank' %>
</li>
<% end %>
<% elsif ma.class == ForgeMessage %>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify','contest'%>

View File

@ -12,7 +12,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','css/sy_public','css/syllabus', 'css/moduel','css/contest'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify','contest' %>
<!-- page specific tags -->
<%= yield :header_tags -%>
@ -44,11 +44,11 @@
<div class="sy_class_leftnav mb12" >
<ul class="accordion">
<li id="sy_01" class="sy_icons_game">
<%= link_to '竞赛首页', contest_path(@contest) %>
</li>
<li id="sy_02" class="sy_icons_index">
<%= link_to '动态', contest_activities_contest_path(@contest) %>
<a href="<%= contest_path(@contest) %>">动态<span><%=@contest.contest_activities.count %></span></a>
</li>
<!--<li id="sy_02" class="sy_icons_index">-->
<!--<%#= link_to '动态', contest_activities_contest_path(@contest) %>-->
<!--</li>-->
<!--<li id="sy_03" class="sy_icons_boards"> <a href="">讨论区<span>26</span></a> <a href="javascript:void(0);" class="sy_class_add"></a></li>-->
<li id="sy_03" class="sy_icons_hwork">
<a href="<%= works_path(:contest => @contest) %>">提交<span><%= work_num%></span></a>
@ -77,8 +77,11 @@
</li>
</ul>
</div><!--sy_class_leftnav end-->
<% update_visiti_count @contest %>
<div class="fontGrey5 mt10 ml20">访问计数 <%= @contest.visits.to_i %> 自2016年5月</div>
</div><!--sy_class_l end-->
<%= render_flash_messages %>
<div class="fl">
<%= yield %>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>

View File

@ -19,7 +19,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','css/syllabus', 'css/moduel','css/contest'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
<!-- page specific tags -->
<%= yield :header_tags -%>

View File

@ -162,8 +162,7 @@
<div class="cl"></div>
<ul class="copyright mt10">
<li class="fl mr30">Copyright&nbsp;&copy;&nbsp;2007-2016,&nbsp;All Rights Reserved</li>
<li>ICP备09019772</li>
<p ><%= l(:label_rights_reserved)%><span class="mr10"></span><a href="http://www.miibeian.gov.cn/" class=" f_grey" target="_blank"><%= l(:label_license)%></a></p>
</ul>
</div>
<div class="cl"></div>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
@ -58,7 +58,7 @@
<li id="user_07" class="user_icons_new">
<%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :style => "font-size:14px;" %>
</li>
<li id="user_08" class="user_icons_addproject">
<li id="user_08" class="user_icons_addproject mb10">
<%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post", :style => "font-size:14px;" %>
</li>
<li id="user_09" class="user_icons_myissues">

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public','css/structure','css/courses','css/popup','prettify','syllabus','sy_public','css/moduel',:media => 'all'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public','css/structure','css/courses','css/popup','prettify','css/syllabus','css/sy_public','css/moduel',:media => 'all'%>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","course",'attachments','prettify','syllabus','cookie'%>

View File

@ -13,7 +13,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'css/common','css/structure', 'css/public', 'css/courses','prettify', 'css/org', 'syllabus'%>
<%= stylesheet_link_tag 'css/common','css/structure', 'css/public', 'css/courses','prettify', 'css/org', 'css/syllabus'%>
<%= javascript_include_tag "course","header",'prettify','contest' %>
<!-- page specific tags -->
<%= yield :header_tags -%>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus',:media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus',:media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>

View File

@ -16,7 +16,7 @@
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<%= stylesheet_link_tag 'css/common','css/structure','css/public','css/popup','syllabus','sy_public', :media => 'all'%>
<%= stylesheet_link_tag 'css/common','css/structure','css/public','css/popup','css/syllabus','css/sy_public', :media => 'all'%>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">

View File

@ -13,7 +13,7 @@
<% end %>
<div class="cl"></div>
<% if @news.commentable? %>
<% if User.current.admin? || ((object.kind_of? Contest) && User.current.member_of_contest?(object)) || ((object.kind_of? Course) && User.current.member_of_course?(object)) || ((object.kind_of? OrgSubfield) && User.current.member_of_org?(object.organization)) %>
<div class="talkWrapMsg" nhname="about_talk_reply">
<em class="talkWrapArrow"></em>
<div class="cl"></div>

View File

@ -41,7 +41,7 @@
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if ((object.kind_of? Organization) ? (User.current.admin_of_org?(object) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
) if ((object.kind_of? OrgSubfield) ? (User.current.admin_of_org?(object.organization) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
</span>
<div class="cl"></div>
</div>

View File

@ -1,10 +1,15 @@
<% polls.each_with_index do |poll, i|%>
<ul id="polls_<%= poll.id %>" class="exercise_list_div" onmouseover="$('#exercise_opr_<%=poll.id %>').show();" onmouseout="$('#exercise_opr_<%=poll.id %>').hide();">
<%= render :partial => 'poll', :locals => {:poll => poll, :index => i} %>
</ul>
<div class="cl"></div>
<% end%>
<% if polls.count != 0 %>
<% polls.each_with_index do |poll, i|%>
<ul id="polls_<%= poll.id %>" class="exercise_list_div" onmouseover="$('#exercise_opr_<%=poll.id %>').show();" onmouseout="$('#exercise_opr_<%=poll.id %>').hide();">
<%= render :partial => 'poll', :locals => {:poll => poll, :index => i} %>
</ul>
<div class="cl"></div>
<% end%>
<ul class="wlist">
<%= pagination_links_full obj_pages, obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<ul class="wlist">
<%= pagination_links_full obj_pages, obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<% else %>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>

Some files were not shown because too many files have changed in this diff Show More