Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
lizanle 2015-09-01 17:04:33 +08:00
commit a8652cbe43
46 changed files with 2029 additions and 1076 deletions

View File

@ -19,7 +19,7 @@ class CommentsController < ApplicationController
default_search_scope :news
include ApplicationHelper
model_object News
before_filter :find_model_object
before_filter :find_model_object
before_filter :find_project_from_association
before_filter :authorize
@ -76,6 +76,6 @@ class CommentsController < ApplicationController
@comment = nil
@news
end
end

View File

@ -115,23 +115,16 @@ class HomeworkCommonController < ApplicationController
end
end
# uri = URI('http://test.gitlab.trustie.net/api/questions.json')
# req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
# req.body = question.to_json
# res = Net::HTTP.start(uri.hostname, uri.port) do |http|
# http.request(req)
# uri = URI('http://192.168.80.21:8080/api/questions.json')
# body = question.to_json
# res = Net::HTTP.new(uri.host, uri.port).start do |client|
# request = Net::HTTP::Post.new(uri.path)
# request.body = body
# request["Content-Type"] = "application/json"
# client.request(request)
# end
uri = URI('http://192.168.80.21:8080/api/questions.json')
body = question.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
result = JSON.parse(res.body)
homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
# result = JSON.parse(res.body)
# homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
homework.homework_detail_programing = homework_detail_programing
else
@ -254,15 +247,15 @@ class HomeworkCommonController < ApplicationController
question[:input] << test.input
question[:output] << test.output
end
uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
body = question.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Put.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
result = JSON.parse(res.body)
# uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
# body = question.to_json
# res = Net::HTTP.new(uri.host, uri.port).start do |client|
# request = Net::HTTP::Put.new(uri.path)
# request.body = body
# request["Content-Type"] = "application/json"
# client.request(request)
# end
# result = JSON.parse(res.body)
end
@homework.save_attachments(params[:attachments])
@ -406,4 +399,4 @@ class HomeworkCommonController < ApplicationController
student_works += student_works
student_works[index + 1 .. index + n]
end
end
end

View File

@ -66,14 +66,14 @@ class IssuesController < ApplicationController
if @query.valid?
case params[:format]
when 'csv', 'pdf'
@limit = 10#Setting.issues_export_limit.to_i
when 'atom'
@limit = 10#Setting.feeds_limit.to_i
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 10})
else
@limit = 10#per_page_option
when 'csv', 'pdf'
@limit = 10#Setting.issues_export_limit.to_i
when 'atom'
@limit = 10#Setting.feeds_limit.to_i
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 10})
else
@limit = 10#per_page_option
end
@assign_to_id = params[:assigned_to_id]
@author_id = params[:author_id]
@ -84,9 +84,9 @@ class IssuesController < ApplicationController
@issue_pages = Paginator.new @issue_count, @limit, params['page']
@offset ||= @issue_pages.offset
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
:order => sort_clause,
:offset => @offset,
:limit => @limit)
:order => sort_clause,
:offset => @offset,
:limit => @limit)
@issue_count_by_group = @query.issue_count_by_group
respond_to do |format|
format.js
@ -143,16 +143,16 @@ class IssuesController < ApplicationController
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
respond_to do |format|``
format.html {
retrieve_previous_and_next_issue_ids
render :template => 'issues/show', :layout => @project_base_tag#by young
}
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf {
pdf = issue_to_pdf(@issue, :journals => @journals)
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
}
format.html {
retrieve_previous_and_next_issue_ids
render :template => 'issues/show', :layout => @project_base_tag#by young
}
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf {
pdf = issue_to_pdf(@issue, :journals => @journals)
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
}
end
end
@ -322,8 +322,8 @@ class IssuesController < ApplicationController
issue.reload
if @copy
issue = issue.copy({},
:attachments => params[:copy_attachments].present?,
:subtasks => params[:copy_subtasks].present?
:attachments => params[:copy_attachments].present?,
:subtasks => params[:copy_subtasks].present?
)
end
journal = issue.init_journal(User.current, params[:notes])
@ -353,21 +353,21 @@ class IssuesController < ApplicationController
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
if @hours > 0
case params[:todo]
when 'destroy'
# nothing to do
when 'nullify'
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
when 'reassign'
reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
if reassign_to.nil?
flash.now[:error] = l(:error_issue_not_found_in_project)
return
when 'destroy'
# nothing to do
when 'nullify'
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
when 'reassign'
reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
if reassign_to.nil?
flash.now[:error] = l(:error_issue_not_found_in_project)
return
else
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
end
else
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
end
else
# display the destroy form if it's a user request
return unless api_request?
# display the destroy form if it's a user request
return unless api_request?
end
end
@issues.each do |issue|
@ -435,14 +435,14 @@ class IssuesController < ApplicationController
issue_attributes = params[:issue]
if issue_attributes && params[:conflict_resolution]
case params[:conflict_resolution]
when 'overwrite'
issue_attributes = issue_attributes.dup
issue_attributes.delete(:lock_version)
when 'add_notes'
issue_attributes = issue_attributes.slice(:notes)
when 'cancel'
redirect_to issue_url(@issue)
return false
when 'overwrite'
issue_attributes = issue_attributes.dup
issue_attributes.delete(:lock_version)
when 'add_notes'
issue_attributes = issue_attributes.slice(:notes)
when 'cancel'
redirect_to issue_url(@issue)
return false
end
end
@issue.safe_attributes = issue_attributes

View File

