Merge branch 'szzh' into dev_hjq
This commit is contained in:
commit
edea776b03
|
@ -5,14 +5,17 @@ class ExerciseController < ApplicationController
|
|||
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
|
||||
include ExerciseHelper
|
||||
|
||||
include ExerciseHelper
|
||||
def index
|
||||
if @course.is_public == 0 && !User.current.member_of_course?(@course)
|
||||
render_403
|
||||
return
|
||||
end
|
||||
remove_invalid_exercise(@course)
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
if @is_teacher
|
||||
exercises = @course.exercises
|
||||
exercises = @course.exercises.order("created_at asc")
|
||||
else
|
||||
exercises = @course.exercises.where(:exercise_status => 2)
|
||||
exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc")
|
||||
end
|
||||
@exercises = paginateHelper exercises,20 #分页
|
||||
respond_to do |format|
|
||||
|
@ -31,17 +34,24 @@ class ExerciseController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
@can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin?
|
||||
exercise_end = Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
if @exercise.time == -1
|
||||
@can_edit_excercise = exercise_end
|
||||
else
|
||||
@can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin?
|
||||
end
|
||||
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
|
||||
# 学生点击的时候即创建关联,自动保存
|
||||
#eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
|
||||
|
||||
# 已提交问卷的用户不能再访问该界面
|
||||
=begin
|
||||
if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?)
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'base_courses'}
|
||||
end
|
||||
else
|
||||
=end
|
||||
if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id)
|
||||
eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
|
||||
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
|
||||
|
@ -52,7 +62,7 @@ class ExerciseController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html {render :layout => 'base_courses'}
|
||||
end
|
||||
end
|
||||
#end
|
||||
end
|
||||
|
||||
def new
|
||||
|
@ -65,7 +75,6 @@ class ExerciseController < ApplicationController
|
|||
:end_time => "",
|
||||
:publish_time => "",
|
||||
:exercise_description => "",
|
||||
:show_result => "",
|
||||
:show_result => 1
|
||||
}
|
||||
@exercise = Exercise.create option
|
||||
|
@ -80,7 +89,7 @@ class ExerciseController < ApplicationController
|
|||
exercise ||= Exercise.new
|
||||
exercise.exercise_name = params[:exercise][:exercise_name]
|
||||
exercise.exercise_description = params[:exercise][:exercise_description]
|
||||
exercise.end_time = params[:exercise][:end_time]
|
||||
exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1)
|
||||
exercise.publish_time = params[:exercise][:publish_time]
|
||||
exercise.user_id = User.current.id
|
||||
exercise.time = params[:exercise][:time]
|
||||
|
@ -104,10 +113,10 @@ class ExerciseController < ApplicationController
|
|||
def update
|
||||
@exercise.exercise_name = params[:exercise][:exercise_name]
|
||||
@exercise.exercise_description = params[:exercise][:exercise_description]
|
||||
@exercise.time = params[:exercise][:time]
|
||||
@exercise.end_time = params[:exercise][:end_time]
|
||||
@exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time]
|
||||
@exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1)
|
||||
@exercise.publish_time = params[:exercise][:publish_time]
|
||||
@exercise.show_result = params[:exercise][:show_result]
|
||||
@exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result]
|
||||
if @exercise.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -300,6 +309,7 @@ class ExerciseController < ApplicationController
|
|||
# 发布试卷
|
||||
def publish_exercise
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
@index = params[:index]
|
||||
@exercise.exercise_status = 2
|
||||
@exercise.publish_time = Time.now
|
||||
if @exercise.save
|
||||
|
@ -314,11 +324,13 @@ class ExerciseController < ApplicationController
|
|||
# 重新发布的时候会删除所有的答题
|
||||
def republish_exercise
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
@index = params[:index]
|
||||
@exercise.exercise_questions.each do |exercise_question|
|
||||
exercise_question.exercise_answers.destroy_all
|
||||
end
|
||||
@exercise.exercise_users.destroy_all
|
||||
@exercise.exercise_status = 1
|
||||
@exercise.publish_time = nil
|
||||
@exercise.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -328,7 +340,7 @@ class ExerciseController < ApplicationController
|
|||
def student_exercise_list
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@exercise = Exercise.find params[:id]
|
||||
@all_exercises = @course.exercises.order("created_at desc")
|
||||
@all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc")
|
||||
@exercise_count = @exercise.exercise_users.where('score is not NULL').count
|
||||
if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S"))
|
||||
@exercise_users_list = @exercise.exercise_users.where('score is not NULL')
|
||||
|
@ -346,8 +358,8 @@ class ExerciseController < ApplicationController
|
|||
# 学生提交答卷,选中答案的过程中提交
|
||||
def commit_answer
|
||||
eq = ExerciseQuestion.find(params[:exercise_question_id])
|
||||
# 已提交过的则不允许答题
|
||||
if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?)
|
||||
# 已提交过的且是限时的则不允许答题
|
||||
if (has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) && @exercise.time != -1) || Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") < Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
render :json => {:text => "failure"}
|
||||
return
|
||||
end
|
||||
|
@ -364,8 +376,14 @@ class ExerciseController < ApplicationController
|
|||
ea.exercise_choice_id = params[:exercise_choice_id]
|
||||
if ea.save
|
||||
# 保存成功返回成功信息及当前以答题百分比
|
||||
uncomplete_question = get_uncomplete_question(@exercise, User.current)
|
||||
if uncomplete_question.count < 1
|
||||
complete = 1;
|
||||
else
|
||||
complete = 0;
|
||||
end
|
||||
@percent = get_percent(@exercise,User.current)
|
||||
render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)}
|
||||
render :json => {:text => "ok" ,:complete => complete,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
#返回失败信息
|
||||
render :json => {:text => "failure"}
|
||||
|
@ -380,8 +398,14 @@ class ExerciseController < ApplicationController
|
|||
ea.exercise_question_id = params[:exercise_question_id]
|
||||
ea.exercise_choice_id = params[:exercise_choice_id]
|
||||
if ea.save
|
||||
uncomplete_question = get_uncomplete_question(@exercise, User.current)
|
||||
if uncomplete_question.count < 1
|
||||
complete = 1;
|
||||
else
|
||||
complete = 0;
|
||||
end
|
||||
@percent = get_percent(@exercise,User.current)
|
||||
render :json => {:text => "ok",:percent => format("%.2f" ,@percent)}
|
||||
render :json => {:text => "ok",:complete => complete,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
|
@ -410,8 +434,14 @@ class ExerciseController < ApplicationController
|
|||
ea.exercise_question_id = params[:exercise_question_id]
|
||||
ea.answer_text = params[:answer_text]
|
||||
if ea.save
|
||||
uncomplete_question = get_uncomplete_question(@exercise, User.current)
|
||||
if uncomplete_question.count < 1
|
||||
complete = 1;
|
||||
else
|
||||
complete = 0;
|
||||
end
|
||||
@percent = get_percent(@exercise,User.current)
|
||||
render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)}
|
||||
render :json => {:text => ea.answer_text,:complete => complete,:percent => format("%.2f",@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
|
@ -447,6 +477,17 @@ class ExerciseController < ApplicationController
|
|||
def commit_exercise
|
||||
# 老师不需要提交
|
||||
if User.current.allowed_to?(:as_teacher,@course)
|
||||
if @exercise.publish_time.nil?
|
||||
@exercise.update_attributes(:show_result => params[:show_result])
|
||||
@exercise.update_attributes(:exercise_status => 2)
|
||||
@exercise.update_attributes(:publish_time => Time.now)
|
||||
redirect_to exercise_url(@exercise)
|
||||
return
|
||||
elsif Time.parse(@exercise.publish_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S")
|
||||
@exercise.update_attributes(:show_result => params[:show_result])
|
||||
redirect_to exercise_url(@exercise)
|
||||
return
|
||||
end
|
||||
@exercise.update_attributes(:show_result => params[:show_result])
|
||||
redirect_to exercise_url(@exercise)
|
||||
# REDO: 提示提交成功
|
||||
|
@ -490,7 +531,7 @@ class ExerciseController < ApplicationController
|
|||
exercise_qustions.each do |question|
|
||||
answer = get_user_answer(question, user)
|
||||
standard_answer = get_user_standard_answer(question, user)
|
||||
unless answer.nil?
|
||||
unless answer.empty?
|
||||
# 问答题有多个答案
|
||||
if question.question_type == 3
|
||||
if standard_answer.include?(answer.first.answer_text)
|
||||
|
@ -532,19 +573,6 @@ class ExerciseController < ApplicationController
|
|||
eu
|
||||
end
|
||||
|
||||
#获取未完成的题目
|
||||
def get_uncomplete_question exercise,user
|
||||
all_questions = exercise.exercise_questions
|
||||
uncomplete_question = []
|
||||
all_questions.each do |question|
|
||||
answers = get_user_answer(question, user)
|
||||
if answers.nil?
|
||||
uncomplete_question << question
|
||||
end
|
||||
end
|
||||
uncomplete_question
|
||||
end
|
||||
|
||||
# 获取当前学生回答问题的答案
|
||||
def get_user_answer(question,user)
|
||||
# user_answer = ExerciseAnswer.where("user_id=? and exercise_question_id=?", user.id, question.id).first
|
||||
|
@ -563,7 +591,8 @@ class ExerciseController < ApplicationController
|
|||
standard_answer = question.exercise_standard_answers.first
|
||||
end
|
||||
standard_answer
|
||||
end # 是否完成了答题
|
||||
end
|
||||
# 是否完成了答题
|
||||
def get_complete_question(exercise,user)
|
||||
questions = exercise.exercise_questions
|
||||
complete_question = []
|
||||
|
|
|
@ -374,6 +374,9 @@ class FilesController < ApplicationController
|
|||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
Mailer.run.attachments_added(attachments[:files])
|
||||
end
|
||||
# 更新课程英雄榜得分
|
||||
update_contributor_score(@course, attachments[:files].first)
|
||||
# end
|
||||
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
||||
params[:course_attachment_type].each do |type|
|
||||
tag_name = get_tag_name_by_type_number type
|
||||
|
@ -423,6 +426,20 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update_contributor_score(course, file )
|
||||
unless file.author.allowed_to?(:as_teacher, course)
|
||||
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course.id, file.author.id).first
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course.id, :user_id => file.author.id, :message_num => 0, :message_reply_num => 0,
|
||||
:news_reply_num => 0, :resource_num => 5, :journal_num => 0, :journal_reply_num => 0, :total_score => 5)
|
||||
else
|
||||
score = course_contributor_score.resource_num + 5
|
||||
total_score = course_contributor_score.total_score + 5
|
||||
course_contributor_score.update_attributes(:resource_num => score, :total_score => total_score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_tag_name_by_type_number type
|
||||
case type
|
||||
when "1"
|
||||
|
|
|
@ -34,7 +34,7 @@ class RepositoriesController < ApplicationController
|
|||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab]
|
||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked]
|
||||
accept_rss_auth :revisions
|
||||
# hidden repositories filter // 隐藏代码过滤器
|
||||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
|
@ -42,7 +42,7 @@ class RepositoriesController < ApplicationController
|
|||
include RepositoriesHelper
|
||||
helper :project_score
|
||||
#@root_path = RepositoriesHelper::ROOT_PATH
|
||||
|
||||
$g=Gitlab.client
|
||||
|
||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||
def new
|
||||
|
@ -63,6 +63,78 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def forked
|
||||
# 被forked的标识如果不满足单个用户唯一性,则不执行fork
|
||||
if is_sigle_identifier?(User.current, @repository.identifier)
|
||||
# REDO: 那些人有权限forked项目
|
||||
g = Gitlab.client
|
||||
gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.gid}")
|
||||
if gproject
|
||||
copy_project(@project, gproject)
|
||||
end
|
||||
else
|
||||
flash[:notice] = l(:project_gitlab_fork_double_message)
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories')
|
||||
end
|
||||
end
|
||||
|
||||
# copy a project for fork
|
||||
def copy_project(project, gproject)
|
||||
project = Project.new
|
||||
project.name = @project.name
|
||||
project.is_public = @project.is_public
|
||||
project.status = @project.status
|
||||
project.description = @project.description
|
||||
project.hidden_repo = @project.hidden_repo
|
||||
project.user_id = User.current.id
|
||||
project.project_type = 0
|
||||
project.project_new_type = @project.project_new_type
|
||||
project.gpid = gproject.id
|
||||
if project.save
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id)
|
||||
Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
|
||||
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0)
|
||||
Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
|
||||
project.members << m
|
||||
project.project_infos << project_info
|
||||
copy_repository(project, gproject)
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
attrs = {:parent_id => project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_url(attrs, :course => '0')
|
||||
else
|
||||
redirect_to settings_project_url(project)
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => project.id) }
|
||||
format.js
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'forked', :layout => 'base_projects'}
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def copy_repository(project, gproject)
|
||||
# 避免
|
||||
if is_sigle_identifier?(project.user_id, gproject.name)
|
||||
repository = Repository.factory('Git')
|
||||
repository.project_id = project.id
|
||||
repository.type = 'Repository::Gitlab'
|
||||
repository.url = gproject.name
|
||||
repository.identifier = gproject.name
|
||||
repository = repository.save
|
||||
else
|
||||
flash[:notice] = l(:project_gitlab_create_double_message)
|
||||
end
|
||||
end
|
||||
|
||||
def newrepo
|
||||
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||
|
@ -115,21 +187,27 @@ update
|
|||
}
|
||||
|
||||
def create
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory('Git')
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@repository.project = @project
|
||||
@repository.type = 'Repository::Gitlab'
|
||||
@repository.url = @repository.identifier
|
||||
if request.post? && @repository.save
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
s.create_project(@project, @repository)
|
||||
# 判断版本库创建者是否有同名版本库,避免版本库路径一致问题
|
||||
unless is_sigle_identifier?(@project.user_id, params[:repository].first[1])
|
||||
flash[:notice] = l(:project_gitlab_create_double_message)
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories')
|
||||
else
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory('Git')
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@repository.project = @project
|
||||
@repository.type = 'Repository::Gitlab'
|
||||
@repository.url = @repository.identifier
|
||||
if request.post? && @repository.save
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
s.create_project(@project, @repository)
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories')
|
||||
else
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,14 +315,34 @@ update
|
|||
#Modified by young
|
||||
# (show_error_not_found; return) unless @entries
|
||||
g = Gitlab.client
|
||||
count = 0
|
||||
(0..100).each do |page|
|
||||
if g.commits(@project.gpid,:page => page).count == 0
|
||||
break
|
||||
else
|
||||
count = count + g.commits(@project.gpid,:page => page).count
|
||||
end
|
||||
|
||||
# count = 0
|
||||
# (0..100).each do |page|
|
||||
# if g.commits(@project.gpid,:page => page).count == 0
|
||||
# break
|
||||
# else
|
||||
# count = count + g.commits(@project.gpid,:page => page).count
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
#add by hx
|
||||
if g.commits(@project.gpid , :page=>25).count==0
|
||||
count = count_commits(@project.gpid , 0 , 25)
|
||||
elsif g.commits(@project.gpid , :page=>50).count ==0
|
||||
count = count_commits(@project.gpid , 25 , 50)+ 25 * 20
|
||||
elsif g.commits(@project.gpid , :page=>75).count ==0
|
||||
count = count_commits(@project.gpid , 50 , 75)+ 50 * 20
|
||||
elsif g.commits(@project.gpid , :page=>100).count== 0
|
||||
count = count_commits(@project.gpid , 75 , 100) + 75 * 20
|
||||
elsif g.commits(@project.gpid , :page=>125).count==0
|
||||
count = count_commits(@project.gpid , 100 , 125) + 100 * 20
|
||||
elsif g.commits(@project.gpid , :page=>150).count==0
|
||||
count = count_commits(@project.gpid , 125 , 150) + 125 * 20
|
||||
else
|
||||
count = count_commits(@project.gpid , 150 ,200) + 150 * 20
|
||||
end
|
||||
|
||||
@changesets = g.commits(@project.gpid)
|
||||
# @changesets = @repository.latest_changesets(@path, @rev)
|
||||
# @changesets_count = @repository.latest_changesets(@path, @rev).count
|
||||
|
@ -271,11 +369,30 @@ update
|
|||
|
||||
alias_method :browse, :show
|
||||
|
||||
#add by hx
|
||||
def count_commits(project_id , left , right)
|
||||
count = 0
|
||||
(left..right).each do |page|
|
||||
if $g.commits(project_id,:page => page).count == 0
|
||||
break
|
||||
else
|
||||
count = count + $g.commits(project_id,:page => page).count
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
def changes
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
(show_error_not_found; return) unless @entry
|
||||
g = Gitlab.client
|
||||
@commits = g.commits(@project.gpid, page:params[:pamge])
|
||||
limit = 20
|
||||
#每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来
|
||||
@commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s)
|
||||
#页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化
|
||||
@commits_count = params[:commit_count].to_i
|
||||
@commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page]
|
||||
|
||||
@commit = g.commit(@project.gpid,@rev)
|
||||
# @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}")
|
||||
#@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
|
||||
|
@ -284,6 +401,7 @@ update
|
|||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
|
||||
def revisions
|
||||
@changeset_count = @repository.changesets.count
|
||||
@changeset_pages = Paginator.new @changeset_count,
|
||||
|
@ -467,8 +585,8 @@ update
|
|||
def find_repository
|
||||
@repository = Repository.find(params[:id])
|
||||
@project = @repository.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
|
||||
|
|
|
@ -76,7 +76,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
##################################################################################################################
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
|
||||
@show_all = false
|
||||
|
@ -167,6 +167,18 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
# 提交作品前先判断是否已经提交
|
||||
@has_commit = false;
|
||||
if hsd_committed_work?(User.current.id, @homework.id)
|
||||
@work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
|
||||
@has_commit = true;
|
||||
#flash[:notice] = l(:notice_successful_create)
|
||||
#redirect_to edit_student_work_url(params[:student_work])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
return
|
||||
end
|
||||
if params[:student_work]
|
||||
@submit_result = true
|
||||
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
|
||||
|
@ -499,6 +511,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def hsd_committed_work?(user, homework)
|
||||
sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
|
||||
sw.nil? ? result = false : result = true
|
||||
result
|
||||
end
|
||||
|
||||
#获取作业
|
||||
def find_homework
|
||||
@homework = HomeworkCommon.find params[:homework]
|
||||
|
|
|
@ -75,6 +75,50 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 更新课程英雄榜得分
|
||||
# user传过来必须是学生
|
||||
def course_member_score(course_id,user_id,type)
|
||||
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course_id, user_id).first
|
||||
case type
|
||||
when "JournalForMessage"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
|
||||
:news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0, :total_score => 1)
|
||||
else
|
||||
score = course_contributor_score.journal_num + 1
|
||||
total_score = course_contributor_score.total_score + 1
|
||||
course_contributor_score.update_attributes(:journal_num => score, :total_score => total_score)
|
||||
end
|
||||
when "Message"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 2, :message_reply_num => 0,
|
||||
:news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 2)
|
||||
else
|
||||
score = course_contributor_score.message_num + 2
|
||||
total_score = course_contributor_score.total_score + 2
|
||||
course_contributor_score.update_attributes(:message_num => score, :total_score => total_score)
|
||||
end
|
||||
when "MessageReply"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1,
|
||||
:news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
|
||||
else
|
||||
score = course_contributor_score.message_reply_num + 1
|
||||
total_score = course_contributor_score.total_score + 1
|
||||
course_contributor_score.update_attributes(:message_reply_num => score, :total_score => total_score)
|
||||
end
|
||||
when "NewReply"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
|
||||
:news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
|
||||
else
|
||||
score = course_contributor_score.news_reply_num + 1
|
||||
total_score = course_contributor_score.total_score + 1
|
||||
course_contributor_score.update_attributes(:news_reply_num => score, :total_score => total_score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Added by young
|
||||
# Define the course menu's link class
|
||||
# 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表
|
||||
|
|
|
@ -25,6 +25,10 @@ module CoursesHelper
|
|||
# searchTeacherAndAssistant(project).count
|
||||
end
|
||||
|
||||
def show_nav?(count)
|
||||
count == 0 ? true : false
|
||||
end
|
||||
|
||||
#课程模块需要展示的模块
|
||||
def course_model
|
||||
@nav_dispaly_course_all_label = 1
|
||||
|
@ -733,4 +737,26 @@ module CoursesHelper
|
|||
end
|
||||
desc.html_safe
|
||||
end
|
||||
|
||||
# 学生按作业总分排序,取前8个
|
||||
def hero_homework_score(course, score_sort_by)
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(student_works.final_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{course.id}
|
||||
AND student_works.user_id = members.user_id
|
||||
) AS score
|
||||
FROM members
|
||||
JOIN students_for_courses
|
||||
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
||||
WHERE members.course_id = #{course.id} ORDER BY score #{score_sort_by} limit 9"
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
end
|
||||
|
||||
def contributor_course_scor(course_id)
|
||||
ccs = CourseContributorScore.where("course_id =?", course_id).order("total_score desc") .limit(9)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -107,6 +107,19 @@ module ExerciseHelper
|
|||
end
|
||||
end
|
||||
|
||||
#获取未完成的题目
|
||||
def get_uncomplete_question exercise,user
|
||||
all_questions = exercise.exercise_questions
|
||||
uncomplete_question = []
|
||||
all_questions.each do |question|
|
||||
answers = get_user_answer(question, user)
|
||||
if answers.empty?
|
||||
uncomplete_question << question
|
||||
end
|
||||
end
|
||||
uncomplete_question
|
||||
end
|
||||
|
||||
#获取文本题答案
|
||||
def get_anwser_vote_text(question_id,user_id)
|
||||
pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id)
|
||||
|
|
|
@ -27,6 +27,20 @@ module RepositoriesHelper
|
|||
REPO_IP_ADDRESS = Setting.host_repository
|
||||
REPO_GITLAB_ADDRESS = "git.trustie.net"
|
||||
|
||||
# 某个成员不能拥有同名版本库,不同的成员可以创建同名版本库
|
||||
def is_sigle_identifier?(user_id, iden)
|
||||
projects = Project.where("user_id =?",user_id)
|
||||
identifiers = []
|
||||
projects.each do |project|
|
||||
# 只针对gitlab类型的,git类型的后期清掉
|
||||
repository = Repository.where("project_id =? and type =?", project.id, "Repository::Gitlab").first
|
||||
if repository
|
||||
identifiers << repository.identifier
|
||||
end
|
||||
end
|
||||
identifiers.include?(iden) ? false :true
|
||||
end
|
||||
|
||||
def format_revision(revision)
|
||||
if revision.respond_to? :format_identifier
|
||||
revision.format_identifier
|
||||
|
@ -47,7 +61,7 @@ module RepositoriesHelper
|
|||
|
||||
def user_commit_rep(mail)
|
||||
user = User.find_by_mail(mail)
|
||||
user.nil? ? User.find(2) : User.find_by_mail(mail)
|
||||
#user.nil? ? User.find(2) : User.find_by_mail(mail)
|
||||
end
|
||||
|
||||
def render_properties(properties)
|
||||
|
|
|
@ -560,4 +560,5 @@ class Attachment < ActiveRecord::Base
|
|||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class Comment < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
safe_attributes 'comments'
|
||||
after_create :send_mail, :act_as_system_message
|
||||
after_create :send_mail, :act_as_system_message, :act_as_student_score
|
||||
|
||||
def act_as_system_message
|
||||
if self.commented.course
|
||||
|
@ -66,13 +66,24 @@ class Comment < ActiveRecord::Base
|
|||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
end
|
||||
|
||||
# 课程成员得分(英雄榜)
|
||||
def act_as_student_score
|
||||
unless self.author.allowed_to?(:as_teacher, self.commented.course)
|
||||
course_member_score(self.commented.course.id, self.author_id, "NewReply")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -40,8 +40,10 @@ class Course < ActiveRecord::Base
|
|||
|
||||
has_many :course_activities
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
has_many :exercises, :dependent => :destroy
|
||||
# 课程贡献榜
|
||||
has_many :course_contributor_scores, :dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class CourseContributorScore < ActiveRecord::Base
|
||||
attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num, :resource_num, :user_id, :total_score
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
end
|
|
@ -64,7 +64,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
|
||||
|
||||
validates :notes, presence: true, if: :is_homework_jour?
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
@ -263,4 +263,12 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
# 课程成员得分(英雄榜)
|
||||
def act_as_student_score
|
||||
unless self.user.allowed_to?(:as_teacher, self.jour)
|
||||
course_member_score(self.jour_id, self.user_id, "JournalForMessage")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -74,7 +74,7 @@ class Message < ActiveRecord::Base
|
|||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
|
||||
|
||||
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail
|
||||
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -285,4 +285,16 @@ class Message < ActiveRecord::Base
|
|||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
|
||||
# 课程成员得分(英雄榜)
|
||||
def act_as_student_score
|
||||
unless self.author.allowed_to?(:as_teacher, self.course)
|
||||
if self.parent_id.nil?
|
||||
# 发帖
|
||||
course_member_score(self.course.id, self.author_id, "Message")
|
||||
else
|
||||
# 回帖
|
||||
course_member_score(self.course.id, self.author_id, "MessageReply")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,8 @@ class Repository < ActiveRecord::Base
|
|||
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
|
||||
validates_presence_of :identifier#, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
||||
#validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||
validates_uniqueness_of :identifier, :allow_blank => true
|
||||
# 改成同一用户不能有两个相同名字的版本库
|
||||
# validates_uniqueness_of :identifier, :allow_blank => true
|
||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||
# donwcase letters, digits, dashes, underscores but not digits only
|
||||
validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true
|
||||
|
@ -52,7 +53,8 @@ class Repository < ActiveRecord::Base
|
|||
'password',
|
||||
'path_encoding',
|
||||
'log_encoding',
|
||||
'is_default'
|
||||
'is_default',
|
||||
'type'
|
||||
|
||||
safe_attributes 'url',
|
||||
:if => lambda {|repository, user| repository.new_record?}
|
||||
|
@ -63,6 +65,10 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def repo_create_validation
|
||||
# 之所以可以这样改,是因为Fork的时候不需要从Trustie创建版本库,只需从Gitlab关联即可
|
||||
if self.class.name.demodulize == "Repository"
|
||||
return
|
||||
end
|
||||
unless Setting.enabled_scm.include?(self.class.name.demodulize)
|
||||
errors.add(:type, :invalid)
|
||||
end
|
||||
|
|
|
@ -153,6 +153,8 @@ class User < Principal
|
|||
# 邮件邀请状态
|
||||
has_many :invite_lists, :dependent => :destroy
|
||||
# end
|
||||
# 课程贡献榜
|
||||
has_many :course_contributor_scores, :dependent => :destroy
|
||||
|
||||
######added by nie
|
||||
has_many :project_infos, :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<% course_file_num = visable_attachemnts_incourse(@course).count%>
|
||||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<% if show_nav?(@course.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10"%>
|
||||
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.news.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_file_num) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_feedback_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}", :id => "course_jour_count"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_poll_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10"%>
|
||||
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10"%>
|
||||
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,12 +1,21 @@
|
|||
<div id="popbox" style="text-align: center;margin-top: 25px">
|
||||
<% if status == 0 %>
|
||||
<% if status == 0 && exercise.time != -1%>
|
||||
<h3 style="font-weight: normal;color: green">提交成功!您的分数是:<%=@score %>分。</h3>
|
||||
<%= link_to "确定", exercise_path(),:class => 'commit'%>
|
||||
<% elsif status == 1 %>
|
||||
<h3 style="font-weight: normal;color: red">您还有尚未作答的题目请完成后再提交!</h3>
|
||||
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
|
||||
<% else %>
|
||||
<% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
|
||||
<h3 style="font-weight: normal;color: green">提交成功!</h3>
|
||||
<%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%>
|
||||
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
|
||||
<h3 style="font-weight: normal;color: red">保存成功!</h3>
|
||||
<%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => 'commit'%>
|
||||
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") <= Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
|
||||
<h3 style="font-weight: normal;color: red">时间已到!</h3>
|
||||
<%= link_to "确定", exercise_path(),:class => 'commit'%>
|
||||
<% elsif status == 2 %>
|
||||
<h3 style="font-weight: normal;color: red">发生未知错误,请检查您的网络。</h3>
|
||||
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
|
||||
<% else %>
|
||||
<h3 style="font-weight: normal;color: green">时间已到!您的分数是:<%=@score %>分。</h3>
|
||||
<%= link_to "确定", exercise_path(),:class => 'commit'%>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
|
||||
<!--编辑单选start-->
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=exercise_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>")
|
||||
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>")
|
||||
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
|
||||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<% end%>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="questionContainer" style="width: 680px;">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入单选题题目" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div id="poll_answers_<%=exercise_question.id%>">
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,1);">
|
||||
保存
|
||||
</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
|
||||
<!--编辑单选start-->
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=exercise_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>")
|
||||
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>")
|
||||
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
|
||||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<% end%>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="questionContainer" style="width: 680px;">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入单选题题目" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div id="poll_answers_<%=exercise_question.id%>">
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,1);">
|
||||
保存
|
||||
</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
<% end%>
|
|
@ -1,63 +1,63 @@
|
|||
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
|
||||
<!--编辑单选start-->
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=exercise_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>")
|
||||
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>")
|
||||
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
|
||||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<% end%>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="questionContainer" style="width: 680px;">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入多选题题目" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div id="poll_answers_<%=exercise_question.id%>">
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,2);">
|
||||
保存
|
||||
</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
|
||||
<!--编辑单选start-->
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=exercise_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>")
|
||||
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>")
|
||||
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
|
||||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" +
|
||||
"<input maxlength='200' type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<% end%>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="questionContainer" style="width: 680px;">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入多选题题目" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div id="poll_answers_<%=exercise_question.id%>">
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,2);">
|
||||
保存
|
||||
</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
<% end%>
|
|
@ -3,31 +3,37 @@
|
|||
<div>
|
||||
<input name="exercise[exercise_name]" maxlength="100" id="exercise_name" class="testTitle mb10" type="text" placeholder="测验标题" value="<%=@exercise.exercise_name%>" />
|
||||
</div>
|
||||
<%# if edit_mode %>
|
||||
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选):</label>-->
|
||||
<%# end %>
|
||||
<div class="calendar_div fl mr10">
|
||||
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if exercise.publish_time %>" >
|
||||
<%= calendar_for('exercise_publish_time')%>
|
||||
</div>
|
||||
<%# if edit_mode %>
|
||||
<!--<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>-->
|
||||
<%# end %>
|
||||
<label class="fl c_grey f14" style="margin-top: 4px;">截止时间:</label>
|
||||
<div class="calendar_div fl">
|
||||
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>" >
|
||||
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>"/>
|
||||
<%= calendar_for('exercise_end_time')%>
|
||||
</div>
|
||||
<div class="fl ml10 f14 fontGrey2"><span class="mr5">测验时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" value="<%=exercise.time %>" />分钟</div>
|
||||
<div class="fl ml15 f14 fontGrey2"><span class="mr5">测验时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" placeholder="不填即不限时" value="<%=exercise.time if exercise.time!= -1 %>" />分钟</div>
|
||||
<label class="fl c_grey ml15 f14" style="margin-top: 4px;">发布时间(可选):</label>
|
||||
<div class="calendar_div fl">
|
||||
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间(可选)" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil? %>"/>
|
||||
<%= calendar_for('exercise_publish_time')%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<textarea class="testDes mt10" name="exercise[exercise_description]" id="exercise_description" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。您可以在此处填写测验相关说明。" ><%=exercise.exercise_description %></textarea>
|
||||
<div class="ur_editor_footer" style="padding-top: 10px;">
|
||||
<a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));">
|
||||
保存
|
||||
</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">
|
||||
<a class="btn_cancel" data-button="cancel" onclick="resetHead();pollsCancel();">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
function resetHead()
|
||||
{
|
||||
$("#exercise_name").val("<%=@exercise.exercise_name%>");
|
||||
$("#exercise_end_time").val("<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>");
|
||||
$("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>");
|
||||
$("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>");
|
||||
$("#exercise_description").val("<%=exercise.exercise_description %>");
|
||||
}
|
||||
</script>
|
|
@ -8,7 +8,7 @@
|
|||
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>候选答案<span class='ur_index'></span>: </label>" +
|
||||
"<input name='exercise_choice[<%=exercise_choice.id %>]' placeholder='请输入候选答案' type='text' value='<%=exercise_choice.answer_text %>'/>" +
|
||||
"<input class='candiate_answer' name='exercise_choice[<%=exercise_choice.id %>]' placeholder='请输入候选答案' type='text' value='<%=exercise_choice.answer_text %>'/>" +
|
||||
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
|
@ -24,7 +24,7 @@
|
|||
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text" value="<%=exercise_question.question_title %>">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<div class="ur_editor_content" id="edit_single">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||||
<li class="ur_item">
|
||||
<label>候选答案<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[<%=exercise_choice.id %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<input class="candiate_answer" name="exercise_choice[<%=exercise_choice.id %>]" placeholder="请输入候选答案" type="text" value="<%=exercise_choice.answer_text %>"/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this));"></a>
|
||||
</li>
|
||||
|
|
|
@ -1,61 +1,60 @@
|
|||
<%# has_commit = has_commit_poll?(poll.id ,User.current)%>
|
||||
<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%>
|
||||
<% if @is_teacher%>
|
||||
<li title="<%= exercise.exercise_name %>">
|
||||
<div style="width: 310px;float: left;">
|
||||
<%# if has_commit %>
|
||||
<%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%>
|
||||
<%# else %>
|
||||
<%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %>
|
||||
<%# end %>
|
||||
<%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<% if exercise.exercise_status == 1%>
|
||||
<li class="pollsbtn fl ml10 pollsbtn_grey">统计结果</li>
|
||||
<% else %>
|
||||
<li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%></li>
|
||||
<% end%>
|
||||
|
||||
<% if exercise.exercise_status == 1 %>
|
||||
<li><a href="javascript:" class="pollsbtn btn_pu fl ml5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>);">发布试卷</a></li>
|
||||
<% elsif exercise.exercise_status == 2%>
|
||||
<li><a href="javascript:" class="pollsbtn btn_de fl ml5" onclick="republish_exercise(<%= exercise.id%>);">取消发布</a></li>
|
||||
<% else%>
|
||||
<li class="pollsbtn fl ml10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li>
|
||||
<% end%>
|
||||
|
||||
<%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %>
|
||||
|
||||
<% if exercise.exercise_status == 1 %>
|
||||
<li><%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%></li>
|
||||
<% else%>
|
||||
<li class="polls_de_grey fr ml5" title="未发布的试卷才能进行编辑">编辑</li>
|
||||
<% end%>
|
||||
|
||||
<%# if exercise.exercise_status == 2 %>
|
||||
<!--<li><a class="polls_de fr ml5" onclick="" href="javascript:">关闭</a></li>-->
|
||||
<%# else %>
|
||||
<!--<li class="polls_de_grey fr ml5" title="发布的问卷才能进行关闭">关闭</li>-->
|
||||
<%# end%>
|
||||
|
||||
<%# if exercise.exercise_status == 1%>
|
||||
<!--<li class="polls_de_grey fr ml5">导出</li>-->
|
||||
<%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %>
|
||||
<!--<li><%#= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%></li>-->
|
||||
<%# end%>
|
||||
|
||||
|
||||
<li class="polls_date fr"><%= format_date exercise.created_at.to_date%></li>
|
||||
<% else%>
|
||||
<% if exercise.exercise_status == 2%>
|
||||
<%# if has_commit%>
|
||||
<!--li><%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_st fl c_dblue" %></li>
|
||||
<li class="pollsbtn_tip fl ml5">已答</li-->
|
||||
<%#else%>
|
||||
<%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%>
|
||||
<%#end%>
|
||||
<% end%>
|
||||
<li class="polls_date fr mr10"><%= format_date exercise.created_at.to_date%></li>
|
||||
<%# has_commit = has_commit_poll?(poll.id ,User.current)%>
|
||||
<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%>
|
||||
<% if @is_teacher%>
|
||||
<li title="<%= exercise.exercise_name %>">
|
||||
<div style="width: 310px;float: left;">
|
||||
<%# if has_commit %>
|
||||
<%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%>
|
||||
<%# else %>
|
||||
<%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %>
|
||||
<%# end %>
|
||||
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<%# if exercise.exercise_status == 2 %>
|
||||
<!--<li><a class="polls_de fr ml5" onclick="" href="javascript:">关闭</a></li>-->
|
||||
<%# else %>
|
||||
<!--<li class="polls_de_grey fr ml5" title="发布的问卷才能进行关闭">关闭</li>-->
|
||||
<%# end%>
|
||||
|
||||
<%# if exercise.exercise_status == 1%>
|
||||
<!--<li class="polls_de_grey fr ml5">导出</li>-->
|
||||
<%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %>
|
||||
<!--<li><%#= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%></li>-->
|
||||
<%# end%>
|
||||
<% if exercise.exercise_status == 1 %>
|
||||
<li><a href="javascript:" class="pollsbtn btn_pu fr mr5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li>
|
||||
<% elsif exercise.exercise_status == 2%>
|
||||
<li><a href="javascript:" class="pollsbtn btn_de fr mr5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li>
|
||||
<% else%>
|
||||
<li class="pollsbtn fr mr10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li>
|
||||
<% end%>
|
||||
|
||||
<% if exercise.exercise_status == 1%>
|
||||
<li class="pollsbtn fr mr10 pollsbtn_grey">统计结果</li>
|
||||
<% else %>
|
||||
<li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%></li>
|
||||
<% end%>
|
||||
|
||||
<%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %>
|
||||
|
||||
<% if exercise.exercise_status == 1 %>
|
||||
<li><%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%></li>
|
||||
<li class="polls_date fr"><%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%></li>
|
||||
<% else%>
|
||||
<li class="polls_de_grey fr ml10" title="未发布的试卷才能进行编辑">编辑</li>
|
||||
<li class="polls_date fr">已发布</li>
|
||||
<% end%>
|
||||
|
||||
<% else%>
|
||||
<% if exercise.exercise_status == 2%>
|
||||
<%# if has_commit%>
|
||||
<!--li><%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_st fl c_dblue" %></li>
|
||||
<li class="pollsbtn_tip fl ml5">已答</li-->
|
||||
<%#else%>
|
||||
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%>
|
||||
<%#end%>
|
||||
<% end%>
|
||||
<li class="polls_date fr mr10">截止时间:<%= format_time(exercise.end_time.to_s)%></li>
|
||||
<% end%>
|
|
@ -1,194 +1,219 @@
|
|||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#RSide").removeAttr("id");
|
||||
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
|
||||
$("#Container").css("width","1000px");
|
||||
});
|
||||
//编辑问卷描述之后
|
||||
var popWindow ; //弹出框的引用
|
||||
var importPollPopWindow; //选择导入的弹出框引用
|
||||
function edit_head(){
|
||||
$("#polls_description").val($("#polls_description_div").html());
|
||||
}
|
||||
$(function(){
|
||||
//点击空白处
|
||||
$(document).bind('click',function(e){
|
||||
//弹出框非空 不是a标签 点击的不是弹出框 ,那么弹出框就会隐藏
|
||||
if(popWindow && e.target.nodeName != 'A' && !popWindow.is(e.target) && popWindow.has(e.target).length === 0){ // Mark 1
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
if(importPollPopWindow && e.target.nodeName != 'A' && !importPollPopWindow.is(e.target) && importPollPopWindow.has(e.target).length === 0){
|
||||
importPollPopWindow.css('display', 'none');
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
function dismiss(quest_type,quest_id){
|
||||
popWindow = $("#div_"+quest_type+"_"+quest_id);
|
||||
if(popWindow){
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
function chooseQuestionType(quest_type,quest_id){
|
||||
//quest_type 分为 mc mcq single multi
|
||||
//quest_id 是quetion的id 下同
|
||||
if(popWindow){
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
popWindow = $("#div_"+quest_type+"_"+quest_id);
|
||||
$("#div_"+quest_type+"_"+quest_id).click(function(e){
|
||||
e.stopPropagation(); //组织冒泡到document.body中去
|
||||
});
|
||||
$("#div_"+quest_type+"_"+quest_id).css("position", "absolute");
|
||||
|
||||
$("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30);
|
||||
|
||||
$("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10);
|
||||
if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') {
|
||||
$("#div_"+quest_type+"_"+quest_id).css('display', 'none');
|
||||
}
|
||||
else{
|
||||
$("#div_"+quest_type+"_"+quest_id).css('display', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
//选择导入调查问卷
|
||||
function importPoll(){
|
||||
importPollPopWindow = $("#import_poll");
|
||||
$("#import_poll").css("position", "absolute");
|
||||
|
||||
$("#import_poll").css("top", $("#import_btn").offset().top+30);
|
||||
|
||||
$("#import_poll").css("left", $("#import_btn").offset().left-65);
|
||||
$("#import_poll").css("display","block")
|
||||
}
|
||||
|
||||
function remote_import(){
|
||||
importPollPopWindow.css('display', 'none');
|
||||
if($("#import_poll").val() === 0){
|
||||
return;
|
||||
}else{
|
||||
if(confirm("确认导入问卷"+$("#import_poll").find("option:selected").text()+"?")){
|
||||
$("#import_form").submit();
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//添加标题时确定按钮
|
||||
function add_poll_question(doc,quest_type)
|
||||
{
|
||||
var title = $.trim($("#poll_questions_title").val());
|
||||
var score = $.trim($("#question_score").val());
|
||||
var standard_ans = $.trim($("#question_standard_ans").val());
|
||||
if(title.length == 0 || score.length == 0){
|
||||
alert("题目标题/分数不能为空");
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
//修改标题时确定按钮
|
||||
function edit_poll_question(doc,id,quest_type)
|
||||
{
|
||||
var title = $.trim($("#poll_questions_title_" + id).val());
|
||||
var score = $.trim($("#poll_question_score_"+ id).val());
|
||||
var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val());
|
||||
if(title.length == 0 || score.length == 0){
|
||||
alert("题目标题/分数不能为空");
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsSubmit(doc){
|
||||
var title = $.trim($("#exercise_name").val());
|
||||
if(title.length == 0){
|
||||
alert("测验标题不能为空");
|
||||
} else if($.trim($("#exercise_publish_time").val()) =="") {
|
||||
alert("发布时间不能为空");
|
||||
} else if($.trim($("#exercise_end_time").val()) =="") {
|
||||
alert("截止时间不能为空");
|
||||
} else if($.trim($("#exercise_time").val()) =="") {
|
||||
alert("考试时长不能为空");
|
||||
} else if(Date.parse($("#exercise_end_time").val()) <= Date.parse($("#exercise_publish_time").val())) {
|
||||
alert("截止时间必须大于发布时间");
|
||||
}
|
||||
else {
|
||||
doc.parent().parent().parent().submit();
|
||||
}
|
||||
}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
//
|
||||
function pollQuestionCancel(question_id){
|
||||
$("#show_poll_questions_"+question_id).show();
|
||||
$("#edit_poll_questions_"+question_id).hide();
|
||||
}
|
||||
function pollQuestionEdit(question_id){
|
||||
$("#show_poll_questions_"+question_id).hide();
|
||||
$("#edit_poll_questions_"+question_id).show();
|
||||
$("#poll_questions_title_"+question_id).focus();
|
||||
}
|
||||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
|
||||
"</li><div class='cl'></div>");
|
||||
}
|
||||
function add_candidate_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>候选答案<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='exercise_choice["+new Date().getTime()+"]' placeholder='请输入候选答案(选填)'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
|
||||
"</li><div class='cl'></div>");
|
||||
}
|
||||
function remove_single_answer(doc)
|
||||
{
|
||||
if(doc.parent().siblings("li").length == 0)
|
||||
{
|
||||
alert("选择题至少有一个选项");
|
||||
}
|
||||
else
|
||||
{
|
||||
doc.parent().remove();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="homepageRight mt0 ml10">
|
||||
<div class="resources">
|
||||
<!-- 头部 -->
|
||||
<div id="polls_head_show" style="display: none;">
|
||||
<%= render :partial => 'show_head', :locals => {:exercise => @exercise}%>
|
||||
</div>
|
||||
<div id="polls_head_edit">
|
||||
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
|
||||
</div>
|
||||
<% current_score = get_current_score @exercise %>
|
||||
<div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%=current_score %>分</span></div>
|
||||
<!-- 问题 -->
|
||||
<div id="poll_content">
|
||||
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
|
||||
</div>
|
||||
|
||||
<div class="testQuestion" id="new_exercise_question">
|
||||
<%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
|
||||
</div><!--选项 end-->
|
||||
|
||||
<!-- 新增问题 -->
|
||||
<div id="new_poll_question">
|
||||
</div>
|
||||
|
||||
<div id="exercise_submit">
|
||||
<%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!--contentbox end-->
|
||||
</div>
|
||||
</div><!--编辑end-->
|
||||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#RSide").removeAttr("id");
|
||||
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
|
||||
$("#Container").css("width","1000px");
|
||||
});
|
||||
//编辑问卷描述之后
|
||||
var popWindow ; //弹出框的引用
|
||||
var importPollPopWindow; //选择导入的弹出框引用
|
||||
function edit_head(){
|
||||
$("#polls_description").val($("#polls_description_div").html());
|
||||
}
|
||||
$(function(){
|
||||
//点击空白处
|
||||
$(document).bind('click',function(e){
|
||||
//弹出框非空 不是a标签 点击的不是弹出框 ,那么弹出框就会隐藏
|
||||
if(popWindow && e.target.nodeName != 'A' && !popWindow.is(e.target) && popWindow.has(e.target).length === 0){ // Mark 1
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
if(importPollPopWindow && e.target.nodeName != 'A' && !importPollPopWindow.is(e.target) && importPollPopWindow.has(e.target).length === 0){
|
||||
importPollPopWindow.css('display', 'none');
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
function dismiss(quest_type,quest_id){
|
||||
popWindow = $("#div_"+quest_type+"_"+quest_id);
|
||||
if(popWindow){
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
function chooseQuestionType(quest_type,quest_id){
|
||||
//quest_type 分为 mc mcq single multi
|
||||
//quest_id 是quetion的id 下同
|
||||
if(popWindow){
|
||||
popWindow.css('display', 'none');
|
||||
}
|
||||
popWindow = $("#div_"+quest_type+"_"+quest_id);
|
||||
$("#div_"+quest_type+"_"+quest_id).click(function(e){
|
||||
e.stopPropagation(); //组织冒泡到document.body中去
|
||||
});
|
||||
$("#div_"+quest_type+"_"+quest_id).css("position", "absolute");
|
||||
|
||||
$("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30);
|
||||
|
||||
$("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10);
|
||||
if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') {
|
||||
$("#div_"+quest_type+"_"+quest_id).css('display', 'none');
|
||||
}
|
||||
else{
|
||||
$("#div_"+quest_type+"_"+quest_id).css('display', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
//选择导入调查问卷
|
||||
function importPoll(){
|
||||
importPollPopWindow = $("#import_poll");
|
||||
$("#import_poll").css("position", "absolute");
|
||||
|
||||
$("#import_poll").css("top", $("#import_btn").offset().top+30);
|
||||
|
||||
$("#import_poll").css("left", $("#import_btn").offset().left-65);
|
||||
$("#import_poll").css("display","block")
|
||||
}
|
||||
|
||||
function remote_import(){
|
||||
importPollPopWindow.css('display', 'none');
|
||||
if($("#import_poll").val() === 0){
|
||||
return;
|
||||
}else{
|
||||
if(confirm("确认导入问卷"+$("#import_poll").find("option:selected").text()+"?")){
|
||||
$("#import_form").submit();
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//添加标题时确定按钮
|
||||
function add_poll_question(doc,quest_type)
|
||||
{
|
||||
var title = $.trim($("#poll_questions_title").val());
|
||||
var score = $.trim($("#question_score").val());
|
||||
var standard_ans = $.trim($("#question_standard_ans").val());
|
||||
if(title.length == 0 || score.length == 0){
|
||||
alert("题目标题/分数不能为空");
|
||||
}else if(!/^[1-9][0-9]*$/.test(score)) {
|
||||
alert("分数必须是非零开头的数字");
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
//修改标题时确定按钮
|
||||
function edit_poll_question(doc,id,quest_type)
|
||||
{
|
||||
var title = $.trim($("#poll_questions_title_" + id).val());
|
||||
var score = $.trim($("#poll_question_score_"+ id).val());
|
||||
var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val());
|
||||
if(title.length == 0 || score.length == 0){
|
||||
alert("题目标题/分数不能为空");
|
||||
}else if(!/^[1-9][0-9]*$/.test(score)) {
|
||||
alert("分数必须是非零开头的数字");
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
}else if(quest_type ==3) {
|
||||
var div = $("#poll_answers_" + id);
|
||||
var candiate_answer = $(".candiate_answer",div);
|
||||
if(candiate_answer.length > 0) {
|
||||
for(i=0;i<candiate_answer.length;i++) {
|
||||
if(i<candiate_answer.length-1 && $.trim($(candiate_answer[i]).val()) == "") {
|
||||
continue;
|
||||
} else if(i == (candiate_answer.length-1) && $.trim($(candiate_answer[i]).val()) == "") {
|
||||
alert("候选答案不能为空");
|
||||
} else if($.trim($(candiate_answer[i]).val()) != ""){
|
||||
doc.parent().parent().parent().submit();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
} else{
|
||||
alert("候选答案不能为空");
|
||||
}
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsSubmit(doc){
|
||||
var title = $.trim($("#exercise_name").val());
|
||||
if(title.length == 0){
|
||||
alert("测验标题不能为空");
|
||||
} else if($.trim($("#exercise_end_time").val()) =="") {
|
||||
alert("截止时间不能为空");
|
||||
} else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) {
|
||||
alert("截止时间不能小于当前时间");
|
||||
} else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) {
|
||||
alert("测验时长必须为非零开头的数字");
|
||||
} else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) {
|
||||
alert("发布时间不能小于当前时间");
|
||||
} else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) {
|
||||
alert("截止时间不能小于发布时间");
|
||||
} else {
|
||||
doc.parent().parent().parent().submit();
|
||||
}
|
||||
}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
//
|
||||
function pollQuestionCancel(question_id){
|
||||
$("#show_poll_questions_"+question_id).show();
|
||||
$("#edit_poll_questions_"+question_id).hide();
|
||||
}
|
||||
function pollQuestionEdit(question_id){
|
||||
$("#show_poll_questions_"+question_id).hide();
|
||||
$("#edit_poll_questions_"+question_id).show();
|
||||
$("#poll_questions_title_"+question_id).focus();
|
||||
}
|
||||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
|
||||
"</li><div class='cl'></div>");
|
||||
}
|
||||
function add_candidate_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>候选答案<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='exercise_choice["+new Date().getTime()+"]' placeholder='请输入候选答案(选填)'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
|
||||
"</li><div class='cl'></div>");
|
||||
}
|
||||
function remove_single_answer(doc)
|
||||
{
|
||||
if(doc.parent().siblings("li").length == 0)
|
||||
{
|
||||
alert("至少有一个选项或一个候选答案");
|
||||
}
|
||||
else
|
||||
{
|
||||
doc.parent().remove();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="homepageRight mt0 ml10">
|
||||
<div class="resources">
|
||||
<!-- 头部 -->
|
||||
<div id="polls_head_show" style="display: none;">
|
||||
<%= render :partial => 'show_head', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
<div id="polls_head_edit">
|
||||
<%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
<% current_score = get_current_score @exercise %>
|
||||
<div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%= current_score %>
|
||||
分</span></div>
|
||||
<!-- 问题 -->
|
||||
<div id="poll_content">
|
||||
<%= render :partial => 'exercise_content', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
|
||||
<div class="testQuestion" id="new_exercise_question">
|
||||
<%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
<!--选项 end-->
|
||||
|
||||
<!-- 新增问题 -->
|
||||
<div id="new_poll_question">
|
||||
</div>
|
||||
|
||||
<div id="exercise_submit">
|
||||
<%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!--contentbox end-->
|
||||
</div>
|
||||
</div><!--编辑end-->
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
$("#RSide").removeAttr("id");
|
||||
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
|
||||
$("#Container").css("width","1000px");
|
||||
<%uncomplete_question =get_uncomplete_question(exercise, User.current) %>;
|
||||
<% if (uncomplete_question.count < 1) %>
|
||||
$("#exercise_submit_btn").html("提交");
|
||||
<% end %>
|
||||
var end_time = <%=exercise.end_time.to_i%>;
|
||||
getTime(end_time);
|
||||
/*start_time = new Date();
|
||||
start_time.setFullYear(<%#=exercise_user.start_at.year%>);
|
||||
start_time.setMonth(<%#=exercise_user.start_at.month%>);
|
||||
|
@ -17,11 +23,16 @@
|
|||
function getTime(end_time) {
|
||||
//alert(end_time);
|
||||
now = new Date();
|
||||
var total_seconds = (now.getTime() - end_time)/1000;
|
||||
var total_seconds = now.getTime()/1000 - end_time;
|
||||
if (total_seconds > 0) {
|
||||
$("#exercise_submit_btn").click();
|
||||
return;
|
||||
}
|
||||
setTimeout("getTime("+end_time+");", 1000);
|
||||
//start = new Date(start_time);
|
||||
//end_time = start_time;
|
||||
//var total_seconds = total_seconds - 1;
|
||||
var hours = total_seconds / 60 / 60;
|
||||
/*var hours = total_seconds / 60 / 60;
|
||||
var hoursRound = Math.floor(hours);
|
||||
var minutes = total_seconds /60 - (60 * hoursRound);
|
||||
var minutesRound = Math.floor(minutes);
|
||||
|
@ -29,9 +40,9 @@
|
|||
var secondsRound = Math.round(seconds);
|
||||
$("#rest_hours").html(hoursRound);
|
||||
$("#rest_minutes").html(minutesRound);
|
||||
$("#rest_seconds").html(secondsRound);
|
||||
$("#rest_seconds").html(secondsRound);*/
|
||||
//if(total_seconds >0) {
|
||||
setTimeout("getTime("+end_time+");", 1000);
|
||||
//setTimeout("getTime("+end_time+");", 1000);
|
||||
//}
|
||||
}
|
||||
</script>
|
||||
|
@ -41,8 +52,11 @@
|
|||
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||||
<div id="start_time" style="display: none"><%=exercise_user.start_at %></div>
|
||||
<div class="fontGrey2">
|
||||
<span class="mr130">开始时间:<%=format_time(exercise_user.start_at.to_s)%></span>
|
||||
<span class="mr130">测验时长:<%=exercise.time %>分钟</span>
|
||||
<span class="mr100">开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
||||
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
||||
<% unless exercise.time == -1 %>
|
||||
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
||||
<% end %>
|
||||
<!--
|
||||
<span class="fr">剩余时长:<span class="c_red" id="rest_hours"></span> 小时 <span class="c_red" id="rest_minutes"></span> 分钟 <span class="c_red" id="rest_seconds"></span> 秒</span>
|
||||
-->
|
||||
|
@ -90,6 +104,11 @@
|
|||
{
|
||||
obj.checked = false;
|
||||
}
|
||||
if(dataObj.complete == 1) {
|
||||
$("#exercise_submit_btn").html("提交");
|
||||
} else {
|
||||
$("#exercise_submit_btn").html("保存");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -144,6 +163,11 @@
|
|||
{
|
||||
obj.checked = false;
|
||||
}
|
||||
if(dataObj.complete == 1) {
|
||||
$("#exercise_submit_btn").html("提交");
|
||||
} else {
|
||||
$("#exercise_submit_btn").html("保存");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -186,12 +210,17 @@
|
|||
success: function (data) {
|
||||
var dataObj = eval(data);
|
||||
obj.value = dataObj.text;
|
||||
if(dataObj.complete == 1) {
|
||||
$("#exercise_submit_btn").html("提交");
|
||||
} else {
|
||||
$("#exercise_submit_btn").html("保存");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
<input class="fillInput" placeholder="在此填入答案" type="text" value="" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>>
|
||||
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %>" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -199,7 +228,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="ur_buttons">
|
||||
<%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
|
||||
<%= link_to "保存",commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!--contentbox end-->
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
<div class="testStatus"><!--头部显示 start-->
|
||||
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||||
<div class="fontGrey2">
|
||||
<span class="mr130">开始时间:<%=format_time(exercise_user.start_at.to_s) %></span>
|
||||
<span class="mr130">测验时长:<%=exercise.time %>分钟</span>
|
||||
<span class="mr100">开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S") %></span>
|
||||
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
||||
<% unless exercise.time == -1 %>
|
||||
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
||||
<% end %>
|
||||
<%# time = exercise_user.end_at - exercise_user.start_at %>
|
||||
</div>
|
||||
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
|
||||
|
@ -31,12 +34,12 @@
|
|||
<span class="ml15 c_red">
|
||||
<% answer = get_user_answer(exercise_question, User.current)%>
|
||||
<% standard_answer = get_user_standard_answer(exercise_question, User.current)%>
|
||||
<% if answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %>
|
||||
<% if !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %>
|
||||
√
|
||||
<% else %>
|
||||
×
|
||||
<% end %></span><br />
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
|
@ -70,7 +73,7 @@
|
|||
<span class="ml15 c_red">
|
||||
<% answer = get_user_answer(exercise_question, User.current)%>
|
||||
<% standard_answer = get_user_standard_answer(exercise_question, User.current)%>
|
||||
<% if get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %>
|
||||
<% if !standard_answer.empty? && get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %>
|
||||
√
|
||||
<% else %>
|
||||
×
|
||||
|
@ -109,12 +112,12 @@
|
|||
<span class="ml15 c_red">
|
||||
<% answer = get_user_answer(exercise_question, User.current)%>
|
||||
<% standard_answer = get_user_standard_answer(exercise_question, User.current)%>
|
||||
<% if standard_answer.include?(answer.first.answer_text) %>
|
||||
<% if !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %>
|
||||
√
|
||||
<% else %>
|
||||
×
|
||||
<% end %></span><br />
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
|
|
|
@ -19,14 +19,9 @@
|
|||
<% mc_count = exercise.exercise_questions.where("question_type=1").count %>
|
||||
<% mcq_count = exercise.exercise_questions.where("question_type=2").count %>
|
||||
<% single_count = exercise.exercise_questions.where("question_type=3").count %>
|
||||
<p class="f14">当前测验
|
||||
<% if question_count > 0 %>共有<%= question_count %>道题,其中<% end %>
|
||||
<% if mc_count > 0 %><%= mc_count %>道单选、<% end %>
|
||||
<% if mcq_count > 0 %><%= mcq_count %>道多选、<% end %>
|
||||
<% if single_count > 0%><%= single_count %>道填空,<% end %>
|
||||
总分为<span class="c_red"><%=current_score %></span>分。
|
||||
<p class="f14">当前测验<%if question_count >0%>共有<%= question_count %>道题,其中<%end%><%if mc_count > 0%><%=mc_count %>道单选、<%end%><%if mcq_count > 0%><%=mcq_count %>道多选、<%end%><%if single_count > 0%><%=single_count %>道填空,<%end%>总分为<span class="c_red"><%=current_score %></span>分。
|
||||
<br /><br />
|
||||
是否确定提交该测验?
|
||||
<% if exercise.publish_time.nil? %>点击提交后测验将立即发布,<% end %>是否确定提交该测验?
|
||||
</p>
|
||||
<div class="polls_btn_box">
|
||||
<a class="upload_btn" onclick="exercise_submit();">
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
<div class="testStatus"><!--头部显示 start-->
|
||||
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||||
<div class="fontGrey2">
|
||||
<span class="mr130">发布时间:<%=format_time(exercise.publish_time.to_s) %></span>
|
||||
<span class="mr130">截止时间:<%=format_time(exercise.end_time.to_s) %></span>
|
||||
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
||||
<% unless exercise.publish_time.nil? %>
|
||||
<span class="mr100">发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") %></span>
|
||||
<% end %>
|
||||
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") %></span>
|
||||
<% if exercise.time != -1 %>
|
||||
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
|
||||
<div class="cl"></div>
|
||||
|
@ -92,7 +96,7 @@
|
|||
<div>
|
||||
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
||||
<br />
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
|
||||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<div class="polls_head">
|
||||
<h2>所有试卷
|
||||
<span>(<%= @obj_count%>)</span>
|
||||
</h2>
|
||||
<% if @is_teacher%>
|
||||
<%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%>
|
||||
<%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div id="polls_list" class="polls_list">
|
||||
|
||||
<% @exercises.each do |exercise|%>
|
||||
<ul id="exercises_<%= exercise.id %>" class="polls_list_ul">
|
||||
<%= render :partial => 'exercise', :locals => {:exercise => exercise} %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="polls_head" style="width:730px;">
|
||||
<h2>所有试卷
|
||||
<span>(<%= @obj_count%>)</span>
|
||||
</h2>
|
||||
<% if @is_teacher%>
|
||||
<%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%>
|
||||
<%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div id="polls_list" class="polls_list">
|
||||
|
||||
<% @exercises.each_with_index do |exercise,index|%>
|
||||
<ul id="exercises_<%= exercise.id %>" class="polls_list_ul">
|
||||
<%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
||||
|
||||
<div class="cl"></div>
|
||||
</div><!--列表end-->
|
|
@ -1,60 +1,62 @@
|
|||
<%= form_for(ExerciseQuestion.new,
|
||||
:html => { :multipart => true },
|
||||
:url=>create_exercise_question_exercise_path(exercise.id),
|
||||
:remote=>true ) do |f| %>
|
||||
<div class="questionContainer">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="1" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %>
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<%= form_for(ExerciseQuestion.new,
|
||||
:html => { :multipart => true },
|
||||
:url=>create_exercise_question_exercise_path(exercise.id),
|
||||
:remote=>true ) do |f| %>
|
||||
<div class="questionContainer">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="1" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %>
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,60 +1,62 @@
|
|||
<%= form_for(ExerciseQuestion.new,
|
||||
:html => { :multipart => true },
|
||||
:url=>create_exercise_question_exercise_path(exercise.id),
|
||||
:remote=>true ) do |f| %>
|
||||
<div class="questionContainer">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="2" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %>
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<%= form_for(ExerciseQuestion.new,
|
||||
:html => { :multipart => true },
|
||||
:url=>create_exercise_question_exercise_path(exercise.id),
|
||||
:remote=>true ) do |f| %>
|
||||
<div class="questionContainer">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input name="question_type" value="2" type="hidden">
|
||||
<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %>
|
||||
<label>分数<span class="ur_index"></span>: </label>
|
||||
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>选项A<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项B<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项C<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>选项D<span class="ur_index"></span>: </label>
|
||||
<input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'>
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -8,7 +8,7 @@
|
|||
<input name="question_type" value="3" type="hidden">
|
||||
<input maxlength="250" class="questionTitle" name="question_title" id="poll_questions_title" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text">
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<div class="ur_editor_content" id="new_single">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %>
|
||||
|
@ -16,26 +16,28 @@
|
|||
<input id="question_score" value="<%= score%>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案一<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[0]" placeholder="请输入候选答案一" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案二<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[1]" placeholder="请输入候选答案二(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案三<span class="ur_index"></span>: </label>
|
||||
<input name="exercise_choice[2]" placeholder="请输入候选答案三(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案一<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[0]" placeholder="请输入候选答案一" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案二<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>候选答案三<span class="ur_index"></span>: </label>
|
||||
<input class="candiate_answer" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)" type="text">
|
||||
<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>
|
||||
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,111 +1,111 @@
|
|||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
<span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span>
|
||||
</div>
|
||||
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<table class="ur_table" style="width:675px;">
|
||||
<tbody>
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="radio" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
|
||||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!--单选题显示 end-->
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_mc_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_MC(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else{
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="1"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项B<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项C<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项D<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,在此输入A即可" type="text">'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
<span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span>
|
||||
</div>
|
||||
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<table class="ur_table" style="width:675px;">
|
||||
<tbody>
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="radio" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
|
||||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!--单选题显示 end-->
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_mc_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_MC(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else{
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="1"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项B<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项C<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项D<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,在此输入A即可" type="text">'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,109 +1,109 @@
|
|||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
<span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span>
|
||||
</div>
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<table class="ur_table" style="width:675px;">
|
||||
<tbody>
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="checkbox" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
|
||||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!--多选题显示 end-->
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_mcq_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_MCQ(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else {
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="2"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项B<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项C<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项D<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
}else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
<span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span>
|
||||
</div>
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<table class="ur_table" style="width:675px;">
|
||||
<tbody>
|
||||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="checkbox" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
|
||||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!--多选题显示 end-->
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_mcq_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_MCQ(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else {
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="2"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项A<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项B<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项C<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>选项D<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>标准答案<span class="ur_index"></span>: </label>'+
|
||||
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
}else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -3,9 +3,14 @@
|
|||
<!-- <a class='ur_icon_add' title='导入' id="import_btn" onclick="importPoll();"></a> -->
|
||||
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||||
<div class="fontGrey2">
|
||||
<span class="mr100">发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
|
||||
<span class="mr100">截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></span>
|
||||
<span>测验时长:<%= exercise.time %>分钟</span></div>
|
||||
<% unless exercise.publish_time.nil? %>
|
||||
<span class="mr100">发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
|
||||
<% end %>
|
||||
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></span>
|
||||
<% if exercise.time != -1 %>
|
||||
<span>测验时长:<%= exercise.time %>分钟</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
|
||||
<div class="cl"></div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
</div>
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||||
候选答案:<%= exercise_choice.answer_text%><br />
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_single_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_SINGLE(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else {
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="3"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案一<span class="ur_index"></span>: </label>'+
|
||||
'<input type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案二<span class="ur_index"></span>: </label>'+
|
||||
'<input type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案三<span class="ur_index"></span>: </label>'+
|
||||
'<input maxlength="200" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
} else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
<div>
|
||||
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
|
||||
<%= exercise_question.question_title %>
|
||||
</div>
|
||||
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
|
||||
<a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||||
候选答案:<%= exercise_choice.answer_text%><br />
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新增问题 -->
|
||||
<div id="insert_new_poll_question_single_<%=exercise_question.id%>">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function insert_SINGLE(quest_type,quest_num,quest_id){
|
||||
var forms = $("form.new_exercise_question");
|
||||
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
|
||||
if(forms.length > 0){
|
||||
alert("请先保存正在编辑的题目再新建。");
|
||||
} else {
|
||||
<% score =exercise_question.question_score %>
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
|
||||
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
|
||||
' <div class="questionContainer" style="width: 680px;"> '+
|
||||
'<div class="ur_editor_title"> '+
|
||||
'<label>问题: </label>'+
|
||||
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
|
||||
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
|
||||
'<input type="hidden" name="question_type" value="3"/>'+
|
||||
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_content" id="new_single">'+
|
||||
'<ul>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>分数<span class="ur_index"></span>: </label>'+
|
||||
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
|
||||
'</li><div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案一<span class="ur_index"></span>: </label>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案二<span class="ur_index"></span>: </label>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li>'+
|
||||
'<div class="cl"></div>'+
|
||||
'<li class="ur_item">'+
|
||||
'<label>候选答案三<span class="ur_index"></span>: </label>'+
|
||||
'<input class="candiate_answer" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+
|
||||
'<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+
|
||||
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
|
||||
'</li></div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
'<%= l(:button_cancel)%>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'<div class="cl"></div>'+
|
||||
'</div>'+
|
||||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
} else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,4 +1,4 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>');
|
||||
showModal('ajax-modal', '270px');
|
||||
$('#ajax-modal').css('height','110px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
|
|
|
@ -1,63 +1,68 @@
|
|||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<script type="text/javascript">
|
||||
function republish_exercise(exercise_id)
|
||||
{
|
||||
$('#ajax-modal').html("<div id='popbox02'>" +
|
||||
"<div class='upload_con'>" +
|
||||
"<div class='upload_box'>" +
|
||||
"<p class='polls_box_p'>取消发布后学生答题将会被清空<br />是否确定取消发布该测验?</p>" +
|
||||
"<div class='polls_btn_box'>" +
|
||||
"<a href='/exercise/"+ exercise_id +"/republish_exercise' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" +
|
||||
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
showModal('ajax-modal', '310px');
|
||||
$('#ajax-modal').css('height','120px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
|
||||
function clickCanel(){hideModal("#popbox02");}
|
||||
|
||||
function exercise_submit(exercise_id,exercise_name)
|
||||
{
|
||||
if(exercise_name == 0)
|
||||
{
|
||||
alert("试卷标题不能为空");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#ajax-modal').html("<div id='popbox02'>" +
|
||||
"<div class='upload_con'>" +
|
||||
"<div class='upload_box'>" +
|
||||
"<p class='polls_box_p'>测验发布后将不能对测验进行修改,<br />是否确定发布该测验?</p>" +
|
||||
"<div class='polls_btn_box'>" +
|
||||
"<a href='/exercise/"+ exercise_id +"/publish_exercise' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" +
|
||||
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
showModal('ajax-modal', '310px');
|
||||
$('#ajax-modal').css('height','120px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="polls_content02" id="exercise">
|
||||
<%= render :partial => 'exercises_list'%>
|
||||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#RSide").css("width","730px");
|
||||
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
|
||||
$("#Container").css("width","1000px");
|
||||
});
|
||||
function republish_exercise(exercise_id,index)
|
||||
{
|
||||
$('#ajax-modal').html("<div id='popbox02'>" +
|
||||
"<div class='upload_con'>" +
|
||||
"<div class='upload_box'>" +
|
||||
"<p class='polls_box_p'>取消发布后学生答题将会被清空<br />是否确定取消发布该测验?</p>" +
|
||||
"<div class='polls_btn_box'>" +
|
||||
"<a href='/exercise/"+ exercise_id +"/republish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" +
|
||||
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
showModal('ajax-modal', '310px');
|
||||
$('#ajax-modal').css('height','120px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
|
||||
function clickCanel(){hideModal("#popbox02");}
|
||||
|
||||
function exercise_submit(exercise_id,exercise_name,index)
|
||||
{
|
||||
if(exercise_name == 0)
|
||||
{
|
||||
alert("试卷标题不能为空");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#ajax-modal').html("<div id='popbox02'>" +
|
||||
"<div class='upload_con'>" +
|
||||
"<div class='upload_box'>" +
|
||||
"<p class='polls_box_p'>测验发布后将不能对测验进行修改,<br />是否确定发布该测验?</p>" +
|
||||
"<div class='polls_btn_box'>" +
|
||||
"<a href='/exercise/"+ exercise_id +"/publish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" +
|
||||
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
showModal('ajax-modal', '310px');
|
||||
$('#ajax-modal').css('height','120px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="polls_content02" id="exercise" style="width: 730px;">
|
||||
<%= render :partial => 'exercises_list'%>
|
||||
</div><!--问卷内容end-->
|
|
@ -1,4 +1,4 @@
|
|||
$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>");
|
||||
$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>");
|
||||
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>");
|
||||
showModal('ajax-modal', '250px');
|
||||
//$('#ajax-modal').css('height','111px');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>");
|
||||
$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>");
|
||||
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>");
|
||||
showModal('ajax-modal', '250px');
|
||||
//$('#ajax-modal').css('height','80px');
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<ul>
|
||||
<% @all_exercises.each_with_index do |exercise,index |%>
|
||||
<li class="pr10">
|
||||
<%= link_to "作业#{@all_exercises.count - index}:#{exercise.exercise_name}",''%>
|
||||
<%= link_to "测验#{@all_exercises.count - index}:#{exercise.exercise_name}",student_exercise_list_exercise_path(exercise.id,:course_id => @course.id)%>
|
||||
<%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
|
||||
</li>
|
||||
<% end%>
|
||||
|
|
|
@ -136,50 +136,125 @@
|
|||
</div>
|
||||
|
||||
<div class="subNavBox">
|
||||
<% unless show_nav?(@course.course_activities.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
|
||||
<!--暂时不显示课程动态数,优化后在显示-->
|
||||
<%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(@course.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
<%= link_to "(#{@course.homework_commons.count})", homework_common_index_path(:course => @course.id), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_homework_new)}", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(@course.news.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.news.count})", course_news_index_path(@course), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_file_num) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{course_file_num})", course_files_path(@course), :class => "subnav_num c_orange",:id=>'courses_files_count_nav' %>
|
||||
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||
<a class="subnav_green ml95 c_white" href="javascript:void(0);" onclick="course_files_upload();">+上传资源 </a>
|
||||
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_message_new)}",course_boards_path(@course, :flag => true, :is_new => 1),:class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_feedback_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{course_feedback_count})", course_feedback_path(@course), :class => "subnav_num c_orange", :id => "course_jour_count"%>
|
||||
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_poll_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{course_poll_count})", poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_new_poll)}", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+新建试卷", new_exercise_path(:course_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%# 工具栏展开 %>
|
||||
<% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
|
||||
course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %>
|
||||
<div class="subNav subNav_jiantou" id="expand_tools_expand" nhtype="toggle4cookie" data-id="expand_tool_more" data-target="#navContentCourse" data-val="retract"><%= l(:label_project_more) %></div>
|
||||
<ul class="navContent" id="navContentCourse">
|
||||
<%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div><!--项目侧导航 end-->
|
||||
<%# 课程贡献榜 %>
|
||||
<div class="cl"></div>
|
||||
<% unless contributor_course_scor(@course.id).count == 0 %>
|
||||
<ul class="rankList">
|
||||
<h4>课程贡献榜</h4>
|
||||
<% contributor_course_scor(@course.id).each do |contributor_score| %>
|
||||
<% unless contributor_score.total_score ==0 %>
|
||||
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a>
|
||||
<p><a href="javascript:void:(0);"><%=link_to contributor_score.user, user_path(contributor_score.user), :title => contributor_score.user %></a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">
|
||||
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p>
|
||||
<div style="display: none" class="numIntro">
|
||||
<% unless contributor_score.resource_num == 0 %>
|
||||
课程资源:<%= contributor_score.resource_num %><br />
|
||||
<% end %>
|
||||
<% unless contributor_score.message_num == 0 %>
|
||||
课程讨论:<%= contributor_score.message_num %><br />
|
||||
<% end %>
|
||||
<% unless contributor_score.message_reply_num == 0 %>
|
||||
评论回复:<%= contributor_score.message_reply_num %><br />
|
||||
<% end %>
|
||||
<% unless contributor_score.journal_num == 0 %>
|
||||
课程留言:<%= contributor_score.journal_num %><br />
|
||||
<% end %>
|
||||
<% unless contributor_score.news_reply_num == 0 %>
|
||||
课程通知:<%= contributor_score.news_reply_num %><br />
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% hero_homework_scores = hero_homework_score(@course, "desc") %>
|
||||
<% unless hero_homework_scores.map(&:score).detect{|s| s != nil}.nil? %>
|
||||
<ul class="rankList">
|
||||
<h4>课程英雄榜</h4>
|
||||
<% hero_homework_scores.each do |student_score| %>
|
||||
<% unless student_score.score.nil? %>
|
||||
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a>
|
||||
<p><a href="javascript:void:(0);"><%=link_to student_score.user, user_path(student_score.user), :title => student_score.user %></a></p>
|
||||
<p><span class="c_red" style="cursor:pointer" title="作业总分:<%= student_score.score %>"><%= student_score.score.to_i %></span></p>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<div class="project_intro">
|
||||
<div id="course_description" class="course_description">
|
||||
<h4 ><%= l(:label_course_brief_introduction)%>:</h4>
|
||||
|
@ -278,6 +353,16 @@
|
|||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
// 鼠标经过的时候显示内容
|
||||
function message_titile_show(obj,e)
|
||||
{
|
||||
obj.parent().parent().next("div").show();
|
||||
obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute");
|
||||
}
|
||||
function message_titile_hide(obj)
|
||||
{
|
||||
obj.parent().parent().next("div").hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<% else %>
|
||||
<%= link_to l(:project_module_repository),({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).identifier}), :class => "f14 c_blue02" %>
|
||||
<% end %>
|
||||
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
|
||||
<!--<a class="subnav_num">(<%= @project.repositories.count %>)</a>-->
|
||||
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) && rep_is_gitlab?(@project) %>
|
||||
<%= link_to "+"+l(:project_gitlab_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %>
|
||||
<% end %>
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<span class="pic_add fl mr5 mt3"></span><span class="f14 fontBlue fl">关联组织</span>
|
||||
<div class="cl mb5"></div>
|
||||
<%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %>
|
||||
<input type="text" name="orgs" class="searchOrg mb5 ml20" placeholder="请输入组织名称" />
|
||||
<div id="search_orgs_result_list" class="ml20"></div>
|
||||
<ul id="paginator" class="wlist ml20" style="float:none;"></ul>
|
||||
<input type="text" name="orgs" class="searchOrg mb5 ml20" placeholder="请输入组织名称" />
|
||||
<div id="search_orgs_result_list" class="ml20"></div>
|
||||
<ul id="paginator" class="wlist ml20" style="float:none;"></ul>
|
||||
<a href="javascript:void(0);" class="saveBtn db fl ml20 mr15 mb5" onclick="join_org(<%= @project.id %>);">关联</a>
|
||||
<a href="javascript:void(0);" class="cancelBtn db fl" onclick="cancel_join_orgs();">取消</a>
|
||||
<a href="javascript:void(0);" class="cancelBtn db fl" onclick="cancel_join_orgs();">取消</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="relatedList fr">
|
||||
|
|
|
@ -111,4 +111,4 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= paginate @events_pages, :left => 3, :right => 3 %>
|
||||
<%= paginate @events_pages, :left => 3, :right => 3 %>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<div class="git_usr_title">
|
||||
<%=link_to @project.owner, user_path(@project.owner), :class => "repository-title-dec" %>
|
||||
/
|
||||
<span><%= link_to @repository.identifier.present? ? h(@repository.identifier) : 'root',
|
||||
{:action => 'show', :id => @project,
|
||||
:repository_id => @repository.identifier_param,
|
||||
:path => nil, :rev => @rev },
|
||||
:class => "repository-title-dec"
|
||||
%>
|
||||
/
|
||||
<%=link_to @project.owner, user_path(@project.owner), :class => "repository-title-dec" %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<!--<th><%= l(:field_comments) %></th>-->
|
||||
<!--</tr></thead>-->
|
||||
<tbody>
|
||||
|
||||
<% show_diff = revisions.size > 1 %>
|
||||
<% line_num = 1 %>
|
||||
<% revisions.each do |changeset| %>
|
||||
|
@ -48,4 +49,9 @@
|
|||
<%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>
|
||||
</p>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
<%= render_properties(@properties) %>
|
||||
|
||||
<div class="mt10">
|
||||
<%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @commits, :entry => @entry }) unless @commits.empty? %>
|
||||
|
||||
<%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path ,:revisions => @commits, :entry => @entry ,:commits_pages =>@commits_pages , :commits_count => @commits_count}) unless @commits.empty? %>
|
||||
|
||||
</div>
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag "scm" %>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<div class="project_r_h">
|
||||
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||
</div>
|
||||
<%= form_for('forked',:url => {:controller => 'repositories', :action => 'forked'},:method => "post") do |f| %>
|
||||
<input type="text" name="repo_name"/>
|
||||
<button type="submit">确定</button>
|
||||
<% end %>
|
||||
<%= @project.id %>
|
||||
<%= @repository.id %>
|
||||
<%= User.current %>
|
|
@ -26,21 +26,30 @@
|
|||
<a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a>
|
||||
<div class="fl mt5 ml15"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_zip"></span>ZIP</a> </div>
|
||||
<div class="fr mt5"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_fork"></span>Fork</a> <span href="javascript:void(0);" class="vl_btn_2 fb">0</span> </div>
|
||||
<!--<div class="fr mt5"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_fork"></span><%= link_to "Fork", :controller => 'repositories', :action => 'forked' %></a> <span href="javascript:void(0);" class="vl_btn_2 fb">0</span> </div>-->
|
||||
<div class="cl"></div>
|
||||
<div class="recordBanner mt10">
|
||||
<% if @changesets && !@changesets.empty? %>
|
||||
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
|
||||
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %></div>
|
||||
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:</div>
|
||||
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
|
||||
</span>
|
||||
<% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
|
||||
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
|
||||
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %></div>
|
||||
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:</div>
|
||||
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=@changesets_latest_coimmit.author_email %></div>
|
||||
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:</div>
|
||||
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
|
||||
</span>
|
||||
<%end%>
|
||||
<% end %>
|
||||
<span class="fr mr5 "><font class="fb ml2 mr2 vl_branch mt2">
|
||||
<%= @repository.branches.count %></font> 个分支
|
||||
</span>
|
||||
|
||||
<span class="fr mr5"><font class="fb ml2 mr2 vl_commit">
|
||||
<%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev} %></font> 提交
|
||||
<%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %></font> 提交
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<div id="popbox02">
|
||||
<div class="ni_con">
|
||||
<div><p align='center' style='margin-top: 35px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
|
||||
<div class="cl"></div>
|
||||
<div class="ni_btn mt10">
|
||||
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||
编 辑
|
||||
</a>
|
||||
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||
取 消
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function clickOK() {
|
||||
window.location.href = '<%= edit_student_work_path(@work.id)%>';
|
||||
}
|
||||
function clickCanel() {
|
||||
hideModal('#popbox02');
|
||||
window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>';
|
||||
}
|
||||
</script>
|
|
@ -1,4 +1,12 @@
|
|||
<% if @submit_result%>
|
||||
<% if @has_commit %>
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/has_commit_work') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
<% elsif @submit_result%>
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
|
|
|
@ -201,7 +201,7 @@ default:
|
|||
judge_server: 'http://judge.trustie.net/'
|
||||
|
||||
# Git's url
|
||||
gitlab_address: 'http://git.trustie.net'
|
||||
gitlab_address: 'http://gitfast.trustie.net'
|
||||
|
||||
# specific configuration options for production environment
|
||||
# that overrides the default ones
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
Gitlab.configure do |config|
|
||||
# config.endpoint = 'http://192.168.41.130:3000/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
|
||||
# config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
||||
config.endpoint = 'http://git.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
|
||||
config.private_token = 'kZUYYbAY12QSQ2Tx1zes' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
||||
config.endpoint = 'http://gitfast.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
|
||||
config.private_token = 'fPc_gBmEiSANve8TCfxW' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
||||
# Optional
|
||||
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
|
||||
# config.sudo = 'user' # username for sudo mode, default: nil
|
||||
|
|
|
@ -94,4 +94,6 @@ zh:
|
|||
label_user_name: "用户名称"
|
||||
#setting end
|
||||
|
||||
label_course_poll: 课程问卷
|
||||
label_course_poll: 课程问卷
|
||||
|
||||
label_homework_committed: 你已经提交过作品,如果你想修改作品的话,可以在作品列表页面对作品信息进行修改。
|
|
@ -89,6 +89,8 @@ zh:
|
|||
project_module_repository: 版本库
|
||||
project_module_create_repository: 创建版本库
|
||||
project_gitlab_create_repository: 新版本库
|
||||
project_gitlab_create_double_message: 亲,您已经创建了一个同名的版本库,换个特别点的名字同名的概率就会变小哦~
|
||||
project_gitlab_fork_double_message: 亲,您已经有了一个相同名字的版本库,所以不能fork改版本库~
|
||||
|
||||
|
||||
label_project_more: 更多
|
||||
|
|
|
@ -643,6 +643,7 @@ RedmineApp::Application.routes.draw do
|
|||
# get 'create', :via=>[:get, :post]
|
||||
end
|
||||
end
|
||||
|
||||
match 'wiki/index', :via => :get
|
||||
resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
|
||||
member do
|
||||
|
@ -740,6 +741,7 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes'
|
||||
|
||||
get 'projects/:id/repository/forked', :to => 'repositories#forked'
|
||||
get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
|
||||
get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
|
||||
get 'projects/:id/repository/revision', :to => 'repositories#revision'
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration
|
||||
def up
|
||||
# count = CourseActivity.all.count/30 + 1
|
||||
# for i in 1 ... count do
|
||||
# transaction do
|
||||
# CourseActivity.page(i).per(30).each do |course_act|
|
||||
# if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil?
|
||||
# org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first
|
||||
# org_activity.created_at = course_act.created_at
|
||||
# org_activity.save
|
||||
# else
|
||||
# OrgActivity.create(:user_id => course_act.user_id,
|
||||
# :org_act_id => course_act.course_act_id,
|
||||
# :org_act_type => course_act.course_act_type,
|
||||
# :container_id => course_act.course_id,
|
||||
# :container_type => 'Course',
|
||||
# :created_at => course_act.created_at,
|
||||
# :updated_at => course_act.updated_at)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
count = CourseActivity.all.count/30 + 1
|
||||
for i in 1 ... count do
|
||||
transaction do
|
||||
CourseActivity.page(i).per(30).each do |course_act|
|
||||
if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil?
|
||||
org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first
|
||||
org_activity.created_at = course_act.created_at
|
||||
org_activity.save
|
||||
else
|
||||
OrgActivity.create(:user_id => course_act.user_id,
|
||||
:org_act_id => course_act.course_act_id,
|
||||
:org_act_type => course_act.course_act_type,
|
||||
:container_id => course_act.course_id,
|
||||
:container_type => 'Course',
|
||||
:created_at => course_act.created_at,
|
||||
:updated_at => course_act.updated_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class ChangecolumnOfExerciseQuestion < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :exercise_questions, :question_title, :text
|
||||
change_column :exercises, :exercise_name, :text
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class CreateCourseContributorScores < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :course_contributor_scores do |t|
|
||||
t.integer :course_id
|
||||
t.integer :user_id
|
||||
t.integer :message_num
|
||||
t.integer :message_reply_num
|
||||
t.integer :news_reply_num
|
||||
t.integer :resource_num
|
||||
t.integer :journal_num
|
||||
t.integer :journal_reply_num
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddTotalScoreToCourseContributorScore < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_contributor_scores, :total_score, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
class AddCourseContributorTotalScore < ActiveRecord::Migration
|
||||
def up
|
||||
# course_count = Course.all.count / 30 + 1
|
||||
# transaction do
|
||||
# for i in 1 ... course_count do i
|
||||
Course.all.each do |course|
|
||||
if course.course_activities.count > 1
|
||||
course.student.each do |s|
|
||||
puts course.id
|
||||
puts course.name
|
||||
puts s.student_id
|
||||
# board_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?",s.student_id, course.id, "Message").count * 2
|
||||
board_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is null;").count * 2
|
||||
message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null").count * 1
|
||||
common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1
|
||||
# attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
|
||||
attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id};").count * 5
|
||||
journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.student_id, course.id, "Course").count * 1
|
||||
# journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
|
||||
# journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1
|
||||
total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count
|
||||
if total !=0
|
||||
CourseContributorScore.create(:course_id => course.id, :user_id => s.student_id, :message_num => board_count, :message_reply_num => message_reply_count,
|
||||
:news_reply_num => common_reply_count, :resource_num => attachment_count, :journal_num => journal_count, :journal_reply_num => 0, :total_score => total)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
3704
db/schema.rb
3704
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -239,6 +239,12 @@ class Gitlab::Client
|
|||
delete("/projects/#{project}/hooks/#{id}")
|
||||
end
|
||||
|
||||
# Forks a project into the user namespace of the authenticated user.
|
||||
# @param [Integer] - The ID of the project to be forked
|
||||
def fork(id)
|
||||
post("/projects/fork/#{id}")
|
||||
end
|
||||
|
||||
# Mark this project as forked from the other
|
||||
#
|
||||
# @example
|
||||
|
|
|
@ -12,19 +12,15 @@ namespace :sync_rep do
|
|||
puts count
|
||||
unless count > 1
|
||||
rep.identifier
|
||||
puts "################################"
|
||||
puts project.id
|
||||
puts rep.id
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
s.sync_project(project, path: rep.identifier, import_url: rep.url)
|
||||
rep.type = 'Repository::Gitlab'
|
||||
rep.save
|
||||
puts "*************************************"
|
||||
puts project.id
|
||||
puts rep.id
|
||||
puts rep.identifier
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task :delete_rep => :environment do
|
||||
end
|
||||
end
|
|
@ -1,60 +1,63 @@
|
|||
#coding=utf-8
|
||||
#
|
||||
#
|
||||
module Trustie
|
||||
module Gitlab
|
||||
|
||||
module ManageMember
|
||||
def self.included(base)
|
||||
base.class_eval {
|
||||
before_create :add_gitlab_member
|
||||
before_destroy :delete_gitlab_member
|
||||
after_save :change_gitlab_member
|
||||
}
|
||||
end
|
||||
|
||||
def change_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def add_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def delete_gitlab_member
|
||||
if isGitlabProject?
|
||||
if member.roles.count <=1
|
||||
@g ||= ::Gitlab.client
|
||||
@g.remove_team_member(project.gpid, self.member.user.gid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def project
|
||||
self.member.project
|
||||
end
|
||||
|
||||
def repository
|
||||
unless project.nil?
|
||||
project.repository
|
||||
end
|
||||
end
|
||||
|
||||
def isGitlabProject?
|
||||
unless repository.nil?
|
||||
repository && repository.gitlab?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
#coding=utf-8
|
||||
#
|
||||
#
|
||||
module Trustie
|
||||
module Gitlab
|
||||
|
||||
module ManageMember
|
||||
def self.included(base)
|
||||
base.class_eval {
|
||||
before_create :add_gitlab_member
|
||||
before_destroy :delete_gitlab_member
|
||||
after_save :change_gitlab_member
|
||||
}
|
||||
end
|
||||
|
||||
def change_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def add_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
if self.member.user.gid.nil?
|
||||
add_user(self.member.user)
|
||||
end
|
||||
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def delete_gitlab_member
|
||||
if isGitlabProject?
|
||||
if member.roles.count <=1
|
||||
@g ||= ::Gitlab.client
|
||||
@g.remove_team_member(project.gpid, self.member.user.gid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def project
|
||||
self.member.project
|
||||
end
|
||||
|
||||
def repository
|
||||
unless project.nil?
|
||||
project.repository
|
||||
end
|
||||
end
|
||||
|
||||
def isGitlabProject?
|
||||
unless repository.nil?
|
||||
repository && repository.gitlab?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module Trustie
|
|||
base.class_eval {
|
||||
#before_create :add_gitlab_user
|
||||
#before_destroy :delete_gitlab_user
|
||||
before_save :change_gitlab_user
|
||||
#before_save :change_gitlab_user
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -22,10 +22,10 @@ module Trustie
|
|||
def delete_gitlab_user
|
||||
del_user(self)
|
||||
end
|
||||
|
||||
def change_gitlab_user
|
||||
change_password(self.gid, self.hashed_password, self.salt)
|
||||
end
|
||||
#
|
||||
#def change_gitlab_user
|
||||
# change_password(self.gid, self.hashed_password, self.salt)
|
||||
#end
|
||||
|
||||
def g
|
||||
@g ||= ::Gitlab.client
|
||||
|
|
|
@ -73,11 +73,6 @@ module Trustie
|
|||
|
||||
# import url http://xianbo_trustie2:1234@repository.trustie.net/xianbo/trustie2.git
|
||||
# can use password
|
||||
puts "@@@@@@@@@@@@@@@@@@@@@@@"
|
||||
puts path
|
||||
puts project.description
|
||||
puts gid
|
||||
puts import_url
|
||||
gproject = self.g.create_project(path,
|
||||
path: path,
|
||||
description: project.description,
|
||||
|
@ -91,7 +86,6 @@ module Trustie
|
|||
import_url: import_url,
|
||||
visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE
|
||||
)
|
||||
puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
|
||||
project.gpid = gproject.id
|
||||
project.save!
|
||||
puts "Successfully created #{project.name}"
|
||||
|
|
|
@ -1306,3 +1306,60 @@ function cancel_org_course_relation(id, courseId){
|
|||
// alert('<%= @course.id%>')
|
||||
// })
|
||||
//})
|
||||
|
||||
//项目点击展开
|
||||
function expand_tools_expand(content) {
|
||||
if (content == "invit") {
|
||||
$("#expand_tools_expand_invit").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
|
||||
$("#expand_tools_expand_invit").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
|
||||
$("#expand_tools_expand_invit").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
|
||||
}
|
||||
else {
|
||||
// $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
|
||||
// $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
|
||||
// $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
|
||||
$("#navContent").toggle(500);
|
||||
}
|
||||
|
||||
// 修改数字控制速度, slideUp(500)控制卷起速度
|
||||
}
|
||||
|
||||
//通过cookie存储伸开形式
|
||||
$(function(){
|
||||
var personalized_expand_key = "personalized_expand";
|
||||
function personalized_init(){
|
||||
var personalized_map = cookieget(personalized_expand_key);
|
||||
if(personalized_map!=false){
|
||||
personalized_map = JSON.parse(personalized_map);
|
||||
$("*[nhtype='toggle4cookie']").each(function(){
|
||||
var personalized_id=$(this).data('id');
|
||||
var val = personalized_map[personalized_id];
|
||||
if(val!=undefined && val!=$(this).data('val')){
|
||||
personalized_click($(this),0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function personalized_click(obj,timeout){
|
||||
var target = $(obj.data('target'));
|
||||
var oldval = obj.data('val');
|
||||
var val='';
|
||||
if(oldval=='expand'){val='retract';}else{val='expand';}
|
||||
obj.data('val',val);
|
||||
var personalized_map = cookieget(personalized_expand_key);
|
||||
if(personalized_map == false){
|
||||
personalized_map={};
|
||||
}else{
|
||||
personalized_map = JSON.parse(personalized_map);
|
||||
}
|
||||
var personalized_id=obj.data('id');
|
||||
personalized_map[personalized_id]=val;
|
||||
cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
|
||||
target.toggle(timeout);
|
||||
}
|
||||
$("*[nhtype='toggle4cookie']").on('click',function(){
|
||||
personalized_click($(this),500);
|
||||
});
|
||||
|
||||
personalized_init();
|
||||
});
|
|
@ -1156,7 +1156,7 @@ a:hover.btn_cancel{ color:#666;}
|
|||
.mr118 {margin-right:118px !important;}
|
||||
.questionContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;}
|
||||
.questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;}
|
||||
.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
|
||||
.examTime {width:90px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
|
||||
.testStatus{width:698px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px; background:#ffffff; position:relative; color:#767676;}
|
||||
.testEdit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;}
|
||||
a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
|
||||
|
@ -1166,4 +1166,14 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
|
|||
.questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;}
|
||||
.fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;}
|
||||
.mr130 {margin-right:130px;}
|
||||
.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; }
|
||||
.mr100 {margin-right:100px;}
|
||||
.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; }
|
||||
|
||||
/*20151123课程排行榜Tim*/
|
||||
.courseMenuSetting {background:url(../images/homepage_icon2.png) -190px -365px no-repeat; width:15px; height:15px; margin-top:3px; float:right; margin-right:5px;}
|
||||
.courseMenuSetting:hover {background:url(../images/homepage_icon2.png) -190px -407px no-repeat;}
|
||||
.rankList {width:220px; padding:10px; background-color:#ffffff; margin-top:10px;}
|
||||
.rankList li {width:73px; padding:8px 0px 0px 0px; text-align:center; float:left; position:relative;}
|
||||
.rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;word-wrap: normal; word-break: normal;}
|
||||
.rankPortrait {border-radius:50%; width:35px; height:35px;}
|
||||
.numIntro {position:absolute; text-align:left; z-index:999; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); border:1px solid #eaeaea; background-color:#ffffff; padding:3px 5px; left:15px; color:#585858; white-space: nowrap;}
|
|
@ -89,7 +89,7 @@ a:hover.btn_cancel{ color:#666;}
|
|||
.ur_question_title{ width:534px; height:30px; border:1px solid #cbcbcb; padding-left:5px; margin-right:10px; background:#fff;}
|
||||
.ur_editor_title{ margin-bottom:10px;}
|
||||
.ur_editor_content{ }
|
||||
.ur_item{ margin-bottom:5px; height:32px; }
|
||||
.ur_item{ margin-bottom:5px; height:32px; line-height: 32px; vertical-align: middle; }
|
||||
.ur_item input{ width:324px; height:30px;border:1px solid #cbcbcb; padding-left:5px; float:left; margin-right:10px; background:#fff;}
|
||||
.ur_item label{ float:left;}
|
||||
.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;}
|
||||
|
|
|
@ -220,7 +220,7 @@
|
|||
.vl_branch {background:url(../images/vlicon/branch_icon.png) 0px -2px no-repeat; padding-left:22px}
|
||||
.mt1 {margin-top:1px;}
|
||||
.mt2 {margin-top:2px;}
|
||||
.commit_content_dec{width: 300px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
|
||||
.commit_content_dec{width: 200px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
|
||||
|
||||
/*提交信息列表*/
|
||||
.col-md-10 {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
FactoryGirl.define do
|
||||
factory :course_contributor_score do
|
||||
course_id 1
|
||||
user_id 1
|
||||
message_num 1
|
||||
message_reply_num 1
|
||||
news_reply_num 1
|
||||
resource_num 1
|
||||
journal_num 1
|
||||
journal_reply_num 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseContributorScore, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue