diff --git a/app/assets/javascripts/org_courses.js.coffee b/app/assets/javascripts/org_courses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_courses.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/org_courses.css.scss b/app/assets/stylesheets/org_courses.css.scss new file mode 100644 index 000000000..026af5d01 --- /dev/null +++ b/app/assets/stylesheets/org_courses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_courses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1a561006a..cd1de16fc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -29,6 +29,30 @@ class CoursesController < ApplicationController before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] + #查找组织 + def search_public_orgs_not_in_course + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id) + if course_org_ids.empty? + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + course_org_ids = "(" + course_org_ids.join(',') + ")" + @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + @hint_flag = params[:hint_flag] + #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json + respond_to do |format| + format.js + end + end + def join if User.current.logged? cs = CoursesService.new diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb new file mode 100644 index 000000000..d53dc067c --- /dev/null +++ b/app/controllers/exercise_controller.rb @@ -0,0 +1,612 @@ +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 + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @exercise.exercise_status = 2 + @exercise.publish_time = Time.now + if @exercise.save + #redirect_to exercise_index_url(:course_id=> @course.id) + respond_to do |format| + format.js + end + end + end + + # 重新发布试卷 + # 重新发布的时候会删除所有的答题 + def republish_exercise + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @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/controllers/files_controller.rb b/app/controllers/files_controller.rb index cbbf36ea8..a2902e3fc 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -24,7 +24,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] + before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] helper :sort include SortHelper diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e529dd3b9..edf055370 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -397,6 +397,23 @@ class IssuesController < ApplicationController end end + def add_journal_in_org + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first + org_activity.updated_at = jour.created_on + org_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + private def find_project diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 4f78d61f5..9b090de9a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -174,6 +174,11 @@ class MessagesController < ApplicationController user_activity.updated_at = Time.now user_activity.save end + org_activity = OrgActivity.where("org_act_type='Message' and org_act_id =#{@topic.id}").first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] diff --git a/app/controllers/org_courses_controller.rb b/app/controllers/org_courses_controller.rb new file mode 100644 index 000000000..3d1d313c5 --- /dev/null +++ b/app/controllers/org_courses_controller.rb @@ -0,0 +1,18 @@ +class OrgCoursesController < ApplicationController + def create + org_ids = params[:orgNames] + @course = Course.find(params[:course_id]) + org_ids.each do |org_id| + OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) + end + respond_to do |format| + format.js + end + end + + def destroy + @course = Course.find(params[:course_id]) + @org_course = OrgCourse.find(params[:id]) + @org_course.destroy + end +end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 60522dc3f..61a27c433 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -12,7 +12,7 @@ class OrgDocumentCommentsController < ApplicationController @org_document_comment.title = params[:org_document_comment][:title] @org_document_comment.content = params[:org_document_comment][:content] if @org_document_comment.save - #flash[:notice] = 'success' + flash.keep[:notice] = l(:notice_successful_create) OrgActivity redirect_to organization_org_document_comments_path(@organization) else @@ -20,15 +20,23 @@ class OrgDocumentCommentsController < ApplicationController end end def show - + @document = OrgDocumentComment.find(params[:id]) end def index - @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + else + render_403 + end end def update @org_document = OrgDocumentComment.find(params[:id]) @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content]) + if @org_document.parent.nil? + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first + act.update_attributes(:updated_at => @org_document.updated_at) + end respond_to do |format| format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)} end @@ -41,12 +49,24 @@ class OrgDocumentCommentsController < ApplicationController def add_reply @document = OrgDocumentComment.find(params[:id]).root + @act = OrgActivity.find(params[:id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment.content = params[:org_content] @document.children << @comment @document.save end + def add_reply_in_doc + @document = OrgDocumentComment.find(params[:id]).root + @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:org_comment][:org_content] + @document.children << @comment + @document.save + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def find_organization @organization = Organization.find(params[:organization_id]) end @@ -59,5 +79,66 @@ class OrgDocumentCommentsController < ApplicationController org.home_id == nil end end + respond_to do |format| + format.js + end + end + + def delete_reply + @org_document_comment = OrgDocumentComment.find(params[:id]) + @document = @org_document_comment.root + org = @org_document_comment.organization + @org_document_comment.destroy + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def quote + @org_comment = OrgDocumentComment.find(params[:id]) + @subject = @org_comment.content + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " + @temp = OrgDocumentComment.new + #@course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + def reply + @document = OrgDocumentComment.find(params[:id]).root + @quote = params[:quote][:quote] + @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) + + # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @org_document.title = params[:org_document_comment][:title] + @org_document.content = params[:org_document_comment][:content] + @org_document.content = @quote + @org_document.content + #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document + # @user_activity_id = params[:user_activity_id] + # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + # if user_activity + # user_activity.updated_at = Time.now + # user_activity.save + # end + # attachments = Attachment.attach_files(@org_document, params[:attachments]) + # render_attachment_warning_if_needed(@org_document) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + # redirect_to syllabus_course_path(:id=>params[:course_id]) + # else + redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) + # end + + } + format.js + end end end diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb index 4b842f9dc..642a100c3 100644 --- a/app/controllers/org_member_controller.rb +++ b/app/controllers/org_member_controller.rb @@ -16,7 +16,7 @@ class OrgMemberController < ApplicationController member_ids = params[:membership][:user_ids] role_id = params[:orgRole] member_ids.each do |user_id| - member = OrgMember.create(:user_id=>user_id) + member = OrgMember.create(:user_id=>user_id, :created_at => Time.now) @org.org_members << member OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) end diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb index 733df95b7..29e60a62a 100644 --- a/app/controllers/org_projects_controller.rb +++ b/app/controllers/org_projects_controller.rb @@ -4,7 +4,6 @@ class OrgProjectsController < ApplicationController @project = Project.find(params[:project_id]) org_ids.each do |org_id| OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) - p 1 end respond_to do |format| format.js @@ -14,18 +13,5 @@ class OrgProjectsController < ApplicationController @project = Project.find(params[:project_id]) @org_project = OrgProject.find(params[:id]) @org_project.destroy - - condition = '%%' - project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id) - if project_org_ids.empty? - @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count - else - project_org_ids = "(" + project_org_ids.join(',') + ")" - @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count - end - # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,1 end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b75742164..0d22ab461 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -55,22 +55,38 @@ class OrganizationsController < ApplicationController def show if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) - @org_activities = OrgActivity.where('container_id =? and container_type =? ', - @organization.id, 'Organization ').order('updated_at desc').page(params[:page]).per(10) - @org_activities_count = OrgActivity.where('container_id =? and container_type =? ', - @organization.id, 'Organization ').order('updated_at desc').count project_ids = @organization.projects.map(&:id) << 0 - @org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10) - @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count - #@org_activities = paginateHelper @org_activities, 10 + course_ids = @organization.courses.map(&:id) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + end @page = params[:page] + respond_to do |format| + format.html + format.js + end else render_403 end - respond_to do |format| - format.html - format.js - end end def update @@ -135,13 +151,26 @@ class OrganizationsController < ApplicationController end def members - @members = OrgMember.where("organization_id =?", @organization.id) + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @members = OrgMember.where("organization_id =?", @organization.id) + else + render_403 + end end def more_org_projects @organization = Organization.find params[:id] @page = params[:page] - @org_projects = @organization.org_projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + @org_projects = @organization.projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + respond_to do |format| + format.js + end + end + + def more_org_courses + @organization = Organization.find(params[:id]) + @page = params[:page] + @org_courses = @organization.courses.reorder('created_at').page((params[:page].to_i || 1) + 1 ).per(5) respond_to do |format| format.js end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index baa7db060..715f56d3d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,6 +86,7 @@ class ProjectsController < ApplicationController end # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count @orgs_page = Paginator.new @org_count, 10,params[:page] + @no_roll_hint = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json respond_to do |format| format.js diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3129dbf02..2bd54954a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 @@ -315,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 @@ -349,33 +369,27 @@ update alias_method :browse, :show - - #add by houxiang - - def get_commits(id) - g = Gitlab.client - tmp_commit_count = g.commits(id,page:0).count - commit_count = 0 - i=0 - while tmp_commit_count!=0 - commit_count = commit_count+tmp_commit_count - i=i+1 - tmp_commit_count = g.commits(id,page:i).count + #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 commit_count - + return count end - def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client 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] @@ -387,6 +401,7 @@ update render :layout => 'base_projects' end + def revisions @changeset_count = @repository.changesets.count @changeset_pages = Paginator.new @changeset_count, diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9ad46cd69..7eac379e4 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -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] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 273d48ccf..776e6b7d5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1918,6 +1918,20 @@ class UsersController < ApplicationController end end + def search_user_orgs + name="" + if !params[:search_orgs].nil? + name = params[:search_orgs].strip + end + name = "%"+name+"%" + @orgs = User.current.organizations.where("name like ?", name) + @user = User.current + respond_to do |format| + format.html {render :layout => 'static_base'} + format.js + end + end + private def find_user diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e08259b11..f4e0f88ff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2374,8 +2374,10 @@ module ApplicationHelper link_to "作品(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework - if work.nil? + if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") + link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' else if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" 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/helpers/org_courses_helper.rb b/app/helpers/org_courses_helper.rb new file mode 100644 index 000000000..28655e52e --- /dev/null +++ b/app/helpers/org_courses_helper.rb @@ -0,0 +1,2 @@ +module OrgCoursesHelper +end diff --git a/app/models/course.rb b/app/models/course.rb index 7288c3b3b..1350b8cf7 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -18,6 +18,8 @@ class Course < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :principals, :through => :member_principals, :source => :principal has_many :users, :through => :members + has_many :org_courses + has_many :organizations, :through => :org_courses # has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy # has_many :homework_for_courses, :dependent => :destroy @@ -39,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/course_activity.rb b/app/models/course_activity.rb index 4e74142ad..e1f9ab9f5 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,8 +5,8 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity - before_destroy :destroy_user_activity + after_save :add_user_activity, :add_course_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -30,8 +30,34 @@ class CourseActivity < ActiveRecord::Base end end + def add_course_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first + if org_activity + org_activity.save + else + if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, + :org_act_id => self.course_act_id, + :org_act_type => self.course_act_type, + :container_id => self.course_id, + :container_type => 'Course', + :created_at => self.created_at, + :updated_at => self.updated_at) + end + end + end + def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'") + org_activity.destroy_all + end end 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/forge_activity.rb b/app/models/forge_activity.rb index c4f13c6d0..bb5f30442 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -20,8 +20,8 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_id,presence: true validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity - before_destroy :destroy_user_activity + after_save :add_user_activity, :add_org_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -45,8 +45,29 @@ class ForgeActivity < ActiveRecord::Base end end + def add_org_activity + if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.forge_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, + :org_act_id => self.forge_act_id, + :org_act_type => self.forge_act_type, + :container_id => self.project_id, + :container_type => 'Project', + :created_at => self.created_at, + :updated_at => self.updated_at) + end + end + def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and org_act_id = '#{self.forge_act_id}'") + org_acts.destroy_all + end end diff --git a/app/models/org_course.rb b/app/models/org_course.rb new file mode 100644 index 000000000..8c198794a --- /dev/null +++ b/app/models/org_course.rb @@ -0,0 +1,5 @@ +class OrgCourse < ActiveRecord::Base + #attr_accessible :organization, :course, :created_at + belongs_to :organization + belongs_to :course +end diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index 2b3c9132a..7b9f9cd75 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -11,6 +11,10 @@ class OrgDocumentComment < ActiveRecord::Base def document_save_as_org_activity if(self.parent().nil?) self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization') + else + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", self.root.id).first + act.update_attributes(:updated_at => self.updated_at) end end + end diff --git a/app/models/organization.rb b/app/models/organization.rb index 7778da477..d3755b5ee 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -3,7 +3,9 @@ class Organization < ActiveRecord::Base has_many :org_members, :dependent => :destroy has_many :org_projects ,:dependent => :destroy has_many :projects,:through => :org_projects + has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy + has_many :org_courses has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity 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/services/courses_service.rb b/app/services/courses_service.rb index e566a8f46..5d60238bf 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -186,6 +186,7 @@ class CoursesService #params[:setup_time]:暂不传(貌似已经没用了) #params[:endup_time]: 暂不传(貌似已经没用了) #params[:class_period]:学时总数 + #params[:course][:publish_resource]允许学生上传资源 def create_course(params,current_user) if current_user.user_extensions.identity @course = Course.new @@ -202,6 +203,7 @@ class CoursesService @course.class_period = params[:class_period].to_i params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0 params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0 + params[:course][:publish_resource] ? @course.publish_resource = 1 : @course.publish_resource = 0 else end @@ -243,6 +245,7 @@ class CoursesService #params[:term]:学期(秋季学期或春季学期) #params[:time]: 年份(例:2014) #params[:class_period]:学时总数 + #params[:publish_resource] 允许学生上传资源 0 不允许 1 允许 def edit_course(params,course,current_user) course.send(:safe_attributes=, params[:course], current_user) #course.safe_attributes = params[:course] @@ -251,6 +254,7 @@ class CoursesService course.class_period = params[:class_period].to_i params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0 params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0 + params[:course][:publish_resource] ? course.publish_resource = 1 : course.publish_resource = 0 if course.save if params[:course][:is_public] == '0' course_status = CourseStatus.find_by_course_id(course.id) diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index d2c17917e..f1b917816 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -50,6 +50,12 @@ (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)
+
  • + + id="course_publish_resource" name="course[publish_resource]" type="checkbox" /> + (打钩为"允许学生上传资源",不打钩为"不允许学生上传资源") +
    +
  • 提交 <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%> diff --git a/app/views/courses/search_public_orgs_not_in_course.js.erb b/app/views/courses/search_public_orgs_not_in_course.js.erb new file mode 100644 index 000000000..2669f8a0f --- /dev/null +++ b/app/views/courses/search_public_orgs_not_in_course.js.erb @@ -0,0 +1,19 @@ +<% if @hint_flag.nil? %> + if($("#join_orgs_for_course input:checked").size() > 0) + { + alert("翻页或搜索后将丢失当前选择的用户数据"); + } +<% end %> +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('') +<% if @org_count > 10 %> + $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); + $("#paginator").css("display", "block"); +<% else %> + $("#paginator").css("display", "none"); +<% end %> diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index a90be14ea..5c3918f00 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -10,6 +10,9 @@
  • 成员
  • +
  • + 组织 +
  • @@ -65,6 +68,12 @@ (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)
    +
  • + + id="course_publish_resource" name="course[publish_resource]" type="checkbox" style="margin-left: 1px;"/> + (打钩为"允许学生上传资源",不打钩为"不允许学生上传资源") +
    +
  • 提交 <%= link_to l(:button_cancel), course_path(@course), :class => "blue_btn grey_btn fl c_white" %> @@ -91,6 +100,10 @@ <%= render :partial => "course_members" %>
  • + +
    + <%= render :partial => 'courses/settings/join_org' %> +
    \ No newline at end of file + diff --git a/app/views/courses/settings/_added_orgs.html.erb b/app/views/courses/settings/_added_orgs.html.erb new file mode 100644 index 000000000..9ac783ca0 --- /dev/null +++ b/app/views/courses/settings/_added_orgs.html.erb @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/app/views/courses/settings/_join_org.html.erb b/app/views/courses/settings/_join_org.html.erb new file mode 100644 index 000000000..cd2d515cc --- /dev/null +++ b/app/views/courses/settings/_join_org.html.erb @@ -0,0 +1,86 @@ + + + + + + + +<%= stylesheet_link_tag 'org' %> + +
    +
    + 关联组织 +
    + <%= form_tag url_for(:controller => 'org_courses', :action => 'create', :course_id => @course.id), :id => 'join_orgs_for_course', :remote => true do %> + +
    + + 关联 + 取消 + <% end %> +
    +
    +
    + 已关联组织 +
    + <%= render :partial => 'courses/settings/added_orgs', :locals => {:orgs => @course.organizations, :course_id => params[:id]} %> +
    +
    +
    +
    +
    +
    + + \ No newline at end of file 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..008c95c24 --- /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..2b900d648 --- /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..d2e4a6f2c --- /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..1f415886f --- /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..45d6ccf70 --- /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..b9306b0d2 --- /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..d1774f637 --- /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..d65e01ca7 --- /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..0555b997c --- /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..faadb08a9 --- /dev/null +++ b/app/views/exercise/_new_question.html.erb @@ -0,0 +1,45 @@ + +
    + + \ 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..08b31087a --- /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..f6ee29266 --- /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, :quest_num => exercise_question.question_number), + 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..d7a7c2b6d --- /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, :quest_num => exercise_question.question_number), + 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..a6bb5afe9 --- /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, :quest_num => exercise_question.question_number), + 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..3cff84e1c --- /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..b7172fe9e --- /dev/null +++ b/app/views/exercise/republish_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_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/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 4176b72d0..a0cb419b2 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -72,7 +72,7 @@ <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> <% end %> - <% if is_course_teacher(User.current,@course) %> + <% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %>

    上传: diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 4cc249c20..f04d70577 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -32,7 +32,7 @@ <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %> - <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> + <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> <% if @course.is_public? %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %> @@ -57,7 +57,7 @@

    文件大小:<%= number_to_human_size(file.filesize) %>

    <%= link_to( l(:button_delete), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course"%>

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    diff --git a/app/views/issues/add_journal_in_org.js.erb b/app/views/issues/add_journal_in_org.js.erb new file mode 100644 index 000000000..ad7a85540 --- /dev/null +++ b/app/views/issues/add_journal_in_org.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); + +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file diff --git a/app/views/layouts/_org_courses.html.erb b/app/views/layouts/_org_courses.html.erb new file mode 100644 index 000000000..2837ef71f --- /dev/null +++ b/app/views/layouts/_org_courses.html.erb @@ -0,0 +1,12 @@ +<% courses.each do |course|%> + <%# pro = Project.find course.course_id %> +
  • + <%= link_to course.name, course_path(course.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => course.name%> +
  • +<% end %> +<% if courses.size == 5%> +
  • + + +
  • +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_org_projects.html.erb b/app/views/layouts/_org_projects.html.erb index be65fd516..687b54ecd 100644 --- a/app/views/layouts/_org_projects.html.erb +++ b/app/views/layouts/_org_projects.html.erb @@ -1,7 +1,7 @@ <% projects.each do |project|%> - <% pro = Project.find project.project_id %> + <%# pro = Project.find project.project_id %>
  • - <%= link_to pro.name, project_path(pro.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => pro.name%> + <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%>
  • <% end %> <% if projects.size == 5%> diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 489820f0c..96b015bdc 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -18,6 +18,18 @@ <%= yield :header_tags -%> <%= stylesheet_link_tag 'base','header', :media => 'all'%> + + + + diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 39de4faeb..106aa35a7 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -21,6 +21,22 @@ <%= javascript_include_tag "course","header","attachments",'prettify' %> <%= yield :header_tags -%> + + + + + + + @@ -138,7 +154,7 @@ +
    diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb index e03ac2fc5..eb24c0a6e 100644 --- a/app/views/layouts/base_forums.html.erb +++ b/app/views/layouts/base_forums.html.erb @@ -16,6 +16,18 @@ <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> <%= stylesheet_link_tag 'base','header','new_user', :media => 'all'%> + + + + + + + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    +
    + <%= form_for @org_comment, :as => :reply, :url => {:controller => 'org_document_comments',:action => 'reply', :id => @org_comment.id}, :method => 'post', :html => {:multipart => true, :id => 'new_form'} do |f| %> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 5d54af2bf..40ed2eeb2 100644 --- a/app/views/org_document_comments/add_reply.js.erb +++ b/app/views/org_document_comments/add_reply.js.erb @@ -1,3 +1,3 @@ -$("#organization_document_<%= @document.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document}) %>"); -init_activity_KindEditor_data(<%= @document.id %>,"","87%"); \ No newline at end of file +$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document, :act => @act}) %>"); +init_activity_KindEditor_data(<%= @act.id %>,"","87%"); \ No newline at end of file diff --git a/app/views/org_document_comments/add_reply_in_doc.js.erb b/app/views/org_document_comments/add_reply_in_doc.js.erb new file mode 100644 index 000000000..bcebe9d37 --- /dev/null +++ b/app/views/org_document_comments/add_reply_in_doc.js.erb @@ -0,0 +1 @@ +location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/destroy.js.erb b/app/views/org_document_comments/destroy.js.erb index bcebe9d37..adbeff4a6 100644 --- a/app/views/org_document_comments/destroy.js.erb +++ b/app/views/org_document_comments/destroy.js.erb @@ -1 +1,2 @@ -location.reload(); \ No newline at end of file +//location.reload(); +window.location.href = '<%= organization_org_document_comments_path(:organization_id => @org_document_comment.root.organization_id)%>' \ No newline at end of file diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index b4f8662a3..4b50c1064 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -12,17 +12,19 @@ } } -
    +
    编辑文章
    +
    +
    <%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id),:method => 'put', :id => 'new_org_document_form' do |f| %>
    - +
    -
    +
    <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %>
    @@ -35,10 +37,11 @@
    确定 - 取消 + 取消
    -<% end %> \ No newline at end of file +<% end %> +
    \ No newline at end of file diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb index d9b1d9579..d967c42fd 100644 --- a/app/views/org_document_comments/index.html.erb +++ b/app/views/org_document_comments/index.html.erb @@ -16,9 +16,9 @@ <% @documents.each do |document| %> - <%= render :partial => 'organizations/show_org_document', :locals => {:document => document} %> + <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/quote.js.erb b/app/views/org_document_comments/quote.js.erb new file mode 100644 index 000000000..a71b23f0e --- /dev/null +++ b/app/views/org_document_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @org_comment.id%>").length > 0) { + $("#reply_message_<%= @org_comment.id%>").replaceWith("<%= escape_javascript(render :partial => 'org_document_comments/simple_ke_reply_form', :locals => {:reply => @org_comment,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @org_comment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @org_comment.id %>").length >0) { + $("#reply_to_message_<%= @org_comment.id%>").replaceWith("

    "); +} \ No newline at end of file diff --git a/app/views/org_document_comments/reply.js.erb b/app/views/org_document_comments/reply.js.erb new file mode 100644 index 000000000..888613c8c --- /dev/null +++ b/app/views/org_document_comments/reply.js.erb @@ -0,0 +1 @@ +//location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index e69de29bb..9df568e02 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -0,0 +1,148 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_path(@document.creator_id) %> +
    +
    +
    + <%= link_to User.find(@document.creator_id), user_path(@document.creator.id), :class => "newsBlue mr15" %> + TO  <%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> + | + <% if @document.organization.home_id == @document.id %> + 首页 + <% else %> + 组织文章 + <% end %> +
    +
    <%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %>
    +
    + 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
    + <% unless @document.content.blank? %> +
    + <%= @document.content.html_safe %> +
    + <% end %> + + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> +
    +
      +
    • +
        +
      • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> + 设为首页 + <% end %> +
      • +
      • + <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :class => "postOptionLink" %> +
      • +
      • + <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
      • +
      +
    • +
    +
    +
    + <% end %> +
    +
    + <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> + +
    + <% if count > 0 %> +
    +
    回复(<%= count %>)
    +
    +
    + <% comments_for_doc.each_with_index do |reply,i| %> + + <% user = User.find(reply.creator_id) %> +
    +
    + <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_path(user) %> +
    +
    + <%= link_to User.find(reply.creator_id).realname, user_path(reply.creator_id), :class => "newsBlue mr10 f14" %> +
    + <%= reply.content.html_safe unless reply.content.nil? %> +
    +
    + <%= format_time(reply.created_at) %> + +
    +

    +
    +
    +
    + <% end %> +
    +
    + <% end %> + <% if User.current.logged?%> +
    + +
    +
    + <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    + + \ No newline at end of file diff --git a/app/views/org_projects/create.js.erb b/app/views/org_projects/create.js.erb index 545918c73..ee3c67bbd 100644 --- a/app/views/org_projects/create.js.erb +++ b/app/views/org_projects/create.js.erb @@ -1,6 +1,2 @@ - -$("#search_orgs_result_list").html(""); -//$("#search_orgs_result_list").append('
      '); $("#added_orgs").html(""); -$("#paginator").css("display", "none"); $("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') \ No newline at end of file diff --git a/app/views/org_projects/destroy.js.erb b/app/views/org_projects/destroy.js.erb index 49ea1dc33..f8927280a 100644 --- a/app/views/org_projects/destroy.js.erb +++ b/app/views/org_projects/destroy.js.erb @@ -1,22 +1,4 @@ -//$("#search_orgs_result_list").html(""); -////$("#paginator").css("display", "none"); $("#added_orgs").html(""); -$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') -//$.ajax({ -// url: '<%#= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1', -// type:'get' -//}); -$("#search_orgs_result_list").html(""); -$("#search_orgs_result_list").append('
        '); -<% @orgs_not_in_project.each do |org|%> -link = "
      • "; -$("#search_orgs_result_list").append(link ); -<%end %> -$("#search_orgs_result_list").append('
      ') -<% if @org_count > 10 %> -$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); -$("#paginator").css("display", "block"); -<% else %> -$("#paginator").css("display", "none"); -<% end %> +$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>'); + diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb new file mode 100644 index 000000000..aa48fedf1 --- /dev/null +++ b/app/views/organizations/_org_activities.html.erb @@ -0,0 +1,70 @@ +<% unless org_activities.nil? %> + <% org_activities.each do |act| %> + + <% if act.container_type == 'Organization' %> + <% if act.org_act_type == 'CreateOrganization' %> +
      +
      + +
      +
      <%= link_to User.find(act.user_id), user_path(act.user_id) %>  创建了 <%= Organization.find(act.org_act_id).name %> + | 组织
      +
      创建时间:<%= format_activity_day(act.created_at) %> <%= format_time(act.created_at, false) %>
      +
      +
      +
      +
      + <% end %> + <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> + <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act} %> + <% end %> + <% end %> + <% if act.container_type == 'Project' %> + <% case act.org_act_type.to_s %> + <% when 'Issue' %> + <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => Issue.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'Message' %> + <%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'ProjectCreateInfo'%> + <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> + <% end %> + <% end %> + <% if act.container_type == 'Course' %> + <% case act.org_act_type.to_s %> + <% when 'HomeworkCommon' %> + <%= render :partial => 'org_course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id,:course_activity => 0} %> + <% when 'News' %> + <%= render :partial => 'org_course_news', :locals => {:activity => News.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'Message'%> + <%= render :partial => 'org_course_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'Poll' %> + <%= render :partial => 'org_course_poll', :locals => {:activity => Poll.find(act.org_act_id), :user_activity_id => act.id} %> + <% when 'Course'%> + <%= render :partial => 'org_course_create', :locals => {:activity => Course.find(act.org_act_id), :user_activity_id => act.id} %> + <% end %> + <% end %> + <% end %> + + <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> + +<% end %> + +<% if org_act_count == 10 %> +
      展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
      + <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end%> + + \ No newline at end of file diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb new file mode 100644 index 000000000..97213283e --- /dev/null +++ b/app/views/organizations/_org_course_create.html.erb @@ -0,0 +1,36 @@ +
      +
      +
      + <%= link_to image_tag(url_to_avatar(activity.teacher), :width => "50", :height => "50"), user_path(activity.tea_id), :alt => "用户头像" %> +
      +
      +
      + <% if activity.try(:teacher).try(:realname) == ' ' %> + <%= link_to activity.try(:teacher), user_path(activity.tea_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:teacher).try(:realname), user_path(activity.tea_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.name.to_s+" | 课程", course_path(activity.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
      +
      + <%= link_to activity.name, course_path(activity.id,:host=>Setting.host_course), :class => "postGrey" %> +
      +
      + 创建时间:<%= format_time(activity.created_at) %> +
      + +
      +
      +
      +
      \ No newline at end of file diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb new file mode 100644 index 000000000..9699eff5f --- /dev/null +++ b/app/views/organizations/_org_course_homework.html.erb @@ -0,0 +1,187 @@ +<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> +
      +
      +
      + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> +
      + + <% if activity.homework_detail_manual%> + <% if activity.homework_detail_manual.comment_status == 1%> + <% if activity.anonymous_comment == 0%> + 未开启匿评 + <% else %> + 匿评已禁用 + <% end %> + <% if Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")%> + 作品提交中 + <% elsif Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") %> + 作品补交中 + <% end %> + <% elsif activity.homework_detail_manual.comment_status == 2%> + <% if activity.anonymous_comment == 0%> + 匿评中 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% elsif activity.homework_detail_manual.comment_status == 3%> + <% if activity.anonymous_comment == 0%> + 匿评已结束 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% end%> + <% end%> +
      +
      + <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> + <%= user_for_homework_common activity,is_teacher %> +
      + + <% if activity.homework_type == 2 && is_teacher%> +
      + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
      + <% end %> + <% if activity.homework_type == 2%> +
      + 语言: + <%= activity.language_name%> +
      + <% end %> + +
      截止时间:<%= activity.end_time.to_s %> 23:59
      +
      +
      +
      + <%= activity.description.html_safe %> +
      +
      +
      + + +
      +
      + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %> +
      +
      + <% if is_teacher%> + <% comment_status = activity.homework_detail_manual.comment_status %> +
      +
        +
      • +
          +
        • + <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> +
        • +
        • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
        • +
        • + <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %> +
        • + <% if activity.anonymous_comment == 0 %> +
        • + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> +
        • +
        • + <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> +
        • + <% end %> + <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> +
        • + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
        • + <% end %> +
        +
      • +
      +
      + <% end%> +
      +
      +
      + + <% count=activity.journals_for_messages.count %> +
      +
      +
      +
      + 回复(<%= count %>) +
      +
      + <%if count>3 %> + + <% end %> +
      + + <% replies_all_i = 0 %> + <% if count > 0 %> +
      +
        + <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
      • +
        + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
        +
        +
        + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
        +
        + <%= comment.notes.html_safe %>
        +
        +
        +
      • + <% end %> +
      +
      + <% end %> + +
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
      +
      +
      + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> + +
      + +
      +

      + <% end%> +
      +
      +
      +
      +
      +
      +
      \ No newline at end of file diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb new file mode 100644 index 000000000..9ca8f5d10 --- /dev/null +++ b/app/views/organizations/_org_course_message.html.erb @@ -0,0 +1,140 @@ +
      +
      +
      + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
      +
      +
      + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> +
      + + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
      +
      + 发帖时间:<%= format_time(activity.created_on) %> +
      +
      +
      + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
      +
      +
      + + +
      + +
      +
      +
      + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
      +
      +
      +
      回复( + <%= count %> + )
      +
      <%#=format_date(activity.updated_on)%>
      + <%if count > 3 %> + + <% end %> +
      + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
      +
        + <% activity.children.reorder("created_on desc").each do |reply|%> + + <% replies_all_i=replies_all_i+1 %> +
      • +
        + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
        +
        +
        + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
        +
        + <%= reply.content.html_safe %> +
        +
        +
        +
      • + <% end %> +
      +
      + <% end %> + + <% if !activity.locked? && authorize_for_course('messages', 'reply') %> +
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
      +
      +
      + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
      + +
      +

      + <% end%> +
      +
      +
      +
      +
      +
      + <% end %> +
      +
      diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb new file mode 100644 index 000000000..475a982e5 --- /dev/null +++ b/app/views/organizations/_org_course_news.html.erb @@ -0,0 +1,106 @@ +
      +
      +
      + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if @ctivity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %> +
      + + <% if activity.sticky == 1%> + 置顶 + <% end%> +
      +
      + 发布时间:<%= format_time(activity.created_on) %> +
      +
      +
      + <%= activity.description.html_safe %> +
      +
      +
      + + +
      +
      +
      +
      + <% count=activity.comments.count %> +
      +
      +
      +
      + 回复(<%= count %>) +
      +
      <%#= format_date(activity.updated_on) %>
      + <%if count>3 %> + + <% end %> +
      + + <% replies_all_i = 0 %> + <% if count > 0 %> +
      +
        + <% activity.comments.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
      • +
        + <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %> +
        +
        +
        + <% if comment.try(:author).try(:realname) == ' ' %> + <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
        +
        + <%= comment.comments.html_safe %>
        +
        +
        +
      • + <% end %> +
      +
      + <% end %> + +
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
      +
      +
      + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + + +
      + +
      +

      + <% end%> +
      +
      +
      +
      +
      +
      +
      \ No newline at end of file diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb new file mode 100644 index 000000000..c363909d9 --- /dev/null +++ b/app/views/organizations/_org_course_poll.html.erb @@ -0,0 +1,56 @@ +<% has_commit = has_commit_poll?(activity.id ,User.current)%> +<% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> +<% if ( activity.polls_status==2) %> +
      +
      +
      + + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %> + +
      +
      + <%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %> + <% if has_commit %> + <%= link_to poll_name, poll_result_poll_path(activity.id), :class => "postGrey"%> + <% else %> + <%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%> + <% end %> +
      +
      + 发布时间:<%= format_time(activity.published_at) %> +
      +
      +
      + <%= activity.polls_description.html_safe %> +
      +
      +
      + + +
      + +
      +
      +
      +
      +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_members.html.erb b/app/views/organizations/_org_members.html.erb index 3940a6576..ee15e19d7 100644 --- a/app/views/organizations/_org_members.html.erb +++ b/app/views/organizations/_org_members.html.erb @@ -5,7 +5,7 @@
    - + 加入时间
    <% members.each do |member| %> @@ -16,6 +16,9 @@ <%= l(:label_username)%> <%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %>
    身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %> + <% if member.created_at %> + <%= format_time(member.created_at) %> + <% end %>
    <% end%> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 573429752..e29994967 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -130,7 +130,23 @@
    <% end %> - +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%> + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb index d966d8e18..607c14a45 100644 --- a/app/views/organizations/_project_create.html.erb +++ b/app/views/organizations/_project_create.html.erb @@ -1,4 +1,4 @@ -<% project = Project.find(activity.project_id) %> +<% project = Project.find(activity.org_act_id) %> <% user = User.find(project.user_id)%>
    diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 85ed08f2f..2708bb546 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -95,6 +95,24 @@
    <% end %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 4177c3688..e74da846e 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -11,10 +11,10 @@ <% if document.organization.home_id == document.id %> 首页 <% else %> - 组织 + 组织文章 <% end %> -
    <%= document.title %>
    +
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
    发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
    <% unless document.content.blank? %> @@ -91,16 +91,16 @@ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_path(User.current) %>
    -
    - <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id), :method => "post", :remote => true) do |f| %> - - +
    + <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id), :method => "post", :remote => true) do |f| %> + + -
    - +
    +
    -

    +

    <% end %>
    diff --git a/app/views/organizations/more_org_courses.js.erb b/app/views/organizations/more_org_courses.js.erb new file mode 100644 index 000000000..02bfb1d70 --- /dev/null +++ b/app/views/organizations/more_org_courses.js.erb @@ -0,0 +1,2 @@ +$("#show_more_org_course").replaceWith("<%= escape_javascript( render :partial => 'layouts/org_courses', + :locals => {:courses => @org_courses,:org_id => @organization, :page => @page} )%>"); diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb index 1ab3ad933..ab0a4ec50 100644 --- a/app/views/organizations/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -34,8 +34,8 @@ (打钩为公开,不打钩则不公开,若不公开,仅组织成员可见该组织。)
    -
  • - 提交 +
  • + 创建 <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
  • diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 0b624d479..e44e0778d 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -14,65 +14,61 @@
    最新动态
    - +
  • <%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> + +
  • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> +
  • <%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> + + + +
  • +
  • +
      +
    • 项目动态
    • +
    • <%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> +
    • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> + +
    +
  • +
  • +
      +
    • 更多
    • +
    • <%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%> +
    • <%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%> +
    +
  • - --> + +
    <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> - - <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %> + <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> + <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> +<% if @org_activities %> + <%= render :partial => 'organizations/org_activities', + :locals => {:org_activities =>@org_activities, + :page=>@page, + :org => @organization, + :org_act_count=>@org_activities.count}%> +<% end %> - <% unless @org_activities.nil? %> - <% @org_activities.each do |act| %> - <% if act.org_act_type == 'CreateOrganization' %> -
    -
    - -
    -
    <%= link_to User.find(act.user_id), user_path(act.user_id) %>  创建了 <%= Organization.find(act.org_act_id).name %> - | 组织
    -
    创建时间:<%= format_activity_day(act.created_at) %> <%= format_time(act.created_at, false) %>
    -
    -
    -
    -
    - <% end %> - <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> - - <%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %> - <% end %> - <% end %> - - <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> - - <% end %> - - <%# @org_project_activties.each do |org_act|%> - <%= render :partial => 'organizations/org_project_activities', - :locals => {:org_project_activties =>@org_project_activties, - :page=>@page, - :org => @organization, - :org_act_count=>@org_activities.count, - :pro_act_count=>@org_project_activties.count}%> - <%# end %> diff --git a/app/views/organizations/show.js.erb b/app/views/organizations/show.js.erb index b0a447910..ee405d73c 100644 --- a/app/views/organizations/show.js.erb +++ b/app/views/organizations/show.js.erb @@ -1,7 +1,6 @@ -$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_project_activities', - :locals => {:org_project_activties =>@org_project_activties, +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_activities', + :locals => {:org_activities =>@org_activities, :page=>@page, :org => @organization, - :org_act_count=>@org_activities.count, - :pro_act_count=>@org_project_activties.count} )%>"); + :org_act_count=>@org_activities.count} )%>"); diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index ec8562885..83b65fe90 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -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 %> - (<%= @project.repositories.count %>) + <% 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 %> diff --git a/app/views/projects/search_public_orgs_not_in_project.js.erb b/app/views/projects/search_public_orgs_not_in_project.js.erb index 69005d304..c8ac999a1 100644 --- a/app/views/projects/search_public_orgs_not_in_project.js.erb +++ b/app/views/projects/search_public_orgs_not_in_project.js.erb @@ -1,3 +1,10 @@ +//翻页提醒 +<% if @no_roll_hint.nil? %> + if( $("#join_orgs_for_project input:checked").size() > 0) + { + alert('翻页或搜索后将丢失当前选择的用户数据!'); + } +<% end %> $("#search_orgs_result_list").html(""); $("#search_orgs_result_list").append('