@ -3,13 +3,45 @@ class StudentWorkController < ApplicationController
include StudentWorkHelper
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
protect_from_forgery :except => :set_program_score
###
def program_test
resultObj = {status: 0, results: [], error_msg: '', time: Time.now}
student_work = find_or_save_student_work
unless student_work
resultObj[:status] = 100
else
if @homework.homework_type == 2 && @homework.homework_detail_programing
result = test_realtime(student_work, params[:src])
logger.debug result
resultObj[:status] = result["status"]
resultObj[:results] = result["results"]
resultObj[:error_msg] = result["error_msg"]
results = result["results"]
if result["status"].to_i == -2 #编译错误
results = [result["error_msg"]]
end
student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
src: params[:src])
unless student_work.save
resultObj[:status] = 200
else
resultObj[:status] = result["status"].to_i
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
end
end
end
render :json => resultObj
end
def index
#设置作业对应的forge_messages表的viewed字段
query_student_work = @homework.course_messages
@ -102,20 +134,16 @@ class StudentWorkController < ApplicationController
end
def new
student_work = @homework.student_works.where("user_id = ?",User.current.id).first
if student_work.nil?
@stundet_work = StudentWork.new
respond_to do |format|
format.html
end
else
render_403
@student_work = @homework.student_works.where("user_id = ?",User.current.id).first
if @student_work.nil?
@student_work = StudentWork.new
end
end
def create
if params[:student_work]
stundet_work = StudentWork.new
stundet_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
stundet_work ||= StudentWork.new
stundet_work.name = params[:student_work][:name]
stundet_work.description = params[:student_work][:description]
stundet_work.project_id = params[:student_work][:project_id]
@ -128,23 +156,9 @@ class StudentWorkController < ApplicationController
stundet_work.late_penalty = 0
end
render_attachment_warning_if_needed(stundet_work)
if stundet_work.save
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
solutions = {
student_work_id:stundet_work.id,
src:Base64.encode64(stundet_work.description),
language:@homework.homework_detail_programing.language
}
uri = URI(url)
body = solutions.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
end
respond_to do |format|
format.html {
@ -584,4 +598,44 @@ class StudentWorkController < ApplicationController
book.write xls_report
xls_report.string
end
def find_or_save_student_work
student_work = @homework.student_works.where(user_id: User.current.id).first
if student_work.nil?
@homework.student_works.build(
name: params[:title],
description: params[:src],
user_id: User.current.id
)
unless @homework.save
else
student_work = @homework.student_works.where(user_id: User.current.id).first
end
end
student_work
end
def test_realtime(student_work, src)
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
factor = []
@homework.homework_tests.each do |test|
factor << {input: test.input, output: test.output}
end
solutions = {
src:src,
language:@homework.homework_detail_programing.language,
factor: factor
}
uri = URI(url)
body = solutions.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
JSON.parse(res.body)
end
end

View File

@ -41,12 +41,12 @@ class UsersController < ApplicationController
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource]
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -223,7 +223,7 @@ class UsersController < ApplicationController
end
# end
##added by fq
##added by fq
def watch_bids
# cond = 'bids.reward_type <> 1'
# @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
@ -286,7 +286,7 @@ class UsersController < ApplicationController
unless User.current.admin?
if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?)
render_404
return
return
end
end
@ -347,6 +347,24 @@ class UsersController < ApplicationController
end
end
def new_user_commit_homework
@user = User.current
@homework = HomeworkCommon.find(params[:homework_id])
@student_work = @homework.student_works.where(user_id: User.current.id).first
if @student_work.nil?
@student_work = StudentWork.new
end
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}
end
end
def user_commit_homework
flash[:notice] = l(:notice_successful_create)
redirect_to user_homeworks_user_path(User.current)
end
def user_new_homework
if params[:homework_common]
homework = HomeworkCommon.new
@ -354,7 +372,7 @@ class UsersController < ApplicationController
homework.description = params[:homework_common][:description]
homework.end_time = params[:homework_common][:end_time] || Time.now
homework.publish_time = Time.now
homework.homework_type = 1
homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 2
homework.user_id = User.current.id
homework.course_id = params[:course_id]
@ -363,17 +381,36 @@ class UsersController < ApplicationController
render_attachment_warning_if_needed(homework)
#匿评作业相关属性
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
homework_detail_manual.comment_status = 1
homework_detail_manual.evaluation_start = Time.now
homework_detail_manual.evaluation_end = Time.now
homework_detail_manual.evaluation_num = params[:evaluation_num] || 3
homework_detail_manual.absence_penalty = 2
homework.homework_detail_manual = homework_detail_manual
if homework.homework_type == 1
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
homework_detail_manual.comment_status = 1
homework_detail_manual.evaluation_start = Time.now
homework_detail_manual.evaluation_end = Time.now
homework_detail_manual.evaluation_num = params[:evaluation_num] || 3
homework_detail_manual.absence_penalty = 2
homework.homework_detail_manual = homework_detail_manual
else
homework_detail_programing = HomeworkDetailPrograming.new
homework.homework_detail_programing = homework_detail_programing
homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
homework_detail_programing.language = params[:program][:language].to_i
inputs = params[:program][:input]
if Array === inputs
inputs.each_with_index do |val, i|
homework.homework_tests << HomeworkTest.new(
input: val,
output: params[:program][:output][i]
)
end
end
end
if homework.save
homework_detail_manual.save if homework_detail_manual
homework_detail_programing.save if homework_detail_programing
redirect_to user_homeworks_user_path(User.current.id)
end
end
@ -406,18 +443,18 @@ class UsersController < ApplicationController
return
end
if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc")
elsif params[:type] == "3" #项目资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
elsif params[:type] == "4" #附件
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
elsif params[:type] == "5" #用户资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
end
@type = params[:type]
@limit = 7
@ -437,18 +474,18 @@ class UsersController < ApplicationController
def user_ref_resource_search
search = params[:search].to_s.strip.downcase
if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "3" #项目资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
elsif params[:type] == "4" #附件
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
elsif params[:type] == "5" #用户资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
end
@type = params[:type]
@limit = 7
@ -466,20 +503,20 @@ class UsersController < ApplicationController
#将资源批量引入
def import_resources_to_homework
@attachments = []
unless params[:checkbox1].nil? || params[:checkbox1].blank?
params[:checkbox1].each do |id|
atta = Attachment.find(id)
att_copy = atta.copy
att_copy.container_id = nil
att_copy.container_type = nil
att_copy.copy_from = atta.id
att_copy.save
@attachments << att_copy
end
end
respond_to do |format|
format.js
unless params[:checkbox1].nil? || params[:checkbox1].blank?
params[:checkbox1].each do |id|
atta = Attachment.find(id)
att_copy = atta.copy
att_copy.container_id = nil
att_copy.container_type = nil
att_copy.copy_from = atta.id
att_copy.save
@attachments << att_copy
end
end
respond_to do |format|
format.js
end
end
@ -529,16 +566,16 @@ class UsersController < ApplicationController
sort_update %w(login firstname lastname mail admin created_on last_login_on)
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})
else
@limit = 15
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})
else
@limit = 15
end
# retrieve all users
# 先内连一下statuses 保证排序之后数量一致
scope = User.visible.
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
# unknow
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
@ -549,29 +586,29 @@ class UsersController < ApplicationController
# users classify
case params[:user_sort_type]
when '0'
# 创建时间排序
@s_type = 0
@users = scope.reorder('users.created_on DESC')
when '1'
# 活跃度排序, 就是所谓的得分情况
@s_type = 1
@users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
when '2'
# 粉丝数排序
@s_type = 2
@users = scope.
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
reorder('user_statuses.watchers_count DESC')
when '0'
# 创建时间排序
@s_type = 0
@users = scope.reorder('users.created_on DESC')
when '1'
# 活跃度排序, 就是所谓的得分情况
@s_type = 1
@users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
when '2'
# 粉丝数排序
@s_type = 2
@users = scope.
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
reorder('user_statuses.watchers_count DESC')
else
# 默认活跃度排序
@s_type = 1
@users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
else
# 默认活跃度排序
@s_type = 1
@users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
end
# limit and offset
@ -591,20 +628,20 @@ class UsersController < ApplicationController
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
(redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
case params[:format]
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})
else
@limit = 15#per_page_option
end
#
#@status = params[:status] || 1
#has = {
# "show_changesets" => true
#}
# scope = User.logged.status(@status)
# @search_by = params[:search_by] ? params[:search_by][:id] : 0
# scope = scope.like(params[:name],@search_by) if params[:name].present?
end
#
#@status = params[:status] || 1
#has = {
# "show_changesets" => true
#}
# scope = User.logged.status(@status)
# @search_by = params[:search_by] ? params[:search_by][:id] : 0
# scope = scope.like(params[:name],@search_by) if params[:name].present?
@search_by = params[:search_by] ? params[:search_by] : 0
us = UsersService.new
@ -637,13 +674,13 @@ class UsersController < ApplicationController
def user_courses4show
@page = params[:page].to_i + 1
@courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
end
end
#显示更多用户项目
def user_projects4show
@page = params[:page].to_i + 1
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5)
end
end
def user_course_activities
lastid = nil
@ -741,7 +778,7 @@ class UsersController < ApplicationController
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10)
else
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10)
end
end
else
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10)
end
@ -759,124 +796,124 @@ class UsersController < ApplicationController
# Author lizanle
# Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复
case params[:type]
when "1"
if @user == User.current
activity = Activity.where('user_id = ?', User.current.id).order('id desc')
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all
@state = 1
end
when "2"
message = []
if @user == User.current
message = JournalsForMessage.reference_message(@user.id)
message += Journal.reference_message(@user.id)
end
@activity_count = message.size
@info_pages = Paginator.new @activity_count, pre_count, params['page']
messages = message.sort {|x,y| y.created_on <=> x.created_on }
@message = messages[@info_pages.offset, @info_pages.per_page]
@state = 2
when "1"
if @user == User.current
activity = Activity.where('user_id = ?', User.current.id).order('id desc')
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all
@state = 1
end
when "2"
message = []
if @user == User.current
message = JournalsForMessage.reference_message(@user.id)
message += Journal.reference_message(@user.id)
end
@activity_count = message.size
@info_pages = Paginator.new @activity_count, pre_count, params['page']
messages = message.sort {|x,y| y.created_on <=> x.created_on }
@message = messages[@info_pages.offset, @info_pages.per_page]
@state = 2
else
# Time 2015-02-04 10:50:49
# Author lizanle
# Description 所有动态
where_condition = nil;
# where_condition = "act_type <> 'JournalsForMessage'"
user_ids = []
if @user == User.current
watcher = User.watched_by(@user)
watcher.push(User.current)
user_ids = watcher.map{|x| x.id}
else
user_ids << @user.id
end
activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc')
permission = !User.current.admin?
if permission
#Issue
act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id}
project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
# Time 2015-02-04 10:50:49
# Author lizanle
# Description 所有动态
where_condition = nil;
# where_condition = "act_type <> 'JournalsForMessage'"
user_ids = []
if @user == User.current
watcher = User.watched_by(@user)
watcher.push(User.current)
user_ids = watcher.map{|x| x.id}
else
user_ids << @user.id
end
ids = []
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc')
#HomeworkCommon
act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id}
course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: course_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
permission = !User.current.admin?
if permission
#Issue
act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id}
project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids = []
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
#HomeworkCommon
act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id}
course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: course_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id}
#Journal
act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id}
project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id}
#News
act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id}
project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
#Message
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
logger.debug "filter ids #{ids}"
activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty?
end
ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id}
#Journal
act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id}
project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id}
# activity = activity.reject { |e|
# e.act.nil? ||
# (!User.current.admin? && !e.act.nil?
# (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
# (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# }
#
#News
act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id}
project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
#Message
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
logger.debug "filter ids #{ids}"
activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty?
end
# activity = activity.reject { |e|
# e.act.nil? ||
# (!User.current.admin? && !e.act.nil?
# (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
# (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# }
#
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
@state = 0
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
@state = 0
end
if params[:user].present?
@ -904,7 +941,7 @@ class UsersController < ApplicationController
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
# redirect_to home_path
render_404
return
return
end
end
@ -936,7 +973,7 @@ class UsersController < ApplicationController
unless User.current.admin?
if !@user.active?
render_404
return
return
end
end
@ -994,7 +1031,7 @@ class UsersController < ApplicationController
unless @user.id.nil?
#后台注册的用户默认权限为男性开发员
ue = UserExtensions.create(:identity => 3,
:gender => 0,
:gender => 0,
:user_id => @user.id)
ue.save
end
@ -1064,7 +1101,7 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
#@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal
Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
if(params[:type].blank?|| params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@ -1120,10 +1157,10 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete
if params[:resource_id].present?
Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id])
Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id])
elsif params[:checkbox1].present?
params[:checkbox1].each do |id|
Attachment.where("author_id = #{User.current.id}").delete(id)
params[:checkbox1].each do |id|
Attachment.where("author_id = #{User.current.id}").delete(id)
end
end
@ -1174,17 +1211,17 @@ class UsersController < ApplicationController
@offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25
respond_to do |format|
format.js
end
respond_to do |format|
format.js
end
end
#根据id或者名称搜索教师或者助教为当前用户的课程
def search_user_course
@user = User.current
if !params[:search].nil?
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'")
.select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'")
.select { |course| @user.allowed_to?(:as_teacher,course)}
else
@course = @user.courses
.select { |course| @user.allowed_to?(:as_teacher,course)}
@ -1216,28 +1253,28 @@ class UsersController < ApplicationController
# 将资源发送到对应的课程,分为发送单个,或者批量发送
def add_exist_file_to_course
@flag = true
if params[:send_id].present?
if params[:send_id].present?
send_id = params[:send_id]
ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids]
if course_ids.nil?
@flag = false
end
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages
end
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages
end
end
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
course_ids = params[:course_ids]
@ -1264,7 +1301,7 @@ class UsersController < ApplicationController
end
end
else
@flag = false
@flag = false
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1353,15 +1390,15 @@ class UsersController < ApplicationController
# 资源预览
def resource_preview
preview_id = params[:resource_id]
@file = Attachment.find(preview_id)
@preview_able = false;
if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)}
@preview_able = true;
end
respond_to do |format|
format.js
end
preview_id = params[:resource_id]
@file = Attachment.find(preview_id)
@preview_able = false;
if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)}
@preview_able = true;
end
respond_to do |format|
format.js
end
end
# 重命名资源
@ -1401,7 +1438,7 @@ class UsersController < ApplicationController
def destroy_membership
@membership = Member.find(params[:membership_id])
if @membership.deletable?
@membership.destroy
@membership.destroy
end
respond_to do |format|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
@ -1416,31 +1453,31 @@ class UsersController < ApplicationController
@obj_flag = params[:tag_for_save][:object_flag]
case @obj_flag
when '1' then
@obj = User.find_by_id(@obj_id)
when '2' then
@obj = Project.find_by_id(@obj_id)
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
# @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'
@obj = Attachment.find_by_id(@obj_id)
when '7' then
@obj = Contest.find_by_id(@obj_id)
when '8'
@obj = OpenSourceProject.find_by_id(@obj_id)
when '9'
@obj = Course.find_by_id(@obj_id)
else
@obj = nil
when '1' then
@obj = User.find_by_id(@obj_id)
when '2' then
@obj = Project.find_by_id(@obj_id)
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
# @obj = Bid.find_by_id(@obj_id)
when '5' then
@obj = Forum.find_by_id(@obj_id)
when '6'
@obj = Attachment.find_by_id(@obj_id)
when '7' then
@obj = Contest.find_by_id(@obj_id)
when '8'
@obj = OpenSourceProject.find_by_id(@obj_id)
when '9'
@obj = Course.find_by_id(@obj_id)
else
@obj = nil
end
unless @obj.nil?
@obj.tag_list.add(@tags.split(","))
else
return
return
end
if @obj.save
logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}"
@ -1531,9 +1568,9 @@ class UsersController < ApplicationController
def update_extensions(user_extensions)
user_extensions = params[:user_extensions]
unless user_extensions.nil?
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
# user_extensions.
# user_extensions.
end
end
@ -1624,9 +1661,9 @@ class UsersController < ApplicationController
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+
" or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" +
" and (filename like '%#{search}%') ").order("created_on desc")
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+
" or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" +
" and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
@ -1635,7 +1672,7 @@ class UsersController < ApplicationController
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
" and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "3" #项目资源

