diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb new file mode 100644 index 000000000..c8e5bf27c --- /dev/null +++ b/app/controllers/exercise_controller.rb @@ -0,0 +1,607 @@ +class ExerciseController < ApplicationController + layout "base_courses" + + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise] + before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + include ExerciseHelper + + include ExerciseHelper + def index + remove_invalid_exercise(@course) + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + if @is_teacher + exercises = @course.exercises + else + exercises = @course.exercises.where(:exercise_status => 2) + end + @exercises = paginateHelper exercises,20 #分页 + respond_to do |format| + format.html + end + end + + def show + unless User.current.member_of_course?(@course) + render_403 + return + end + @exercise = Exercise.find params[:id] + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? + if @exercise.exercise_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) + render_403 + return + end + @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + @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) + + # 已提交问卷的用户不能再访问该界面 + if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + else + 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 + end + # @percent = get_percent(@exercise,User.current) + exercise_questions = @exercise.exercise_questions + @exercise_questions = paginateHelper exercise_questions,5 #分页 + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end + end + + def new + option = { + :exercise_name => "", + :course_id => @course.id, + :exercise_status => 1, + :user_id => User.current.id, + :time => "", + :end_time => "", + :publish_time => "", + :exercise_description => "", + :show_result => "", + :show_result => 1 + } + @exercise = Exercise.create option + if @exercise + redirect_to edit_exercise_url @exercise.id + end + end + + def create + if params[:exercise] + exercise = Exercise.find(params[:exercise_id]) if params[:exercise_id] + 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.publish_time = params[:exercise][:publish_time] + exercise.user_id = User.current.id + exercise.time = params[:exercise][:time] + exercise.course_id = params[:course_id] + exercise.exercise_status = 1 + if exercise.save + @exercise = exercise + respond_to do |format| + format.js + end + end + end + end + + def edit + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + + 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.publish_time = params[:exercise][:publish_time] + @exercise.show_result = params[:exercise][:show_result] + if @exercise.save + respond_to do |format| + format.js + end + else + render_404 + end + end + + def destroy + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? + if @exercise && @exercise.destroy + if @is_teacher + exercises = Exercise.where("course_id =?", @course.id) + else + exercises = Exercise.where("course_id =? and exercise_status =?", @course.id, 2) + end + @exercises = paginateHelper exercises,20 #分页 + respond_to do |format| + format.js + end + end + end + + # 统计结果 + def statistics_result + @exercise = Exercise.find(params[:id]) + exercise_questions = @exercise.exercise_questions + @exercise_questions = paginateHelper exercise_questions, 5 + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + + # 添加题目 + # question_type 1:单选 2:多选 3:填空题 + def create_exercise_question + question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] + option = { + :question_title => question_title, + :question_type => params[:question_type] || 1, + :question_number => params[:question_type] == "1"? @exercise.exercise_questions.where("question_type = 1").count + 1 : + (params[:question_type] == "2" ? (@exercise.exercise_questions.where("question_type = 2").count + 1) : + @exercise.exercise_questions.where("question_type = 3").count + 1), + :question_score => params[:question_score] + } + @exercise_questions = @exercise.exercise_questions.new option + # params[:question_answer] 题目选项 + if params[:question_answer] + for i in 1..params[:question_answer].count + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + question_option = { + :choice_position => i, + :choice_text => answer + } + @exercise_questions.exercise_choices.new question_option + end + end + # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 + if params[:quest_id] + @is_insert = true + if @exercise_questions.question_type == 1 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number + 1") + #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") + elsif @exercise_questions.question_type == 2 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number + 1") + else + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number + 1") + end + # @exercise_question_num = params[:quest_num].to_i + @exercise_questions.question_number = params[:quest_num].to_i + 1 + end + if @exercise_questions.save + # params[:exercise_choice] 标准答案参数 + # 问答题标准答案有三个,单独处理 + if @exercise_questions.question_type == 3 + for i in 1..params[:exercise_choice].count + standart_answer = ExerciseStandardAnswer.new + standart_answer.exercise_question_id = @exercise_questions.id + standart_answer.answer_text = params[:exercise_choice].values[i-1] + standart_answer.save + end + else + standart_answer = ExerciseStandardAnswer.new + standart_answer.exercise_question_id = @exercise_questions.id + if @exercise_questions.question_type == 1 + standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) + else + standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice]) + end + standart_answer.save + end + respond_to do |format| + format.js + end + end + + end + + # 修改题目 + # params[:exercise_question] The id of exercise_question + # params[:question_answer] eg:A、B、C选项 + def update_exercise_question + @exercise_question = ExerciseQuestion.find params[:exercise_question] + @exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] + @exercise_question.question_score = params[:question_score] + # 处理选项:如果选了某个选项,那么则要删除之前的选项 + if params[:question_answer] + @exercise_question.exercise_choices.each do |answer| + answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + end + for i in 1..params[:question_answer].count + question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1] + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + if question + question.choice_position = i + question.choice_text = answer + question.save + else + question_option = { + :choice_position => i, + :choice_text => answer + } + @exercise_question.exercise_choices.new question_option + end + end + end + # 更新标准答案 + if params[:exercise_choice] + if @exercise_question.question_type == 3 + # 删除不合理的选项 + @exercise_question.exercise_standard_answers.each do |answer| + answer.destroy unless params[:exercise_choice].keys.include? answer.id.to_s + end + for i in 1..params[:exercise_choice].count + # 找到对应的标准答案 + question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1] + # 标准答案值 + answer_standart = (params[:exercise_choice].values[i-1].nil? || params[:exercise_choice].values[i-1].empty?) ? l(:label_new_answer) : params[:exercise_choice].values[i-1] + if question_standart + question_standart.answer_text = answer_standart + question_standart.save + else + standart_answer_option = { + :answer_text => answer_standart + } + @exercise_question.exercise_standard_answers.new standart_answer_option + end + end + else + answer_standart = @exercise_question.exercise_standard_answers.first + answer_standart.exercise_choice_id = @exercise_question.question_type == 1 ? sigle_selection_standard_answer(params[:exercise_choice]) : multiselect_standard_answer(params[:exercise_choice]) + answer_standart.save + end + @exercise_question.save + respond_to do |format| + format.js + end + end + end + + # 删除题目 + def delete_exercise_question + @exercise_question = ExerciseQuestion.find params[:exercise_question] + @exercise = @exercise_question.exercise + + if @exercise_question.question_type == 1 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number - 1") + #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") + elsif @exercise_question.question_type == 2 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1") + else + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1") + end + # @exercise_question_num = params[:quest_num].to_i + # @exercise_questions.question_number = params[:quest_num].to_i - 1 + # + # exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}") + # exercise_questions.each do |question| + # question.question_number -= 1 + # question.save + # end + if @exercise_question && @exercise_question.destroy + respond_to do |format| + format.js + end + end + end + + # 发布试卷 + def publish_exercise + @exercise.exercise_status = 2 + @exercise.publish_time = Time.now + if @exercise.save + redirect_to exercise_index_url(:course_id=> @course.id) + end + end + + # 重新发布试卷 + # 重新发布的时候会删除所有的答题 + def republish_exercise + @exercise.exercise_questions.each do |exercise_question| + exercise_question.exercise_answers.destroy_all + end + @exercise.exercise_users.destroy_all + @exercise.exercise_status = 1 + @exercise.save + respond_to do |format| + format.js + end + end + + 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") + @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') + @show_all = true; + elsif !@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("user_id = ? and score is not NULL",User.current.id) + else + @exercise_users_list = [] + end + respond_to do |format| + format.html + end + end + + # 学生提交答卷,选中答案的过程中提交 + def commit_answer + eq = ExerciseQuestion.find(params[:exercise_question_id]) + # 已提交过的则不允许答题 + if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) + render :json => {:text => "failure"} + return + end + if eq.question_type == 1 + # 单选题 + ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id],User.current.id) + if ea.nil? + # 尚未答该题,添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + end + #修改该题对应答案 + ea.exercise_choice_id = params[:exercise_choice_id] + if ea.save + # 保存成功返回成功信息及当前以答题百分比 + @percent = get_percent(@exercise,User.current) + render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)} + else + #返回失败信息 + render :json => {:text => "failure"} + end + elsif eq.question_type == 2 + #多选题 + ea = ExerciseAnswer.find_by_exercise_choice_id_and_user_id(params[:exercise_choice_id],User.current.id) + if ea.nil? + #尚未答该题,添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + ea.exercise_choice_id = params[:exercise_choice_id] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => "ok",:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + else + #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案 + if ea.delete + @percent = get_percent(@exercise, User.current) + render :json => {:text => "false" ,:percent => format("%.2f" , @percent)} + else + render :json => {:text => "failure"} + end + end + elsif eq.question_type == 3 + #单行文本,多行文本题 + ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id], User.current.id) + if ea.nil? + # ea为空之前尚未答题,添加答案 + if params[:answer_text].nil? || params[:answer_text].blank? + #用户提交空答案,视作不作答 + @percent = get_percent(@exercise,User.current) + render :json => {:text => ea.answer_text,:percent => format("%.2f", @percent)} + else + #添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + ea.answer_text = params[:answer_text] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)} + else + render :json => {:text => "failure"} + end + end + else + # ea不为空说明用户之前已作答 + if params[:answer_text].nil? || params[:answer_text].blank? + # 用户提交空答案,视为删除答案 + if ea.delete + @percent = get_percent(@exercise,User.current) + render :json => {:text => ea.answer_text,:percent => format("%.2f", @percent)} + else + render :json => {:text => "failure"} + end + else + #用户修改答案 + ea.answer_text = params[:answer_text] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f", @percent)} + else + render :json => {:text => "failure"} + end + end + end + + else + render :json => {:text => "failure"} + end + end + + # 提交问卷 + def commit_exercise + # 老师不需要提交 + if User.current.allowed_to?(:as_teacher,@course) + @exercise.update_attributes(:show_result => params[:show_result]) + redirect_to exercise_url(@exercise) + # REDO: 提示提交成功 + else + # 更新提交状态 + cur_exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current, @exercise.id).first + cur_exercise_user.update_attributes(:status => 1) + # 答题过程中需要统计完成量 + @uncomplete_question = get_uncomplete_question(@exercise, User.current) + # 获取改学生的考试得分 + @score = calculate_student_score(@exercise, User.current) + # @score = 100 + if @uncomplete_question.count < 1 + # 查看是否有已提交记录 + eu = get_exercise_user(@exercise.id, User.current.id) + eu.user_id = User.current.id + eu.exercise_id = @exercise.id + eu.score = @score + if eu.save + #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') + @status = 0 #提交成功 + else + @status = 2 #未知错误 + end + else + @status = 1 #有未做得必答题 + end + respond_to do |format| + format.js + end + end + end + + # 计算学生得分 + def calculate_student_score(exercise, user) + score = 0 + score1 = 0 + score2 = 0 + score3 = 0 + exercise_qustions = exercise.exercise_questions + exercise_qustions.each do |question| + answer = get_user_answer(question, user) + standard_answer = get_user_standard_answer(question, user) + unless answer.nil? + # 问答题有多个答案 + if question.question_type == 3 + if standard_answer.include?(answer.first.answer_text) + score1 = score1+ question.question_score unless question.question_score.nil? + end + elsif question.question_type == 1 + if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id + score2 = score2 + question.question_score unless question.question_score.nil? + end + else + arr = get_mulscore(question, user) + if arr.to_i == standard_answer.exercise_choice_id + score3 = score3 + question.question_score unless question.question_score.nil? + end + # ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + # arr = [] + # ecs.each do |ec| + # arr << ec.exercise_choice.choice_position + # end + # arr.sort + # arr = arr.join("") + # if arr.to_i == standard_answer.exercise_choice_id + # score3 = score + question.question_score unless question.question_score.nil? + # end + end + end + end + score = score1 + score2 + score3 + end + + private + + # ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 + def get_exercise_user exercise_id,user_id + eu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id,user_id) + if eu.nil? + eu = ExerciseUser.new + end + 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 + user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") + user_answer + end + + # 获取问题的标准答案 + def get_user_standard_answer(question,user) + if question.question_type == 3 + standard_answer =[] + question.exercise_standard_answers.each do |answer| + standard_answer << answer.answer_text + end + else + standard_answer = question.exercise_standard_answers.first + end + standard_answer + end # 是否完成了答题 + def get_complete_question(exercise,user) + questions = exercise.exercise_questions + complete_question = [] + questions.each do |question| + answers = get_user_answer(question,user) + if !(answers.nil? || answers.count < 1) + complete_question << question + end + end + complete_question + end + + # 获取答题百分比 + def get_percent exercise,user + complete_count = get_complete_question(exercise,user).count + if exercise.exercise_questions.count == 0 + return 0 + else + return (complete_count.to_f / exercise.exercise_questions.count.to_f)*100 + end + end + + def remove_invalid_exercise(course) + exercises = course.exercises.where("exercise_name=?","") + unless exercises.empty? + exercises.each do |exercise| + if exercise.exercise_questions.empty? + exercise.destroy + end + end + end + end + + def find_exercise_and_course + @exercise = Exercise.find params[:id] + @course = Course.find @exercise.course_id + rescue Exception => e + render_404 + end + + def find_course + @course = Course.find params[:course_id] + rescue Exception => e + render_404 + end +end \ No newline at end of file diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb new file mode 100644 index 000000000..bb87f3b82 --- /dev/null +++ b/app/helpers/exercise_helper.rb @@ -0,0 +1,139 @@ +# encoding: utf-8 +module ExerciseHelper + + # 单选 + def sigle_selection_standard_answer(params) + size = params.ord - 96 + if size > 0 # 小写字母答案 + answer = params.ord - 96 + else + answer = params.ord - 64 + end + end + + # 多选 + def multiselect_standard_answer(params) + size = params.ord - 96 + answer = [] + if size > 0 # 小写字母答案 + for i in 0..(params.length-1) + answer << (params[i].ord - 96).to_s + end + else + for i in 0..(params.length-1) + answer << (params[i].ord - 64) + end + end + answer = answer.sort + answer.join("") + end + + # + def fill_standart_answer(params, standart_answer) + params.each do |param| + standart_answer.answer_text = param.value + standart_answer.save + end + end + + # 获取多选的得分 + def get_mulscore(question, user) + ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + arr = [] + ecs.each do |ec| + arr << ec.exercise_choice.choice_position + end + arr.sort + arr = arr.join("") + end + + # 判断用户是否已经提交了问卷 + # status 为0的时候是用户点击试卷。为1表示用户已经提交 + def has_commit_exercise?(exercise_id, user_id) + pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, true) + if pu.empty? + false + else + true + end + end + + # 判断学生是否点击过问卷,点击则为他保存一个记录,记录start_at + def has_click_exercise?(exercise_id, user_id) + pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, false) + if pu.empty? + false + else + true + end + end + + def convert_to_char(str) + result = "" + length = str.length + unless str.nil? + if length === 1 + result += (str.to_i + 64).chr + return result + elsif length > 1 + for i in 0...length + result += (str[i].to_i + 64).chr + end + return result + end + end + return result + end + + def get_current_score exercise + score = 0 + unless exercise.nil? + exercise.exercise_questions.each do |exercise_question| + unless exercise_question.question_score.nil? + score += exercise_question.question_score + end + end + return score + end + return score + end + + def answer_be_selected?(answer,user) + pv = answer.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id} ") + if !pv.nil? && pv.count > 0 + true + else + false + end + end + + #获取文本题答案 + def get_anwser_vote_text(question_id,user_id) + pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id) + if pv.nil? + '' + else + pv.answer_text + end + end + + # 获取当前学生回答问题的答案 + def get_user_answer(question,user) + user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") + user_answer + end + + # 获取问题的标准答案 + def get_user_standard_answer(question,user) + if question.question_type == 3 + standard_answer =[] + question.exercise_standard_answers.each do |answer| + standard_answer << answer.answer_text + end + else + standard_answer = question.exercise_standard_answers + end + standard_answer + end + +end \ No newline at end of file diff --git a/app/models/course.rb b/app/models/course.rb index a9f72ad61..1350b8cf7 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -41,6 +41,7 @@ class Course < ActiveRecord::Base has_many :course_activities # 课程消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + has_many :exercises, :dependent => :destroy acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy diff --git a/app/models/exercise.rb b/app/models/exercise.rb new file mode 100644 index 000000000..e4295971e --- /dev/null +++ b/app/models/exercise.rb @@ -0,0 +1,8 @@ +class Exercise < ActiveRecord::Base + #exercise_status: 1,新建;2,发布;3,关闭 + include Redmine::SafeAttributes + belongs_to :user + has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" + has_many :exercise_users, :dependent => :destroy + has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 +end diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb new file mode 100644 index 000000000..c62f5bcd5 --- /dev/null +++ b/app/models/exercise_answer.rb @@ -0,0 +1,8 @@ +class ExerciseAnswer < ActiveRecord::Base + #学生答题 + include Redmine::SafeAttributes + + belongs_to :user + belongs_to :exercise_question + belongs_to :exercise_choice +end diff --git a/app/models/exercise_choice.rb b/app/models/exercise_choice.rb new file mode 100644 index 000000000..00d611566 --- /dev/null +++ b/app/models/exercise_choice.rb @@ -0,0 +1,7 @@ +class ExerciseChoice < ActiveRecord::Base + include Redmine::SafeAttributes + + belongs_to :exercise_question + has_many :exercise_answers, :dependent => :destroy + has_many :exercise_standard_answers, :dependent => :destroy +end diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb new file mode 100644 index 000000000..5189b0274 --- /dev/null +++ b/app/models/exercise_question.rb @@ -0,0 +1,8 @@ +class ExerciseQuestion < ActiveRecord::Base + include Redmine::SafeAttributes + + belongs_to :exercise + has_many :exercise_choices, :order => "#{ExerciseChoice.table_name}.choice_position",:dependent => :destroy + has_many :exercise_answers, :dependent => :destroy + has_many :exercise_standard_answers, :dependent => :destroy +end diff --git a/app/models/exercise_standard_answer.rb b/app/models/exercise_standard_answer.rb new file mode 100644 index 000000000..ce3d08fbf --- /dev/null +++ b/app/models/exercise_standard_answer.rb @@ -0,0 +1,7 @@ +class ExerciseStandardAnswer < ActiveRecord::Base + #标准答案 + include Redmine::SafeAttributes + + belongs_to :exercise_question + belongs_to :exercise_choice +end diff --git a/app/models/exercise_user.rb b/app/models/exercise_user.rb new file mode 100644 index 000000000..2d5da5d95 --- /dev/null +++ b/app/models/exercise_user.rb @@ -0,0 +1,6 @@ +class ExerciseUser < ActiveRecord::Base + include Redmine::SafeAttributes + + belongs_to :user + belongs_to :exercise +end diff --git a/app/models/user.rb b/app/models/user.rb index 85b9e2591..3e7bc2ddb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -81,6 +81,12 @@ class User < Principal has_many :poll, :dependent => :destroy #用户创建的问卷 has_many :answers, :source => :poll, :through => :poll_users, :dependent => :destroy #用户已经完成问答的问卷 # end + #在线测验相关关系 + has_many :exercise_user, :dependent => :destroy #答卷中间表 + has_many :exercise_answer, :dependent => :destroy #针对每个题目学生的答案 + has_many :exercises, :dependent => :destroy #创建的试卷 + has_many :exercises_answers, :source => :exercise, :through => :exercise_user, :dependent => :destroy #用户已经完成问答的试卷 + #end #作业相关关系 has_many :homework_commons, :dependent => :destroy has_many :student_works, :dependent => :destroy diff --git a/app/views/exercise/_alert.html.erb b/app/views/exercise/_alert.html.erb new file mode 100644 index 000000000..b3de53d1f --- /dev/null +++ b/app/views/exercise/_alert.html.erb @@ -0,0 +1,27 @@ + + + + + + + +
+
+
+