View File

@ -2337,7 +2337,7 @@ module ApplicationHelper
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
def user_for_homework_common homework,is_teacher
if is_teacher #老师显示作品数量
link_to "提交#{homework.student_works.count}",student_work_index_path(:homework => homework.id),:class => "c_blue"
link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue"
else #学生显示提交作品、修改作品等按钮
work = cur_user_works_for_homework homework
if work.nil?

View File

@ -71,7 +71,7 @@ module UsersHelper
def user_settings_tabs
tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
{:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
]
]
if Group.all.any?
tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
end
@ -83,7 +83,7 @@ module UsersHelper
def get_users_by_tag(tag_name)
User.tagged_with(tag_name).order('updated_on desc')
end
# added by fq
# <div class="pagination" >
# <ul>
@ -91,7 +91,7 @@ module UsersHelper
# <li><%= link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}) %></li>
# <li><%= link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}) %></li>
# </ul></div>
# TODO: 待删
# def show_activity(state)
# content = ''.html_safe
@ -114,19 +114,19 @@ module UsersHelper
# end
# content_tag('div', content, :class => "pagination")
# end
#TODO: 待删
def watch_projects(state)
content = ''.html_safe
case state
when 0
s = content_tag('span', l(:label_project_take), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
when 1
s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
content << content_tag('li', s, :class => "current-page")
when 0
s = content_tag('span', l(:label_project_take), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
when 1
s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
content << content_tag('li', s, :class => "current-page")
end
content_tag('div', content, :class => "pagination")
end
@ -134,59 +134,59 @@ module UsersHelper
def user_course(state)
content = ''.html_safe
if @user != User.current
if @user.user_extensions.identity == 0
if @user.user_extensions.identity == 0
case state
when 0
s = content_tag('span', '他执教的课程', :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '他发布的作业', :class => "current-page")
content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
when 0
s = content_tag('span', '他执教的课程', :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '他发布的作业', :class => "current-page")
content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
else
else
case state
when 0
s = content_tag('span', '他的课程', :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '他的作业', :class => "current-page")
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
when 0
s = content_tag('span', '他的课程', :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '他的作业', :class => "current-page")
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
end
else
if @user.user_extensions.identity == 0
if @user.user_extensions.identity == 0
case state
when 0
s = content_tag('span', l(:label_teaching_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', l(:label_release_homework), :class => "current-page")
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
when 0
s = content_tag('span', l(:label_teaching_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', l(:label_release_homework), :class => "current-page")
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
else
else
case state
when 0
s = content_tag('span', l(:label_my_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '我的作业', :class => "current-page")
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
when 0
s = content_tag('span', l(:label_my_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '我的作业', :class => "current-page")
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
end
end
@ -196,42 +196,42 @@ module UsersHelper
def sort_user(state, project_type)
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
end
def sort_user_enterprise(state, project_type)
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise")
end
end
def gender_avatar_uri user
img_uri = '/images/sidebar/female.png'
@ -256,7 +256,7 @@ module UsersHelper
# people_ids += (members_to_user_ids(tmp)) unless tmp.nil?
# end
# people_ids.include?(login_user.id) or (login_user == user) or login_user.admin?
false
end
@ -290,7 +290,7 @@ module UsersHelper
membership.collect { |e|
memberships.push(e)
}
## 判断课程是否过期 [需封装]
## 判断课程是否过期 [需封装]
memberships_doing = []
memberships_done = []
memberships.map { |e|
@ -546,7 +546,7 @@ module UsersHelper
type = []
user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
option = []
option << course.name
option << course.name+""+course.time.to_s+course.term+""
option << course.id
type << option
end

View File

@ -56,4 +56,6 @@ class HomeworkCommon < ActiveRecord::Base
Mailer.run.homework_added(self)
end
delegate :language_name, :to => :homework_detail_programing
end

View File

@ -2,4 +2,8 @@ class HomeworkDetailPrograming < ActiveRecord::Base
attr_accessible :language, :standard_code, :homework_common_id
belongs_to :homework_common
def language_name
%W(c c++).at(self.language.to_i - 1)
end
end

View File

@ -2,5 +2,4 @@ class HomeworkTest < ActiveRecord::Base
attr_accessible :input, :output, :homework_common_id,:result,:error_msg
belongs_to :homework_common
has_many :student_work_test
end

View File

@ -7,7 +7,7 @@ class StudentWork < ActiveRecord::Base
has_many :student_works_evaluation_distributions, :dependent => :destroy
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
has_many :student_work_test
has_many :student_work_tests, order: 'id desc'
before_destroy :delete_praise

View File

@ -1,12 +1,12 @@
# encoding: utf-8
class StudentWorkTest < ActiveRecord::Base
attr_accessible :student_work_id, :homework_test_id, :result, :error_msg
belongs_to :homework_test
attr_accessible :student_work_id, :results, :status, :src
belongs_to :student_work
serialize :results, Array
def status_to_s
case self.result.to_i
case self.status.to_i
when -1
'编译出错'
when -2
@ -33,10 +33,11 @@ class StudentWorkTest < ActiveRecord::Base
end
def test_score
if self.result.to_i == 0
if self.status.to_i == 0
format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
else
0
end
end
end

View File

@ -1,3 +1,3 @@
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
init_KindEditor_data(<%= @user_activity_id%>);
init_KindEditor_data('<%= @user_activity_id%>');

View File

@ -0,0 +1,74 @@
<div class="homepageRight">
<div class="HomeWork">
<div class="RightBanner">
<div class="NewsBannerName">发布作业</div>
</div>
<div class="HomeWorkCon">
<div class="mt15">
<textarea class="InputBox W700 " placeholder="请输入作业标题" name="homework_common[name]" id="homework_name" maxlength="255" onkeyup="regex_homework_name();" value="<%= homework.name%>"></textarea>
</div>
<div class=" mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl mr10">导入作业</a>
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 date-input" readonly="readonly" value="<%= homework.end_time%>" placeholder="截止日期"></input>
<div class="fl DateBorder mr10"><a href="javascript:void(0);" class="pic_date"></a></div>
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" class="InputBox fl W120 date-input" readonly="readonly" value="<%= homework.publish_time%>" placeholder="发布日期"></input>
<div class="fl DateBorder"><a href="javascript:void(0);" class="pic_date"></a></div>
<div class="cl"></div>
</div>
<div class="mt10">
<% if edit_mode %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
<% else %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :description,:editor_id => 'homework_description_editor' %>
<% end %>
</div>
<div class="mt10">
<textarea class="InputBox W700 SearchIcon" placeholder="发送到课程" style="margin-top: 0px; margin-bottom: 0px; height: 29px;"></textarea>
</div>
<div class="mt5">
<a href="javascript:void(0);" class="AnnexBtn fl mt3">上传附件</a>
<a href="javascript:void(0);" class="FilesBtn fl mr15 mt3">资源库</a>
<div class="cl"></div>
</div>
<div class="mt10">
<a href="javascript:void(0);" class=" fl DropBtn">高级功能</a>
<div class="DropLine"></div>
<div class="cl"></div>
</div>
<div class="advanced_option" style="display:none;">
<div class="mt10">
<select class="InputBox W120" required="true">
<option value="语言选择">语言选择</option>
<option value="C语言">C语言</option>
<option value="C++">C++</option>
</select>
</div>
<div class="mt10">
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
<div class="cl"></div>
</div>
</div>
<div class="mt10">
<a href="javascript:void(0);" onClick="submit_homework('new_homework_common');" class="BlueCirBtnMini fr">发布</a>
<span class="fr mr10 mt3">或</span><%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'fr mr10 mt3'%>
<div class="cl"></div>
</div>
</div>
</div><!----HomeWork end-->
</div>
<script id="t:test-answer-list" type="text/html">
<div class="mt10">
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
<div class="cl"></div>
</div>
</script>

View File

@ -1,17 +1,16 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<% content_for :header_tags do %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<%#= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<%= render :partial => 'homework_common/new_homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>

View File

@ -1,4 +1,4 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">

View File

@ -101,9 +101,9 @@
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a>
<% if is_current_user%>
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
<%=link_to image_tag("../images/menu_setting.png",width:"14px", height: "14px",class: "homepageMenuSetting fr",title: "新建课程"), new_course_path%>
<%=link_to "", new_course_path, :class => "homepageMenuSetting fr"%>
<% else%>
<%=link_to image_tag("../images/menu_setting.png",width:"14px", height: "14px",class: "homepageMenuSetting fr", title:"加入课程"), join_private_courses_courses_path ,:remote => true%>
<%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true%>
<% end%>
<% end%>
</div>
@ -117,7 +117,7 @@
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuForge').slideToggle();">项目</a>
<% if is_current_user%>
<%=link_to image_tag("../images/menu_setting.png",width:"14px", height: "14px",class: "homepageMenuSetting fr",title:"新建项目"), new_project_path%>
<%=link_to "", new_project_path, :class => "homepageMenuSetting fr"%>
<% end%>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuForge">

View File

@ -1,3 +1,8 @@
<% content_for :header_tags do %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<% if @homework.homework_type == 1 %>
<script type="text/javascript">
<%if @homework.homework_type == 1 && @homework.homework_detail_manual.comment_status != 1%>
$(function(){
@ -18,7 +23,7 @@
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= form_for(@stundet_work,
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
@ -80,4 +85,122 @@
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
<div class="cl"></div>
<% else %>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<!}else{!>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><!=results[i]["result"]!></span>
<span class="w60">正确输出:</span>
<span class="W200"><!=results[i]["output"]!></span>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
<div class="homepageRight">
<div class="HomeWork">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="HomeWorkBox">
<div class="">
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
<div class="cl"></div>
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
<p class="HomeWorkP"><%= @homework.description %> <br />
输入 2 1 1 4 4 2 3 6 5 <br />
输出 15<br />
</p>
</div>
<p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p>
</div><!---HomeWorkBox end -->
<div class="HomeWorkCon">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:student_work_id => @student_work.id,
:homework => @homework.id
},
:method => :post) do |f|%>
<div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span>
</div>
<div class="mt10">
<%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %>
</div>
<div class="mt10">
<%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"请贴入你的代码", rows: 10 %>
</div>
<div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<div class="cl"></div>
</div>
<% end %>
</div><!----HomeWorkCon end-->
</div><!----HomeWork end-->
<div class="ProResult mt10">
<% @student_work.student_work_tests.each_with_index do |test, index| %>
<div class="ProResultTop">
<p class="c_blue fl">第<%= @student_work.student_work_tests.count - index%>次测试</p><span class="fr c_grey"><%= test.created_at.to_s(:db) %></span>
<div class="cl"></div>
</div>
<% if test.status.to_i == -2 %>
<div class="ProResultCon "><%= test.results.first %></div>
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><%=x["result"]%></span>
<span class="w60">正确输出:</span>
<span class="W200"><%=x["output"]%></span>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div><!----ProResult end-->
</div><!--homepageRight end-->
<% end %>

View File

@ -1,108 +1,108 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<% if activity.try(:author).try(:realname) == ' ' %>
<%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% else %>
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% end %>
TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%>
</div>
<div class="homepagePostTitle break_word">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%>
<% end %>
</div>
<div class="homepagePostDate">
发帖时间:<%= format_date(activity.created_on) %>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%>
<% else %>
<%= activity.parent.content.to_s.html_safe%>
<% end %>
</div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<% if activity.try(:author).try(:realname) == ' ' %>
<%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% else %>
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% end %>
TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%>
</div>
<div class="homepagePostTitle break_word">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%>
<% end %>
</div>
<div class="homepagePostDate">
发帖时间:<%= format_date(activity.created_on) %>
</div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<% count=0 %>
<div class="homepagePostReplyBannerCount">回复(
<% if activity.parent_id.nil? %>
<% count=activity.replies_count%>
<%=count %>
<% else %>
<% count=activity.parent.replies_count%>
<%=count %>
<% end %>
)</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>2 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
点击展开更多回复(<%= count.to_s%>)
</a>
</div>
<% end %>
</div>
<div class="homepagePostReplyInputContainer">
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
<input type="hidden" name="quote[quote]" value="">
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%>
<% else %>
<%= activity.parent.content.to_s.html_safe%>
<% end %>
</div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<% count=0 %>
<div class="homepagePostReplyBannerCount">回复(
<% if activity.parent_id.nil? %>
<% count=activity.replies_count%>
<%=count %>
<% else %>
<% count=activity.parent.replies_count%>
<%=count %>
<% end %>
)</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>2 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
点击展开更多回复(<%= count.to_s%>)
</a>
</div>
<div class="cl"></div>
</div>
<% end %>
</div>
<% activity= activity.parent_id.nil? ? activity:activity.parent%>
<% replies_all_i = 0 %>
<% unless activity.children.empty? %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply|%>
<% replies_all_i=replies_all_i+1 %>
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>2 ? 'none' : '' %>">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %>
</div>
<div class="homepagePostReplyDes">
<div class="homepagePostReplyPublisher">
<% if reply.try(:author).try(:realname) == ' ' %>
<%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% else %>
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_date(reply.created_on) %>
<%#= link_to(
<div class="homepagePostReplyInputContainer">
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
<input type="hidden" name="quote[quote]" value="">
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
</div>
<div class="cl"></div>
</div>
<% activity= activity.parent_id.nil? ? activity:activity.parent%>
<% replies_all_i = 0 %>
<% unless activity.children.empty? %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply|%>
<% replies_all_i=replies_all_i+1 %>
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>2 ? 'none' : '' %>">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %>
</div>
<div class="homepagePostReplyDes">
<div class="homepagePostReplyPublisher">
<% if reply.try(:author).try(:realname) == ' ' %>
<%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% else %>
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_date(reply.created_on) %>
<%#= link_to(
l(:button_delete),
{:controller => 'messages', :action => 'destroy', :id => reply.id, :board_id => reply.board_id, :is_board => 'false'},
:method => :post,
@ -110,15 +110,15 @@
:title => l(:button_delete),
:class => 'replyGrey fr ml10'
) if reply.course_destroyable_by?(User.current) %>
<!--<a href="javascript:void(0);" class="replyGrey fr ml10">删除</a>-->
</div>
<div class="homepagePostReplyContent break_word"><%= reply.content.html_safe %></div>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</div>
<!--<a href="javascript:void(0);" class="replyGrey fr ml10">删除</a>-->
</div>
<div class="homepagePostReplyContent break_word"><%= reply.content.html_safe %></div>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</div>

View File

@ -84,6 +84,6 @@
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div>
</div>

View File

@ -11,7 +11,7 @@
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% end %> TO
<%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%>
</div>
</div>
<div class="homepagePostTitle break_word">
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %>
<span class='<%= get_issue_priority(activity.priority_id)[0] %>'><%= get_issue_priority(activity.priority_id)[1] %></span>
@ -19,11 +19,11 @@
<div class="homepagePostSubmitContainer">
<div class="homepagePostAssignTo">指派给&nbsp;&nbsp;
<% unless activity.assigned_to_id.nil? %>
<% if activity.try(:assigned_to).try(:realname) == ' ' %>
<%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% else %>
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% end %>
<% if activity.try(:assigned_to).try(:realname) == ' ' %>
<%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% else %>
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% end %>
<% end %>
</div>
<div class="homepagePostDeadline">时间:<%=format_date(activity.created_on) %></div>
@ -37,21 +37,21 @@
<div class="mt10" style="font-weight:normal;">
<% if activity.attachments.any? %>
<% activity.attachments.each do |attachment| %>
<div class="break_word">
<div class="break_word">
<span title="<%= attachment.filename %>" id="attachment_">
<%= link_to_short_attachment attachment,:length=> 58, :class => 'homepagePostFileAtt newsBlue', :download => true -%>
</span>
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments',
:action => 'show',
:id => attachment,
:filename => attachment.filename %>
<% end %>
<span class="postAttSize">(
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments',
:action => 'show',
:id => attachment,
:filename => attachment.filename %>
<% end %>
<span class="postAttSize">(
<%= number_to_human_size attachment.filesize %>)
</span>
</div>
</div>
<% end %>
<% end %>
</div>
@ -110,7 +110,7 @@
<div class="homepagePostReplyPublisher">
<% if reply.try(:user).try(:realname) == ' ' %>
<%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
<% else %>
<% else %>
<%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_date(reply.created_on) %>

View File

@ -1,25 +1,25 @@
<% if attachments.nil? || attachments.empty? %>
<!--<p class="nodata">-->
<!--<%#= l(:label_no_data) %>-->
<!--</p>-->
<!--<p class="nodata">-->
<!--<%#= l(:label_no_data) %>-->
<!--</p>-->
<% else %>
<% attachments.each do |attach| %>
<ul class="resourcesList">
<li class="resourcesListCheckbox fl">
<input name="checkbox1[]" type="checkbox" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
</li>
<li class="resourcesListName fl">
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
<%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename),
:title => attach.filename,:class=>'resourcesBlack'%>
</li>
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li style="display: none"><%= attach.author_id %></li>
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
<li style="display: none"><%= attach.id %></li>
</ul>
<% end %>
<ul class="resourcesList">
<li class="resourcesListCheckbox fl">
<input name="checkbox1[]" type="checkbox" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
</li>
<li class="resourcesListName fl">
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
<%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename),
:title => attach.filename,:class=>'resourcesBlack'%>
</li>
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li style="display: none"><%= attach.author_id %></li>
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
<li style="display: none"><%= attach.id %></li>
</ul>
<% end %>
<% end %>

View File

@ -8,6 +8,7 @@
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
.ke-inline-block{display: none;}
</style>
<% user_activities.each do |user_activity|
if user_activities %>
@ -59,4 +60,5 @@
<% end %>
<% end %>
<% end %>
<input type="hidden" value="<%= page%>" id="show_more_activities" />
<input type="hidden" value="<%= page%>"/>
<%= link_to "点击展开更多",user_activities_path(@user.id),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>

View File

@ -1,4 +1,8 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<% content_for :header_tags do %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<div class="HomeWorkCon">
<div>
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox w712" maxlength="255" onfocus="$('#homework_editor').show()" onkeyup="regex_homework_name();" placeholder="请输入作业标题" value="<%= homework.name%>" >
@ -35,11 +39,53 @@
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework} %>
</div>
<div class="mt5 fr">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick=" submit_homework('new_homework_common');">发送</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
</div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick=" submit_comm_homework('new_homework_common');">发送</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="reset_homework();">取消</a>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="mt10">
<a href="javascript:void(0);" class=" fl DropBtn">编程选项</a>
<div class="DropLine"></div>
<div class="cl"></div>
</div>
<div class="advanced_option" style="display:none;">
<div class="mt10">
<select class="InputBox W120" required="true" name="program[language]">
<option value="1" selected>C语言</option>
<option value="2">C++</option>
</select>
</div>
<div class="mt10">
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required name="program[input][]"></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required name="program[output][]"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<div class="cl"></div>
</div>
</div>
<input type="hidden" name="homework_type" value="1">
</div>
</div>
<div class="cl"></div>
<script type="text/javascript">
$(function (){
$("#course_id").append("<option value='-1' id='option_select' hidden selected>请选择发布作业的课程</option>");
});
</script>
<script id="t:test-answer-list" type="text/html">
<div class="mt10">
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required name="program[input][]"></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required name="program[output][]"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
<div class="cl"></div>
</div>
</script>

View File

@ -53,4 +53,5 @@
</div><!----HomeWork end-->
<% end%>
<input type="hidden" value="<%= page%>" id="user_show_more_homework" />
<input type="hidden" value="<%= page%>" />
<%= link_to "加载更多",user_homeworks_user_path(User.current.id),:id => "user_show_more_homework",:remote => "true",:class => "loadMore mt10 f_grey"%>

View File

@ -0,0 +1,117 @@
<% content_for :header_tags do %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<!}else{!>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><!=results[i]["result"]!></span>
<span class="w60">正确输出:</span>
<span class="W200"><!=results[i]["output"]!></span>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
<div class="homepageRight">
<div class="HomeWork">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="HomeWorkBox">
<div class="">
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
<div class="cl"></div>
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
<p class="HomeWorkP"><%= @homework.description %> <br />
输入 2 1 1 4 4 2 3 6 5 <br />
输出 15<br />
</p>
</div>
<p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p>
</div><!---HomeWorkBox end -->
<div class="HomeWorkCon">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'users',
:action => 'user_commit_homework',
:student_work_id => @student_work.id,
:homework => @homework.id
},
:method => :post) do |f|%>
<div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span>
</div>
<div class="mt10">
<%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %>
</div>
<div class="mt10">
<%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"请贴入你的代码", rows: 10 %>
</div>
<div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<div class="cl"></div>
</div>
<% end %>
</div><!----HomeWorkCon end-->
</div><!----HomeWork end-->
<div class="ProResult mt10">
<% @student_work.student_work_tests.each_with_index do |test, index| %>
<div class="ProResultTop">
<p class="c_blue fl">第<%= @student_work.student_work_tests.count - index%>次测试</p><span class="fr c_grey"><%= test.created_at.to_s(:db) %></span>
<div class="cl"></div>
</div>
<% if test.status.to_i == -2 %>
<div class="ProResultCon "><%= test.results.first %></div>
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><%=x["result"]%></span>
<span class="w60">正确输出:</span>
<span class="W200"><%=x["output"]%></span>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div><!----ProResult end-->
</div><!--homepageRight end-->

View File

@ -1,19 +1,3 @@
<script type="text/javascript">
var scrollHandler = function () {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$.get(
'<%= user_activities_path(@user.id)%>',
{ page: $("#show_more_activities").val(),
type: $("#user_activities_type").val()},
function (data) {
}
);
}
};
$(window).scroll(scrollHandler);
</script>
<input type="hidden" value="<%= @type%>" name="type" id="user_activities_type">
<div class="resources">
<div class="homepageRightBanner">

View File

@ -1,4 +1,4 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>");
<% if @user_activities.count < 10%>
$(window).off("scroll", scrollHandler);
$("#show_more_activities").hide();
<% end%>

View File

@ -0,0 +1,114 @@
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<!}else{!>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><!=results[i]["result"]!></span>
<span class="w60">正确输出:</span>
<span class="W200"><!=results[i]["output"]!></span>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
<div class="homepageRight">
<div class="HomeWork">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="HomeWorkBox">
<div class="">
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
<div class="cl"></div>
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
<p class="HomeWorkP"><%= @homework.description %> <br />
输入 2 1 1 4 4 2 3 6 5 <br />
输出 15<br />
</p>
</div>
<p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p>
</div><!---HomeWorkBox end -->
<div class="HomeWorkCon">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:student_work_id => @student_work.id,
:homework => @homework.id
},
:method => :post) do |f|%>
<div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span>
</div>
<div class="mt10">
<%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %>
</div>
<div class="mt10">
<%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"请贴入你的代码", rows: 10 %>
</div>
<div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<div class="cl"></div>
</div>
<% end %>
</div><!----HomeWorkCon end-->
</div><!----HomeWork end-->
<div class="ProResult mt10">
<% @student_work.student_work_tests.each_with_index do |test, index| %>
<div class="ProResultTop">
<p class="c_blue fl">第<%= @student_work.student_work_tests.count - index%>次测试</p><span class="fr c_grey"><%= test.created_at.to_s(:db) %></span>
<div class="cl"></div>
</div>
<% if test.status.to_i == -2 %>
<div class="ProResultCon "><%= test.results.first %></div>
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<span class="w60">您的输出:</span>
<span class="W200"><%=x["result"]%></span>
<span class="w60">正确输出:</span>
<span class="W200"><%=x["output"]%></span>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>
</ul>
</div>
<% end %>
<% end %>
</div><!----ProResult end-->
</div><!--homepageRight end-->

View File

@ -1,21 +1,8 @@
<script type="text/javascript">
var scrollHandler = function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$.get(
'<%= user_homeworks_user_path(User.current.id)%>',
{ page : $("#user_show_more_homework").val()},
function (data) {
}
);
}
};
$(window).scroll(scrollHandler);
function reset_homework(){
$("#homework_name").val("");
$("#homework_end_time").val("<%= (Time.now + 3600 * 24).strftime('%Y-%m-%d')%>");
$("#course_id").val("");
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>");
homework_description_editor.html("");
}

View File

@ -4,9 +4,9 @@
<%= stylesheet_link_tag 'leftside' %>
<%= javascript_include_tag 'attachments'%>
<!--<script type="text/css">-->
<!--html,body{ overflow-y:scroll;}-->
<!--html,body{ overflow:scroll; min-height:101%;}-->
<!--html{ overflow:-moz-scrollbars-vertical;}-->
<!--html,body{ overflow-y:scroll;}-->
<!--html,body{ overflow:scroll; min-height:101%;}-->
<!--html{ overflow:-moz-scrollbars-vertical;}-->
<!--</script>-->
<script>
function remote_get_resources(user_id,type){
@ -67,7 +67,7 @@
</li>
</ul>
</div>
</div>
</div>
<div class="resources mt10" id="users_setting">
<div class="resourcesSearchBanner mt10">
<div class="resourcesUploadBox">
@ -93,24 +93,24 @@
</ul>
</div>
<form id="resources_list_form">
<div id="resources_list">
<div id="resources_list">
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
</div>
<div class="resourcesListOption">
<div class="resourcesCheckAll">
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
</div>
<a href="javascript:void(0);" class="replyGrey1 mr15" onclick="all_select();">全选</a>
<a href="javascript:void(0);" class="replyGrey1" onclick="batch_delete();">删除</a>
<div class="resourcesSelectSend">
<div class="fl">选择&nbsp;<span class="c_red" id="res_count">0</span>&nbsp;个资源</div>
<div class="resourcesSelectSendButton" onclick="batch_send();">
<a href="javascript:void(0);" class="sendButtonBlue db" data-remote="true" >发送</a>
<div class="resourcesListOption">
<div class="resourcesCheckAll">
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
</div>
<a href="javascript:void(0);" class="replyGrey1 mr15" onclick="all_select();">全选</a>
<a href="javascript:void(0);" class="replyGrey1" onclick="batch_delete();">删除</a>
<div class="resourcesSelectSend">
<div class="fl">选择&nbsp;<span class="c_red" id="res_count">0</span>&nbsp;个资源</div>
<div class="resourcesSelectSendButton" onclick="batch_send();">
<a href="javascript:void(0);" class="sendButtonBlue db" data-remote="true" >发送</a>
</div>
</div>
</div>
</div>
</form>
<div class="cl"></div>
<div>
@ -122,7 +122,7 @@
<div class="cl"></div>
<!--<div id="upload_box" style="display: none">-->
<!--<%#= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>-->
<!--<%#= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>-->
<!--</div>-->
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="contextMenu">
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)preview();" onfocus="this.blur()">预览</a></li>
@ -133,74 +133,74 @@
</ul>
<script>
var pageX = 0;
var pageY = 0;
//当前选中的行
var line;
//已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line
var last_line;
//资源名称
var res_name;
//资源名称的链接
var res_link;
var id; //资源id
var sendType; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型
$("#resources_list").mousedown(function(e) {
//如果是右键的话
if (3 == e.which) {
document.oncontextmenu = function() {return false;}
pageX = e.clientX;
pageY = e.clientY;
$("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY
+ "px; left:"
+ pageX
+ "px; width: 80px;");
$("#contextMenu").show();
//当前光标所在的对象
var pageX = 0;
var pageY = 0;
//当前选中的行
var line;
//已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line
var last_line;
//资源名称
var res_name;
//资源名称的链接
var res_link;
var id; //资源id
var sendType; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型
$("#resources_list").mousedown(function(e) {
//如果是右键的话
if (3 == e.which) {
document.oncontextmenu = function() {return false;}
pageX = e.clientX;
pageY = e.clientY;
$("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY
+ "px; left:"
+ pageX
+ "px; width: 80px;");
$("#contextMenu").show();
//当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象
line = $(ele).parent();
//如果上一条存在被选中,那么将上一条的背景色改为白色
if(last_line != null){
last_line.children().css("background-color", 'white');
restore();
last_line == null;
}
//如果当前的tag是li那么还要li的父级元素
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
//将当前的元素的所有子元素的背景色改为蓝色
line.children().css("background-color", '#e1e1e1');
//将当前元素赋给 上一个对象 保存起来。
last_line = line;
}
});
//元素包含关系计算
var contains = function(root, el) {
if (root.compareDocumentPosition)
return root === el || !!(root.compareDocumentPosition(el) & 16);
if (root.contains && el.nodeType === 1){
return root.contains(el) && root !== el;
}
while ((el = el.parentNode))
if (el === root) return true;
return false;
}
$(document.body).click(function(e) {
//在列表上的任何单击事件都要恢复原来的样子
//隐藏右键菜单
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象
line = $(ele).parent();
//如果上一条存在被选中,那么将上一条的背景色改为白色
if(last_line != null){
last_line.children().css("background-color", 'white');
restore();
last_line == null;
}
//如果当前的tag是li那么还要li的父级元素
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
//将当前的元素的所有子元素的背景色改为蓝色
line.children().css("background-color", '#e1e1e1');
//将当前元素赋给 上一个对象 保存起来。
last_line = line;
}
});
//元素包含关系计算
var contains = function(root, el) {
if (root.compareDocumentPosition)
return root === el || !!(root.compareDocumentPosition(el) & 16);
if (root.contains && el.nodeType === 1){
return root.contains(el) && root !== el;
}
while ((el = el.parentNode))
if (el === root) return true;
return false;
}
$(document.body).click(function(e) {
//在列表上的任何单击事件都要恢复原来的样子
//隐藏右键菜单
//e.preventDefault();
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
//如果当前行为空,那么要将当前行的拿到
var ele;
if(line == null){
ele = document.elementFromPoint(e.clientX, e.clientY);
var ele;
if(line == null){
ele = document.elementFromPoint(e.clientX, e.clientY);
line = $(ele).parent();
//如果是在li上点击事件那么要获得父组件
if(line.get(0).tagName === 'LI'){
@ -214,317 +214,317 @@ $(document.body).click(function(e) {
}
//当前行恢复编辑状态到链接状态
if(ele && ele.nodeName != 'INPUT') {
restore();
}
if(ele && ele.nodeName != 'INPUT') {
restore();
}
line = null;
});
//只要有一个选中了就是true
function checkboxSelected(){
selected = false;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == true){
selected = true;
}
});
return selected;
}
//只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
});
//只要有一个选中了就是true
function checkboxSelected(){
selected = false;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == true){
selected = true;
}
});
return selected;
}
$("#res_count").html(getCheckBoxSeletedCount());
//只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
}
$("#res_count").html(getCheckBoxSeletedCount());
}
//获取当前checkbox选中的数目
function getCheckBoxSeletedCount(){
var i = 0;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
i ++;
}
});
return i;
}
//全选反选
function all_select(){
}
//获取当前checkbox选中的数目
function getCheckBoxSeletedCount(){
var i = 0;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
i ++;
}
});
return i;
}
//全选反选
function all_select(){
if($("#checkboxAll").attr('checked')){
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',true);
});
$("#res_count").html(getCheckBoxSeletedCount());
}else{
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',false);
});
$("#res_count").html(0);
}
}
//批量删除
function batch_delete(){
var data = $("#resources_list_form").serialize();
if(data != "" && confirm('您删不掉这其中上传者不是您的资源,确认要删除这些资源吗?')) {
$.post(
'<%= user_resource_delete_user_path(@user)%>',
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
function (data) {
if($("#checkboxAll").attr('checked')){
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',true);
});
$("#res_count").html(getCheckBoxSeletedCount());
}else{
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',false);
});
$("#res_count").html(0);
}
}
//批量删除
function batch_delete(){
var data = $("#resources_list_form").serialize();
if(data != "" && confirm('您删不掉这其中上传者不是您的资源,确认要删除这些资源吗?')) {
$.post(
'<%= user_resource_delete_user_path(@user)%>',
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
function (data) {
}
);
}
}
}
);
}
}
function show_send(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}
}
function show_send(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}
}
function batch_send(){
if($("#resources_list_form").serialize() == ""){
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}
}
function batch_send(){
if($("#resources_list_form").serialize() == ""){
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}
}
function preview(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
$.ajax({
type:'get',
url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id
});
}
function preview(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
$.ajax({
type:'get',
url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id
});
}
function rename(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') {
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
'<% end %>');
$("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{
alert('您无法修改此资源!')
}
}
String.prototype.trim = function() {
var str = this,
str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
function rename(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') {
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
'<% end %>');
$("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{
alert('您无法修改此资源!')
}
}
String.prototype.trim = function() {
var str = this,
str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
//恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
function restore(){
//上一行不为空 且链接不为空
if( last_line != null && res_link != null && res_link != '') {
name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ;
if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态
return;
}
if( name && name != res_name.trim()){
//恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
function restore(){
//上一行不为空 且链接不为空
if( last_line != null && res_link != null && res_link != '') {
name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ;
if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态
return;
}
if( name && name != res_name.trim()){
if(confirm('确定修改为 '+name)){
$.post(
'<%=rename_resource_user_path(@user) %>',
"res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title',name);
last_line.children().eq(1).children().attr('href',data);
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
},
'text'
);
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空
}
}else {
last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空
}
if(confirm('确定修改为 '+name)){
$.post(
'<%=rename_resource_user_path(@user) %>',
"res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title',name);
last_line.children().eq(1).children().attr('href',data);
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
},
'text'
);
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空
}
}else {
last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空
}
}
}
}
}
function delete_file() {
$("#contextMenu").hide();
document.oncontextmenu = function () {
return true;
}
line.children().css("background-color", 'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({
type: 'post',
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val()
});
}
}else{
alert('您无法删除此资源!')
}
}
function delete_file() {
$("#contextMenu").hide();
document.oncontextmenu = function () {
return true;
}
line.children().css("background-color", 'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({
type: 'post',
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val()
});
}
}else{
alert('您无法删除此资源!')
}
}
//id 发送的id
//发送的id数组
function chooseSendType(res_id,res_ids){
//id 发送的id
//发送的id数组
function chooseSendType(res_id,res_ids){
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if (lastSendType != null) { //不是第一次点击的时候
if(res_ids == "") {//如果是单个发送
if (sendType === '1') {
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
} else {
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}
}else{//如果是多个发送
if (sendType === '1'){
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}
}
}
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if (lastSendType != null) { //不是第一次点击的时候
if(res_ids == "") {//如果是单个发送
if (sendType === '1') {
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
} else {
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}
}else{//如果是多个发送
if (sendType === '1'){
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}
}
}
lastSendType = sendType;
}
// var iWidth = document.documentElement.clientWidth;
// var iHeight = document.documentElement.clientHeight;
// var moveX = 0;
// var moveY = 0;
// var moveTop = 0;
// var moveLeft = 0;
// var moveable = false;
// var docMouseMoveEvent = document.onmousemove;
// var docMouseUpEvent = document.onmouseup;
// $("#upload_box").mousedown(function() {
// var evt = getEvent();
// moveable = true;
// moveX = evt.clientX;
// moveY = evt.clientY;
//
// moveTop = parseInt($("#upload_box").css('top'));
// moveLeft = parseInt($("#upload_box").css('left'));
//
// $(document).mousemove( function() {
// if (moveable) {
// var evt = getEvent();
// var x = moveLeft + evt.clientX - moveX;
// var y = moveTop + evt.clientY - moveY;
// if ( x > 0 &&( x + 322 < iWidth) && y > 0 && (y + 257 < iHeight) ) {
// $("#upload_box").css('left', x + "px");
// $("#upload_box").css('top', y + "px");
// console.log( moveX)
// console.log( moveY)
// }
// }
// });
// $(document).mouseup (function () {
// if (moveable) {
// document.onmousemove = docMouseMoveEvent;
// document.onmouseup = docMouseUpEvent;
// moveable = false;
// moveX = 0;
// moveY = 0;
// moveTop = 0;
// moveLeft = 0;
// }
// });
// });
//
// // 获得事件Event对象用于兼容IE和FireFox
// function getEvent() {
// return window.event || arguments.callee.caller.arguments[0];
// }
lastSendType = sendType;
}
// var iWidth = document.documentElement.clientWidth;
// var iHeight = document.documentElement.clientHeight;
// var moveX = 0;
// var moveY = 0;
// var moveTop = 0;
// var moveLeft = 0;
// var moveable = false;
// var docMouseMoveEvent = document.onmousemove;
// var docMouseUpEvent = document.onmouseup;
// $("#upload_box").mousedown(function() {
// var evt = getEvent();
// moveable = true;
// moveX = evt.clientX;
// moveY = evt.clientY;
//
// moveTop = parseInt($("#upload_box").css('top'));
// moveLeft = parseInt($("#upload_box").css('left'));
//
// $(document).mousemove( function() {
// if (moveable) {
// var evt = getEvent();
// var x = moveLeft + evt.clientX - moveX;
// var y = moveTop + evt.clientY - moveY;
// if ( x > 0 &&( x + 322 < iWidth) && y > 0 && (y + 257 < iHeight) ) {
// $("#upload_box").css('left', x + "px");
// $("#upload_box").css('top', y + "px");
// console.log( moveX)
// console.log( moveY)
// }
// }
// });
// $(document).mouseup (function () {
// if (moveable) {
// document.onmousemove = docMouseMoveEvent;
// document.onmouseup = docMouseUpEvent;
// moveable = false;
// moveX = 0;
// moveY = 0;
// moveTop = 0;
// moveLeft = 0;
// }
// });
// });
//
// // 获得事件Event对象用于兼容IE和FireFox
// function getEvent() {
// return window.event || arguments.callee.caller.arguments[0];
// }
</script>