+ <%= message%> +

+ +
+
+
+
+ + + diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb new file mode 100644 index 000000000..d92ca51fb --- /dev/null +++ b/app/views/exercise/_commit_alert.html.erb @@ -0,0 +1,12 @@ +
+ <% if status == 0 %> +

提交成功!您的分数是:<%=@score %>分。

+ <%= link_to "确定", exercise_path(),:class => 'commit'%> + <% elsif status == 1 %> +

您还有尚未作答的题目请完成后再提交!

+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% else %> +

发生未知错误,请检查您的网络。

+ <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% end %> +
diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb new file mode 100644 index 000000000..a1c8aa8b1 --- /dev/null +++ b/app/views/exercise/_edit_MC.html.erb @@ -0,0 +1,63 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
+
+ + + +
+
+ +
+ +
+
+ +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb new file mode 100644 index 000000000..a3ae74324 --- /dev/null +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -0,0 +1,63 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
+
+ + + +
+
+ +
+ +
+
+ +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb new file mode 100644 index 000000000..3090cc2c5 --- /dev/null +++ b/app/views/exercise/_edit_head.html.erb @@ -0,0 +1,33 @@ +<%= form_for @exercise, :remote=>true do |f| %> +
+
+ +
+ <%# if edit_mode %> + + <%# end %> +
+ " > + <%= calendar_for('exercise_publish_time')%> +
+ <%# if edit_mode %> + + <%# end %> +
+ " > + <%= calendar_for('exercise_end_time')%> +
+
测验时长:分钟
+
+ + +
+
+<% end %> \ No newline at end of file diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb new file mode 100644 index 000000000..d22747457 --- /dev/null +++ b/app/views/exercise/_edit_single.html.erb @@ -0,0 +1,59 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
+
+ + + +
+
+ +
+ +
+
+ +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb new file mode 100644 index 000000000..f5896c5e3 --- /dev/null +++ b/app/views/exercise/_exercise.html.erb @@ -0,0 +1,61 @@ +<%# 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%> +
  • +
    + <%# 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" %> +
    +
  • + + <% if exercise.exercise_status == 1%> +
  • 统计结果
  • + <% else %> +
  • <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%>
  • + <% end%> + + <% if exercise.exercise_status == 1 %> +
  • 发布试卷
  • + <% elsif exercise.exercise_status == 2%> +
  • 取消发布
  • + <% else%> +
  • 发布试卷
  • + <% 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 %> +
  • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%>
  • + <% else%> +
  • 编辑
  • + <% end%> + + <%# if exercise.exercise_status == 2 %> + + <%# else %> + + <%# end%> + + <%# if exercise.exercise_status == 1%> + + <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> + + <%# end%> + + +
  • <%= format_date exercise.created_at.to_date%>
  • +<% else%> + <% if exercise.exercise_status == 2%> + <%# if has_commit%> + + <%#else%> + <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> + <%#end%> + <% end%> +
  • <%= format_date exercise.created_at.to_date%>
  • +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb new file mode 100644 index 000000000..14add37ec --- /dev/null +++ b/app/views/exercise/_exercise_content.html.erb @@ -0,0 +1,42 @@ +<% mc_question_list = exercise.exercise_questions.where("question_type=1") %> +<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> +<% single_question_list = exercise.exercise_questions.where("question_type=3") %> +
    "> +

    单选题

    + <% mc_question_list.each do |exercise_question| %> +
    +
    + <%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %> +
    + +
    + <% end %> +
    +
    "> +

    多选题

    + <% mcq_question_list.each do |exercise_question| %> +
    +
    + <%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %> +
    + +
    + <% end %> +
    +
    "> +

    填空题

    + <% single_question_list.each do |exercise_question| %> +
    +
    + <%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %> +
    + +
    + <% end %> +
    \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb new file mode 100644 index 000000000..0d6b8602d --- /dev/null +++ b/app/views/exercise/_exercise_form.html.erb @@ -0,0 +1,194 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
    +
    + + +
    + <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%> +
    + <% current_score = get_current_score @exercise %> +
    " id="current_score_div">目前试卷总分:<%=current_score %>分
    + +
    + <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> +
    + +
    + <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %> +
    + + +
    +
    + +
    + <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %> +
    +
    + +
    +
    diff --git a/app/views/exercise/_exercise_republish.html.erb b/app/views/exercise/_exercise_republish.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb new file mode 100644 index 000000000..0f51dfeb7 --- /dev/null +++ b/app/views/exercise/_exercise_student.html.erb @@ -0,0 +1,208 @@ + +
    +
    +
    +

    <%= exercise.exercise_name%>

    + +
    + 开始时间:<%=format_time(exercise_user.start_at.to_s)%> + 测验时长:<%=exercise.time %>分钟 + +
    +
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    +
    +
    +
    + <% mc_question_list = exercise.exercise_questions.where("question_type=1").shuffle %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2").shuffle %> + <% single_question_list = exercise.exercise_questions.where("question_type=3").shuffle %> +
    "> +

    单选题

    + <% mc_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    多选题

    + <% mcq_question_list.each_with_index do |exercise_question,list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    填空题

    + <% single_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    +
    +
    + + > +
    +
    +
    +
    + <% end %> +
    +
    + <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %> +
    +
    + +
    + +
    \ No newline at end of file diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb new file mode 100644 index 000000000..32cb556b3 --- /dev/null +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -0,0 +1,137 @@ + +
    +
    +
    +

    <%= exercise.exercise_name%>

    +
    + 开始时间:<%=format_time(exercise_user.start_at.to_s) %> + 测验时长:<%=exercise.time %>分钟 + <%# time = exercise_user.end_at - exercise_user.start_at %> +
    +
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    +
    +
    +
    得分:<%=exercise_user.score %>分
    + <% mc_question_list = exercise.exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> + <% single_question_list = exercise.exercise_questions.where("question_type=3") %> +
    "> +

    单选题

    + <% mc_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) + + <% 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 %> + √ + <% else %> + × + <% end %>
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    多选题

    + <% mcq_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) + + <% 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 %> + √ + <% else %> + × + <% end %>
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    填空题

    + <% single_question_list.each_with_index do |exercise_question,list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) + + <% 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) %> + √ + <% else %> + × + <% end %>
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
    + <% end %> +
    +
    + > +
    +
    +
    +
    + <% end %> +
    +
    + +
    + +
    \ No newline at end of file diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb new file mode 100644 index 000000000..8e2ad74a2 --- /dev/null +++ b/app/views/exercise/_exercise_submit.html.erb @@ -0,0 +1,37 @@ +<%= form_for('', + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'commit_exercise', + :id => exercise.id + },:remote=>true ) do |f| %> +
    + 提交 +
    + <%= f.check_box 'show_result', :value => exercise.show_result%> + <%= label_tag '_show_result', '允许学生查看测验结果' %> + +
    +
    +<% end %> + + \ No newline at end of file diff --git a/app/views/exercise/_exercise_submit_info.html.erb b/app/views/exercise/_exercise_submit_info.html.erb new file mode 100644 index 000000000..0d7e8928c --- /dev/null +++ b/app/views/exercise/_exercise_submit_info.html.erb @@ -0,0 +1,45 @@ + + + + + + + +
    +
    +
    + <% current_score = get_current_score exercise %> + <% question_count = exercise.exercise_questions.count %> + <% 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 %> +

    当前测验 + <% 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 %> + 总分为<%=current_score %>分。 +

    + 是否确定提交该测验? +

    + +
    +
    +
    +
    + + + diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb new file mode 100644 index 000000000..a3f6380cf --- /dev/null +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -0,0 +1,121 @@ + +
    +
    +
    +

    <%= exercise.exercise_name%>

    +
    + 发布时间:<%=format_time(exercise.publish_time.to_s) %> + 截止时间:<%=format_time(exercise.end_time.to_s) %> + 测验时长:<%=exercise.time %>分钟 +
    +
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    +
    +
    + <% mc_question_list = exercise.exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> + <% single_question_list = exercise.exercise_questions.where("question_type=3") %> +
    "> +

    单选题

    + <% mc_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    多选题

    + <% mcq_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    +
    +
    + <% end %> +
    +
    "> +

    填空题

    + <% single_question_list.each_with_index do |exercise_question, list_index| %> +
    +
    +
    +
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
    + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
    +
    +
    + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
    + <% end %> +
    +
    +
    +
    + <% end %> +
    +
    + <%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => "ur_button_submit" %> + <% if exercise.exercise_status == 1 %> + <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "ur_button_submit", :style => "float:right"%> + <% else %> + 编辑 + <%#= link_to l(:button_edit), '', :class => "ur_button_submit", :style => "float:right; background:#a3a3a3"%> + <% end %> +
    +
    + +
    + +
    \ No newline at end of file diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb new file mode 100644 index 000000000..16fa24b0e --- /dev/null +++ b/app/views/exercise/_exercises_list.html.erb @@ -0,0 +1,25 @@ +
    +

    所有试卷 + (<%= @obj_count%>) +

    + <% 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%> +
    +
    +
    + + <% @exercises.each do |exercise|%> + +
    + <% end%> + + + +
    +
    \ No newline at end of file diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb new file mode 100644 index 000000000..b749c4374 --- /dev/null +++ b/app/views/exercise/_new_MC.html.erb @@ -0,0 +1,60 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url=>create_exercise_question_exercise_path(exercise.id), + :remote=>true ) do |f| %> +
    +
    + + + +
    +
    + +
    + +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb new file mode 100644 index 000000000..a7029d3ea --- /dev/null +++ b/app/views/exercise/_new_MCQ.html.erb @@ -0,0 +1,60 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url=>create_exercise_question_exercise_path(exercise.id), + :remote=>true ) do |f| %> +
    +
    + + + +
    +
    + +
    + +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb new file mode 100644 index 000000000..6148c9bb9 --- /dev/null +++ b/app/views/exercise/_new_question.html.erb @@ -0,0 +1,39 @@ + +
    + + \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb new file mode 100644 index 000000000..1ee79e198 --- /dev/null +++ b/app/views/exercise/_new_single.html.erb @@ -0,0 +1,48 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url=>create_exercise_question_exercise_path(exercise.id), + :remote=>true ) do |f| %> +
    +
    + + + +
    +
    + +
    + +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb new file mode 100644 index 000000000..b932eac1e --- /dev/null +++ b/app/views/exercise/_show_MC.html.erb @@ -0,0 +1,111 @@ +
    +
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    + <%= exercise_question.question_title %> + (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) +
    + + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb new file mode 100644 index 000000000..2a91afab5 --- /dev/null +++ b/app/views/exercise/_show_MCQ.html.erb @@ -0,0 +1,109 @@ +
    +
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    + <%= exercise_question.question_title %> + (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) +
    + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
    +
    + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
    + +
    +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb new file mode 100644 index 000000000..ac7c1c162 --- /dev/null +++ b/app/views/exercise/_show_head.html.erb @@ -0,0 +1,12 @@ +
    + + +

    <%= exercise.exercise_name%>

    +
    + 发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> + 截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> + 测验时长:<%= exercise.time %>分钟
    +
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb new file mode 100644 index 000000000..5f36a931e --- /dev/null +++ b/app/views/exercise/_show_single.html.erb @@ -0,0 +1,85 @@ +
    +
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    + <%= exercise_question.question_title %> +
    + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
    +
    + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
    + <% end %> +
    +
    + +
    +
    + + \ No newline at end of file diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb new file mode 100644 index 000000000..25bf3f7cd --- /dev/null +++ b/app/views/exercise/_student_exercise.html.erb @@ -0,0 +1,73 @@ +
    + + 测验 + + (<%= @exercise_count%>人已交) + + <% if !@is_teacher && @exercise_users_list.empty?%> + 您尚未提交 + <% elsif !@is_teacher && !@exercise_users_list.empty?%> + 您已提交 + <% end %> + + <%#if @is_teacher || @exercise.exercise_status == 3%> + + <%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> + <%# end%> + +
    +
    + +
    + <%= render :partial => "student_table"%> +
    +
    + +<% @exercise_users_list.each do |exercise|%> + + + +
    +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_student_table.html.erb b/app/views/exercise/_student_table.html.erb new file mode 100644 index 000000000..719667973 --- /dev/null +++ b/app/views/exercise/_student_table.html.erb @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb new file mode 100644 index 000000000..2a40df2a5 --- /dev/null +++ b/app/views/exercise/commit_exercise.js.erb @@ -0,0 +1,9 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); +showModal('ajax-modal', '270px'); +$('#ajax-modal').css('height','110px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/exercise/create.js.erb b/app/views/exercise/create.js.erb new file mode 100644 index 000000000..65b8dd327 --- /dev/null +++ b/app/views/exercise/create.js.erb @@ -0,0 +1,4 @@ +$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); \ No newline at end of file diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb new file mode 100644 index 000000000..326a19ec8 --- /dev/null +++ b/app/views/exercise/create_exercise_question.js.erb @@ -0,0 +1,42 @@ +<% if @is_insert %> + $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); + $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); + $("#current_score_div").show(); + $("#current_score").html("<%=get_current_score @exercise %>分"); +<% else %> + $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); + $("#new_poll_question").html(""); + $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); + <%if @exercise_questions.question_type == 1%> + $("#mc_question_list").show().append("
    " + + "
    " + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "
    " + + "" + + "
    "); + <% end %> + <%if @exercise_questions.question_type == 2%> + $("#mcq_question_list").show().append("
    " + + "
    " + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "
    " + + "" + + "
    "); + <% end %> + <%if @exercise_questions.question_type == 3%> + $("#single_question_list").show().append("
    " + + "
    " + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "
    " + + "" + + "
    "); + <% end %> +$("#current_score_div").show(); +$("#current_score").html("<%=get_current_score @exercise %>分"); +<% end %> diff --git a/app/views/exercise/delete_exercise_question.js.erb b/app/views/exercise/delete_exercise_question.js.erb new file mode 100644 index 000000000..d07a80b47 --- /dev/null +++ b/app/views/exercise/delete_exercise_question.js.erb @@ -0,0 +1,3 @@ +$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); +$("#current_score").html("<%=get_current_score @exercise %>分"); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/destroy.js.erb b/app/views/exercise/destroy.js.erb new file mode 100644 index 000000000..c17b5a0f6 --- /dev/null +++ b/app/views/exercise/destroy.js.erb @@ -0,0 +1 @@ +$("#exercise").html("<%= escape_javascript(render :partial => 'exercises_list') %>"); \ No newline at end of file diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb new file mode 100644 index 000000000..0b20dc90e --- /dev/null +++ b/app/views/exercise/edit.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'exercise_form'%> \ No newline at end of file diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb new file mode 100644 index 000000000..1e2d6ff34 --- /dev/null +++ b/app/views/exercise/index.html.erb @@ -0,0 +1,63 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
    + <%= render :partial => 'exercises_list'%> +
    \ No newline at end of file diff --git a/app/views/exercise/new.html.erb b/app/views/exercise/new.html.erb new file mode 100644 index 000000000..3d983d64f --- /dev/null +++ b/app/views/exercise/new.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'exercise_form'%> diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb new file mode 100644 index 000000000..ac2899402 --- /dev/null +++ b/app/views/exercise/publish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','111px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb new file mode 100644 index 000000000..320cd3cf0 --- /dev/null +++ b/app/views/exercise/republish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise_content',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','80px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/exercise/show.html.erb b/app/views/exercise/show.html.erb new file mode 100644 index 000000000..f47710d1c --- /dev/null +++ b/app/views/exercise/show.html.erb @@ -0,0 +1,10 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> +<% if @is_teacher %> + <%= render :partial => 'exercise_teacher', :locals =>{:exercise =>@exercise, :exercise_questions => @exercise_questions} %> +<% else %> + <% if @can_edit_excercise %> + <%=render :partial => 'exercise_student', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> + <% else %> + <%=render :partial => 'exercise_student_result', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb new file mode 100644 index 000000000..8653836ca --- /dev/null +++ b/app/views/exercise/student_exercise_list.html.erb @@ -0,0 +1,138 @@ + + +
    +
    +
    + + +
    +
    + +
    +
    + + <% if @exercise.exercise_status == 1 %> + 未发布 + <% elsif @exercise.exercise_status == 2 %> + 已发布 + <% elsif @exercise.exercise_status == 3 %> + 已截止 + <% end%> + [ 隐藏测验信息 ] +
    +
    发布者:<%= @exercise.user.show_name %>
    +
    +
    <%= @exercise.exercise_description.html_safe %>
    +
    + + +
    +
    +
    截止时间:<%= format_time @exercise.end_time %>
    + <% if @exercise.exercise_status == 1 %> +
    发布时间:<%= format_time @exercise.publish_time %>
    + <% end %> + <% end_time = @exercise.end_time.to_time.to_i %> + <% if end_time > Time.now.to_i %> +
    提交剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60) %> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    提交已截止
    + <% end %> +
    +
    +
    +
    + +
    +
    +
    + <%= render :partial => "exercise/student_exercise"%> +
    +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/exercise/update.js.erb b/app/views/exercise/update.js.erb new file mode 100644 index 000000000..9724b2bd1 --- /dev/null +++ b/app/views/exercise/update.js.erb @@ -0,0 +1,5 @@ +$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb new file mode 100644 index 000000000..9e7822cb7 --- /dev/null +++ b/app/views/exercise/update_exercise_question.js.erb @@ -0,0 +1,20 @@ +$("#poll_questions_<%= @exercise_question.id%>").html("
    " + + "<% if @exercise_question.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_question}) %>" + + "<% end%>" + + "
    " + + ""); +$("#current_score").html("<%=get_current_score @exercise_question.exercise %>分"); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>"); diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index f2525a014..106aa35a7 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -173,6 +173,11 @@ <%= 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 %> +
    diff --git a/config/routes.rb b/config/routes.rb index 993c1e243..d137553ad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -160,6 +160,25 @@ RedmineApp::Application.routes.draw do end end + #show、index、new、create、edit、update、destroy路由自动生成 + resources :exercise do + member do #生成路径为 /exercise/:id/方法名 + get 'statistics_result' + get 'student_exercise_list' + get 'export_exercise' + get 'publish_exercise' + get 'republish_exercise' + post 'create_exercise_question' + post 'commit_answer' + post 'commit_exercise' + end + + collection do #生成路径为 /exercise/方法名 + delete 'delete_exercise_question' + post 'update_exercise_question' + end + end + resources :homework_common, :except => [:show]do member do get 'start_anonymous_comment' diff --git a/db/migrate/20151113025341_exercise.rb b/db/migrate/20151113025341_exercise.rb new file mode 100644 index 000000000..b29bfdb91 --- /dev/null +++ b/db/migrate/20151113025341_exercise.rb @@ -0,0 +1,17 @@ +class Exercise < ActiveRecord::Migration + def up + create_table :exercises do |t| + t.string :exercise_name + t.text :exercise_description + t.integer :course_id + t.integer :exercise_status + t.integer :user_id + t.integer :time + t.timestamps + end + end + + def down + drop_table :exercise + end +end diff --git a/db/migrate/20151113025459_exercise_question.rb b/db/migrate/20151113025459_exercise_question.rb new file mode 100644 index 000000000..1dd0409f9 --- /dev/null +++ b/db/migrate/20151113025459_exercise_question.rb @@ -0,0 +1,15 @@ +class ExerciseQuestion < ActiveRecord::Migration + def up + create_table :exercise_questions do |t| + t.string :question_title + t.integer :question_type + t.integer :question_number + t.integer :exercise_id + t.timestamps + end + end + + def down + drop_table :exercise_question + end +end diff --git a/db/migrate/20151113025524_exercise_choices.rb b/db/migrate/20151113025524_exercise_choices.rb new file mode 100644 index 000000000..782cb5f7d --- /dev/null +++ b/db/migrate/20151113025524_exercise_choices.rb @@ -0,0 +1,14 @@ +class ExerciseChoices < ActiveRecord::Migration + def up + create_table :exercise_choices do |t| + t.integer :exercise_question_id + t.text :choice_text + t.integer :choice_position + t.timestamps + end + end + + def down + drop_table :exercise_choices + end +end diff --git a/db/migrate/20151113025549_exercise_standard_answer.rb b/db/migrate/20151113025549_exercise_standard_answer.rb new file mode 100644 index 000000000..8ed1a25be --- /dev/null +++ b/db/migrate/20151113025549_exercise_standard_answer.rb @@ -0,0 +1,14 @@ +class ExerciseStandardAnswer < ActiveRecord::Migration + def up + create_table :exercise_standard_answers do |t| + t.integer :exercise_question_id + t.integer :exercise_choice_id + t.text :answer_text + t.timestamps + end + end + + def down + drop_table :exercise_standard_answer + end +end diff --git a/db/migrate/20151113025721_exercise_answer.rb b/db/migrate/20151113025721_exercise_answer.rb new file mode 100644 index 000000000..9cc9c5bc7 --- /dev/null +++ b/db/migrate/20151113025721_exercise_answer.rb @@ -0,0 +1,15 @@ +class ExerciseAnswer < ActiveRecord::Migration + def up + create_table :exercise_answers do |t| + t.integer :user_id + t.integer :exercise_question_id + t.integer :exercise_choice_id + t.text :answer_text + t.timestamps + end + end + + def down + drop_table :exercise_answer + end +end diff --git a/db/migrate/20151113025751_user_exercise.rb b/db/migrate/20151113025751_user_exercise.rb new file mode 100644 index 000000000..d5e521401 --- /dev/null +++ b/db/migrate/20151113025751_user_exercise.rb @@ -0,0 +1,15 @@ +class UserExercise < ActiveRecord::Migration + def up + create_table :exercise_users do |t| + t.integer :user_id + t.integer :exercise_id + t.integer :score + t.datetime :start_at + t.timestamps + end + end + + def down + drop_table :exercise_user + end +end diff --git a/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb new file mode 100644 index 000000000..90aec321f --- /dev/null +++ b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb @@ -0,0 +1,6 @@ +class AddPublishTimeEndTimeToExercise < ActiveRecord::Migration + def change + add_column :exercises, :publish_time, :timestamp + add_column :exercises, :end_time, :timestamp + end +end diff --git a/db/migrate/20151118014720_add_show_result_to_exercise.rb b/db/migrate/20151118014720_add_show_result_to_exercise.rb new file mode 100644 index 000000000..8148a277d --- /dev/null +++ b/db/migrate/20151118014720_add_show_result_to_exercise.rb @@ -0,0 +1,5 @@ +class AddShowResultToExercise < ActiveRecord::Migration + def change + add_column :exercises, :show_result, :integer + end +end diff --git a/db/migrate/20151118015638_add_question_score_to_exercise_question.rb b/db/migrate/20151118015638_add_question_score_to_exercise_question.rb new file mode 100644 index 000000000..a3235dcad --- /dev/null +++ b/db/migrate/20151118015638_add_question_score_to_exercise_question.rb @@ -0,0 +1,5 @@ +class AddQuestionScoreToExerciseQuestion < ActiveRecord::Migration + def change + add_column :exercise_questions, :question_score, :integer + end +end diff --git a/db/migrate/20151119124148_add_end_at_to_exercise_user.rb b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb new file mode 100644 index 000000000..db4cc4c47 --- /dev/null +++ b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb @@ -0,0 +1,5 @@ +class AddEndAtToExerciseUser < ActiveRecord::Migration + def change + add_column :exercise_users, :end_at, :datetime + end +end diff --git a/db/migrate/20151120021958_add_status_to_exercise_user.rb b/db/migrate/20151120021958_add_status_to_exercise_user.rb new file mode 100644 index 000000000..ab1355d8c --- /dev/null +++ b/db/migrate/20151120021958_add_status_to_exercise_user.rb @@ -0,0 +1,5 @@ +class AddStatusToExerciseUser < ActiveRecord::Migration + def change + add_column :exercise_users, :status, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index fc2bcee92..27b52780d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151118031602) do +ActiveRecord::Schema.define(:version => 20151120021958) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -425,8 +425,8 @@ ActiveRecord::Schema.define(:version => 20151118031602) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -436,14 +436,14 @@ ActiveRecord::Schema.define(:version => 20151118031602) do t.string "class_period" t.integer "school_id" t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 t.integer "lft" t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 t.integer "publish_resource", :default => 0 end @@ -573,6 +573,129 @@ ActiveRecord::Schema.define(:version => 20151118031602) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" +<<<<<<< .mine + create_table "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_choices", :force => true do |t| + t.integer "exercise_question_id" + t.text "choice_text" + t.integer "choice_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "question_number" + t.integer "exercise_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_score" + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_users", :force => true do |t| + t.integer "user_id" + t.integer "exercise_id" + t.integer "score" + t.datetime "start_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "end_at" + t.integer "status" + end + + create_table "exercises", :force => true do |t| + t.string "exercise_name" + t.text "exercise_description" + t.integer "course_id" + t.integer "exercise_status" + t.integer "user_id" + t.integer "time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "publish_time" + t.datetime "end_time" + t.integer "show_result" + end + +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> .theirs create_table "first_pages", :force => true do |t| t.string "web_title" t.string "title" diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5469078a5..5ff34a4e1 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -83,6 +83,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re .width180{width: 180px;} .width525{width: 525px;} .width285{width: 285px;} +.width530{width: 530px;} .mr95{margin-right: 95px;} .mr140 {margin-right: 140px;} .ml100{margin-left: 100px;} @@ -712,6 +713,7 @@ img.ui-datepicker-trigger { width:16px; height:15px; float:left; + margin: 7px; } .label{ width:80px; text-align:right; font-size:14px; display:block; float:left;} @@ -1141,3 +1143,27 @@ input.sendSourceText { width: 50px; height: 25px; } + +/*20151117在线测验byTim*/ +.testContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} +.testTitle{ width:678px; height:40px; padding:0 10px; text-align:center; font-size:16px; font-weight:bold; background:#fff;border-style:solid; border:1px solid #CBCBCB;} +.testDes{ width:678px; height:60px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} +.btn_submit{ width:56px; height:24px; padding-top:4px;background:#269ac9; color:#fff; text-align:center; display:block; float:left; margin-right:10px;} +a:hover.btn_submit{background:#297fb8;} +.btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; } +a:hover.btn_cancel{ color:#666;} +.testQuestion{ width:708px; height: auto; border:1px solid #cbcbcb; padding:10px 0 0 10px; margin-bottom:10px;} +.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; } +.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;} +.mr100 {margin-right:100px;} +.testDesEdit {width:670px; overflow:hidden;} +.testEditTitle{ padding:10px 0px ; float:left; width:564px; } +.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; } \ No newline at end of file