View File

@ -199,9 +199,12 @@ default:
repository_root_path: '/tmp/htdocs'
judge_server: 'http://judge.trustie.net/'
# specific configuration options for production environment
# that overrides the default ones
production:
judge_server: 'http://192.168.80.21:8080/'
repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs'
cookie_domain: ".trustie.net"
rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf

View File

@ -120,6 +120,7 @@ RedmineApp::Application.routes.draw do
get 'absence_penalty_list'
get 'evaluation_list'
post 'set_program_score'
post 'program_test'
end
end
@ -171,7 +172,7 @@ RedmineApp::Application.routes.draw do
resources :contests, only: [:index] do
resources :contestnotifications do
# get 'preview', on: :collection
resources :notificationcomments
resources :notificationcomments
end
collection do
@ -232,7 +233,7 @@ RedmineApp::Application.routes.draw do
end
end
end
resources :shares
@ -310,8 +311,11 @@ RedmineApp::Application.routes.draw do
collection do
match "tag_saveEx" , :via => [:get, :post]
post "user_new_homework"
get 'new_user_commit_homework'
post "user_commit_homework"
post 'user_select_homework'
end
member do
match 'user_projects_index', :to => 'users#user_projects_index', :via => :get
match 'user_projects', :to => 'users#user_projects', :via => :get
@ -369,7 +373,7 @@ RedmineApp::Application.routes.draw do
get 'user_resource_type'
get 'user_ref_resource_search'
post 'import_resources_to_homework'
# end
# end
end
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
@ -483,7 +487,7 @@ RedmineApp::Application.routes.draw do
collection do
match "getattachtype" , :via => [:get, :post]
match "search_project",:via => [:post,:get]
#match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post]
#match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post]
end
end
@ -513,7 +517,7 @@ RedmineApp::Application.routes.draw do
resources :repositories, :except => [:index, :show] do
member do
get 'newrepo', :via => [:get, :post]
# get 'create', :via=>[:get, :post]
# get 'create', :via=>[:get, :post]
end
end
match 'wiki/index', :via => :get
@ -603,8 +607,8 @@ RedmineApp::Application.routes.draw do
:controller => 'repositories',
:format => false,
:constraints => {
:action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
:action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
}
get 'projects/:id/repository/statistics', :to => 'repositories#stats'
@ -621,8 +625,8 @@ RedmineApp::Application.routes.draw do
:controller => 'repositories',
:format => false,
:constraints => {
:action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
:action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
}
get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
:controller => 'repositories',
@ -725,7 +729,7 @@ RedmineApp::Application.routes.draw do
get 'test_connection', :as => 'try_connection'
end
collection do
get 'autocomplete_for_new_user'
get 'autocomplete_for_new_user'
end
end
@ -787,7 +791,7 @@ RedmineApp::Application.routes.draw do
collection do
match 'chang_read_flag', :via => :get
end
end
end
end # end of resources :courses
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'

View File

@ -0,0 +1,13 @@
class ChangeStudentWorkTests < ActiveRecord::Migration
def change
change_table :student_work_tests do |t|
t.remove :error_msg
t.remove :result
t.remove :homework_test_id
t.integer :status, default: 9
t.text :results
end
end
end

View File

@ -0,0 +1,5 @@
class AddSrcToStudentWorkTests < ActiveRecord::Migration
def change
add_column :student_work_tests, :src, :text
end
end

View File

@ -99,13 +99,13 @@ function initFilters(){
$('#filters-table td.field input[type=checkbox]').each(function(){
toggleFilter($(this).val());
});
$('#filters-table td.field input[type=checkbox]').live('click',function(){
$('#filters-table td.field input[type=checkbox]').on('click',function(){
toggleFilter($(this).val());
});
$('#filters-table .toggle-multiselect').live('click',function(){
$('#filters-table .toggle-multiselect').on('click',function(){
toggleMultiSelect($(this).siblings('select'));
});
$('#filters-table input[type=text]').live('keypress', function(e){
$('#filters-table input[type=text]').on('keypress', function(e){
if (e.keyCode == 13) submit_query_form("query_form");
});
}

View File

@ -0,0 +1,216 @@
/**
* baiduTemplate简单好用的Javascript模板引擎 1.0.6 版本
* http://baidufe.github.com/BaiduTemplate
* 开源协议BSD License
* 浏览器环境占用命名空间 baidu.template nodejs环境直接安装 npm install baidutemplate
* @param str{String} dom结点ID或者模板string
* @param data{Object} 需要渲染的json对象可以为空当data为{}仍然返回html
* @return 如果无data直接返回编译后的函数如果有data返回html
* @author wangxiao
* @email 1988wangxiao@gmail.com
*/
;(function(window){
//取得浏览器环境的baidu命名空间非浏览器环境符合commonjs规范exports出去
//修正在nodejs环境下采用baidu.template变量名
var baidu = typeof module === 'undefined' ? (window.baidu = window.baidu || {}) : module.exports;
//模板函数放置于baidu.template命名空间下
baidu.template = function(str, data){
//检查是否有该id的元素存在如果有元素则获取元素的innerHTML/value否则认为字符串为模板
var fn = (function(){
//判断如果没有document则为非浏览器环境
if(!window.document){
return bt._compile(str);
};
//HTML5规定ID可以由任何不包含空格字符的字符串组成
var element = document.getElementById(str);
if (element) {
//取到对应id的dom缓存其编译后的HTML模板函数
if (bt.cache[str]) {
return bt.cache[str];
};
//textarea或input则取value其它情况取innerHTML
var html = /^(textarea|input)$/i.test(element.nodeName) ? element.value : element.innerHTML;
return bt._compile(html);
}else{
//是模板字符串,则生成一个函数
//如果直接传入字符串作为模板,则可能变化过多,因此不考虑缓存
return bt._compile(str);
};
})();
//有数据则返回HTML字符串没有数据则返回函数 支持data={}的情况
var result = bt._isObject(data) ? fn( data ) : fn;
fn = null;
return result;
};
//取得命名空间 baidu.template
var bt = baidu.template;
//标记当前版本
bt.versions = bt.versions || [];
bt.versions.push('1.0.6');
//缓存 将对应id模板生成的函数缓存下来。
bt.cache = {};
//自定义分隔符可以含有正则中的字符可以是HTML注释开头 <! !>
bt.LEFT_DELIMITER = bt.LEFT_DELIMITER||'<%';
bt.RIGHT_DELIMITER = bt.RIGHT_DELIMITER||'%>';
//自定义默认是否转义,默认为默认自动转义
bt.ESCAPE = true;
//HTML转义
bt._encodeHTML = function (source) {
return String(source)
.replace(/&/g,'&amp;')
.replace(/</g,'&lt;')
.replace(/>/g,'&gt;')
.replace(/\\/g,'&#92;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
};
//转义影响正则的字符
bt._encodeReg = function (source) {
return String(source).replace(/([.*+?^=!:${}()|[\]/\\])/g,'\\$1');
};
//转义UI UI变量使用在HTML页面标签onclick等事件函数参数中
bt._encodeEventHTML = function (source) {
return String(source)
.replace(/&/g,'&amp;')
.replace(/</g,'&lt;')
.replace(/>/g,'&gt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;')
.replace(/\\\\/g,'\\')
.replace(/\\\//g,'\/')
.replace(/\\n/g,'\n')
.replace(/\\r/g,'\r');
};
//将字符串拼接生成函数,即编译过程(compile)
bt._compile = function(str){
var funBody = "var _template_fun_array=[];\nvar fn=(function(__data__){\nvar _template_varName='';\nfor(name in __data__){\n_template_varName+=('var '+name+'=__data__[\"'+name+'\"];');\n};\neval(_template_varName);\n_template_fun_array.push('"+bt._analysisStr(str)+"');\n_template_varName=null;\n})(_template_object);\nfn = null;\nreturn _template_fun_array.join('');\n";
return new Function("_template_object",funBody);
};
//判断是否是Object类型
bt._isObject = function (source) {
return 'function' === typeof source || !!(source && 'object' === typeof source);
};
//解析模板字符串
bt._analysisStr = function(str){
//取得分隔符
var _left_ = bt.LEFT_DELIMITER;
var _right_ = bt.RIGHT_DELIMITER;
//对分隔符进行转义支持正则中的元字符可以是HTML注释 <! !>
var _left = bt._encodeReg(_left_);
var _right = bt._encodeReg(_right_);
str = String(str)
//去掉分隔符中js注释
.replace(new RegExp("("+_left+"[^"+_right+"]*)//.*\n","g"), "$1")
//去掉注释内容 <%* 这里可以任意的注释 *%>
//默认支持HTML注释将HTML注释匹配掉的原因是用户有可能用 <! !>来做分割符
.replace(new RegExp("<!--.*?-->", "g"),"")
.replace(new RegExp(_left+"\\*.*?\\*"+_right, "g"),"")
//把所有换行去掉 \r回车符 \t制表符 \n换行符
.replace(new RegExp("[\\r\\t\\n]","g"), "")
//用来处理非分隔符内部的内容中含有 斜杠 \ 单引号 处理办法为HTML转义
.replace(new RegExp(_left+"(?:(?!"+_right+")[\\s\\S])*"+_right+"|((?:(?!"+_left+")[\\s\\S])+)","g"),function (item, $1) {
var str = '';
if($1){
//将 斜杠 单引 HTML转义
str = $1.replace(/\\/g,"&#92;").replace(/'/g,'&#39;');
while(/<[^<]*?&#39;[^<]*?>/g.test(str)){
//将标签内的单引号转义为\r 结合最后一步,替换为\'
str = str.replace(/(<[^<]*?)&#39;([^<]*?>)/g,'$1\r$2')
};
}else{
str = item;
}
return str ;
});
str = str
//定义变量,如果没有分号,需要容错 <%var val='test'%>
.replace(new RegExp("("+_left+"[\\s]*?var[\\s]*?.*?[\\s]*?[^;])[\\s]*?"+_right,"g"),"$1;"+_right_)
//对变量后面的分号做容错(包括转义模式 如<%:h=value%>) <%=value;%> 排除掉函数的情况 <%fun1();%> 排除定义变量情况 <%var val='test';%>
.replace(new RegExp("("+_left+":?[hvu]?[\\s]*?=[\\s]*?[^;|"+_right+"]*?);[\\s]*?"+_right,"g"),"$1"+_right_)
//按照 <% 分割为一个个数组,再用 \t 和在一起,相当于将 <% 替换为 \t
//将模板按照<%分为一段一段的,再在每段的结尾加入 \t,即用 \t 将每个模板片段前面分隔开
.split(_left_).join("\t");
//支持用户配置默认是否自动转义
if(bt.ESCAPE){
str = str
//找到 \t=任意一个字符%> 替换为 ‘,任意字符,'
//即替换简单变量 \t=data%> 替换为 ',data,'
//默认HTML转义 也支持HTML转义写法<%:h=value%>
.replace(new RegExp("\\t=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'");
}else{
str = str
//默认不转义HTML转义
.replace(new RegExp("\\t=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':$1,'");
};
str = str
//支持HTML转义写法<%:h=value%>
.replace(new RegExp("\\t:h=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'")
//支持不转义写法 <%:=value%>和<%-value%>
.replace(new RegExp("\\t(?::=|-)(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':$1,'")
//支持url转义 <%:u=value%>
.replace(new RegExp("\\t:u=(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':encodeURIComponent($1),'")
//支持UI 变量使用在HTML页面标签onclick等事件函数参数中 <%:v=value%>
.replace(new RegExp("\\t:v=(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':baidu.template._encodeEventHTML($1),'")
//将字符串按照 \t 分成为数组,在用'); 将其合并,即替换掉结尾的 \t 为 ');
//在iffor等语句前面加上 '); ,形成 ');if ');for 的形式
.split("\t").join("');")
//将 %> 替换为_template_fun_array.push('
//即去掉结尾符生成函数中的push方法
//如if(list.length=5){%><h2>',list[4],'</h2>');}
//会被替换为 if(list.length=5){_template_fun_array.push('<h2>',list[4],'</h2>');}
.split(_right_).join("_template_fun_array.push('")
//将 \r 替换为 \
.split("\r").join("\\'");
return str;
};
})(window);

View File

@ -0,0 +1,133 @@
$(function(){
//提交作业
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var tested = false;
var valid_form = function() {
var src = $('#program-src').val();
var title = $('#program-title').val();
if (!src) {
alert('请输入正确的代码');
return false;
}
if (!title) {
alert('请输入标题');
return false;
}
return true;
}
var test_program = function(cb){
var homework_id = $('#test-program-btn').attr('data-homework-id');
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
var src = $('#program-src').val();
var title = $('#program-title').val();
if(!valid_form()){
return;
}
$.post(
'/student_work/program_test',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title},
function(data,status){
tested = true;
console.log(data);
if (typeof cb == 'function') {cb(); return;}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (data.status==0) {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
}
}
);
};
$('#test-program-btn').on('click', test_program);
$('#commit-program-work-btn').on('click', function(){
if(!valid_form()){
return;
}
if($('.ProResult .ProResultTop').length<=0){
var r=confirm("测试后才能提交,是否立刻测试?");
if (r) {
test_program();
}
return;
}
if (!tested) {
test_program(function(){
$(".HomeWorkCon form").submit();
});
return;
}
$(".HomeWorkCon form").submit();
});
$('form.edit_student_work').on('keydown', '#program-src', function(){
tested = false;
});
//发布作业
var isProgramHomework = function(){
return !$(".advanced_option").is(":hidden");
}
var submit_comm_homework = function(id){
var valid = true;
if (isProgramHomework()) {
$.each($('.advanced_option textarea.InputBox'), function(i, val){
if ($(val).val().length<=0) {
$(val).focus();
valid = false;
return false;
}
});
if (valid) {
$('input[name=homework_type]').val(2);
};
}
if (valid) {
submit_homework(id);
}
}
window.submit_comm_homework = submit_comm_homework;
var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true};
$('input.date-input').datepicker(datepickerOptions);
$('a.pic_date').on('click', function(){
$(this).parent().prev().first().focus();
})
$('a.DropBtn').on('click', function(){
$(".advanced_option").toggle();
});
$(".HomeWork").on('click', 'a.icon_add', function(){
var html = bt('t:test-answer-list', null);
$(this).parent('.mt10').after(html);
});
$(".HomeWork").on('click', 'a.icon_remove', function(){
$(this).parent('.mt10').remove();
});
});

View File

@ -131,13 +131,13 @@
});
//鼠标经过列表项事件
//鼠标经过
$(".mailHover").live("mouseover", function(){
$(".mailHover").on("mouseover", function(){
index = Number($(this).attr("id").split("_")[1]);
liveValue = $("#mailList_"+index).text();
x.children("." + cf).removeClass(cf).addClass(cl);
$(this).addClass(cf).removeClass(cl);
});
$(".mailHover").live("click", function(){
$(".mailHover").on("click", function(){
$("#mail").val($(this).html());
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,10 +4,10 @@ $(function(){
$("#users_setting").css("min-height",$("#LSide").height()-100);
//头像相关
$("#homepage_portrait_image").live("mouseover",function(){
$("#homepage_portrait_image").on("mouseover",function(){
$("#edit_user_file_btn").show();
$("#watch_user_btn").show();
}).live("mouseout",function(){
}).on("mouseout",function(){
$("#edit_user_file_btn").hide();
$("#watch_user_btn").hide();
});

View File

@ -453,7 +453,7 @@ $(function(){
cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
target.toggle(timeout);
}
$("*[nhtype='toggle4cookie']").live('click',function(){
$("*[nhtype='toggle4cookie']").on('click',function(){
personalized_click($(this),500);
});

View File

@ -1,7 +1,7 @@
//个人动态
$(function(){
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
$("a[nhname='reply_btn']").on('click',function(){
var params = {};
params.kindutil = K;
params.container = $(this).parent().parent('div');
@ -35,7 +35,7 @@ $(function(){
},300);
});
$("a[nhname='sub_reply_btn']").live('click',function(){
$("a[nhname='sub_reply_btn']").on('click',function(){
var params = {};
params.kindutil = K;
params.container = $(this).parent().parent('div');

View File

@ -719,3 +719,51 @@ a:hover.about_me{ color:#0781b4;}
/*20150820课程作业 LB*/
.HomeWork {width:708px; background-color:#ffffff; padding:10px 20px 20px 20px; border:1px solid #dddddd;}
.RightBanner {width:708px; height:34px; border-bottom:1px solid #e9e9e9;}
select.InputBox,input.InputBox,textarea.InputBox{ border:1px solid #d9d9d9; color:#888888; height:28px; line-height:28px; padding-left:5px; font-size:14px;}
a.BlueCirBtn{ display:block;width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; text-align:center; border:1px solid #15bccf; color:#15bccf; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtn{ background:#15bccf; color:#fff;}
.W440{ width:440px;}
.W120{ width:110px;}
.W700{ width:700px;max-width: 700px;min-width: 700px;}
.w708{width: 708px;}
a.AnnexBtn{ background: url(../images/homepage_icon2.png) 0px -343px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.AnnexBtn{background: url(../images/homepage_icon2.png) -90px -343px no-repeat; color:#15bccf;}
a.FilesBtn{ background: url(../images/homepage_icon2.png) 0px -373px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.FilesBtn{background: url(../images/homepage_icon2.png) -89px -372px no-repeat; color:#15bccf;}
a.BlueCirBtnMini{ display:block;width:40px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #15bccf; color:#15bccf; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtnMini{ background:#15bccf; color:#fff;}
a.DropBtn{background: url(../images/homepage_icon2.png) -125px -339px no-repeat; width:85px; height:20px; display:block; color:#888888; font-size:14px;}
a:hover.DropBtn{background: url(../images/homepage_icon2.png) -125px -370px no-repeat;}
.DropLine{border-top:1px solid #d9d9d9; float:left; width:623px; height:10px; margin-top:10px;}
/*20150820编程作业 LB*/
.W320{ width:320px;}
.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;}
a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
.icon_remove{background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:left;}
a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;}
/*20150820提交作业 LB*/
.HomeWorkBox{ background:#f6f6f6; padding:10px; margin:10px 0;}
.c_grey{ color:#888888;}
.c_dark_grey{color:#a9a9a9 !important;}
.HomeWorkP{ width:690px; font-size:14px;}
.H150{ height:150px;}
.ProResult{width:748px; background-color:#fff; border:1px solid #dddddd;border-bottom:none; }
.ProResultTop{ height:38px; line-height:38px; border-bottom:1px solid #dddddd; background:#f2f2f2; padding:0 10px;}
.ProResultCon{ padding:10px; color:#888888; line-height:24px; border-bottom:1px solid #dddddd; }
.W50{ width:50px;}
.W200{ width:200px;}
.ProResultTable{ color:#888888;}
.T_C{ text-align:center;}
.SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; }
.SearchIcon:hover{background:url(../images/homepage_icon2.png) 676px -419px no-repeat; }
a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; }
a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;}
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}
a.FilesName{ max-width:540px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;}
a.FilesName02{ max-width:665px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;}
.ProResultUl span { display:block; float:left;}
.ProResultUl li{ line-height:35px; border-bottom:1px solid #dddddd; }
.DateBorder{border:1px solid #d9d9d9; border-left:none; padding:7px 6px 6px 6px;}

View File

@ -498,7 +498,7 @@ a.coursesLineGrey:hover {color:#ffffff;}
.homepageLeftMenuMore {height:18px;}
.homepageLeftMenuMore:hover {background-color:#269ac9;}
.homepageLeftMenuMoreIcon {background:url(../images/homepage_icon.png) -74px -240px no-repeat; display:block; height:18px;}
.homepageMenuSetting {display:inline-block; margin-left:155px;background:url(../images/homepage_icon.png) -190px -365px no-repeat; width:15px; height:15px;}
.homepageMenuSetting {display:inline-block; margin-left:155px;background:url(../images/homepage_icon.png) -190px -365px no-repeat; width:15px; height:15px; margin-top: 16px; margin-right: 15px;}
.homepageMenuSetting:hover {background:url(../images/homepage_icon.png) -190px -407px no-repeat;}
a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}
.homepageLeftLabelContainer {width:238px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px;}
@ -528,6 +528,7 @@ a.menuGrey {color:#808080;}
a.menuGrey:hover {color:#fe7d68;}
.navSearchTypeBox {width:368px; height:35px; position:absolute; border:1px solid #e1e1e1; background-color:#ffffff; padding-left:10px; display:none; color:#3e3e3e; font-size:14px;}
#navSearchAlert {display:none;}
.loadMore {font-size:14px;width:748px; text-align:center; display:block; border:1px solid #dddddd; background-color:#ffffff; float:right;padding:5px 0; letter-spacing: 1px;}
/*个人主页右部分*/
.homepagePostType {width:180px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-170px; font-size:12px; color:#4b4b4b; line-height:2; z-index:9999; display:none;}
@ -674,7 +675,7 @@ a.referenceTypeBlock {color:#888888; display:inline-block; padding:0px 20px;}
/*底部*/
#Footer{background-color:#ffffff; padding-bottom:15px; color:#666666;} /*margin-bottom:10px;*/
.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}
.footerAbout{ width:455px; margin:0 auto;height:35px; line-height:35px; padding-top: 10px; }
.footerAbout{ width:365px; margin:0 auto;height:35px; line-height:35px; padding-top: 10px; }
.languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;}
.departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;}
.copyright{ width:375px; margin:0 auto;height:20px;line-height:20px;}
@ -951,13 +952,3 @@ blockquote {
background-size: 100% 100%;
}