| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
3fbb7083cd | 合并 | 11 years ago |
|
|
8b041fb51a |
Merge branch 'develop' into dev_cxt2
Conflicts: Gemfile app/controllers/exercise_controller.rb app/controllers/homework_common_controller.rb app/controllers/memos_controller.rb app/controllers/messages_controller.rb app/controllers/org_document_comments_controller.rb app/controllers/organizations_controller.rb app/controllers/projects_controller.rb app/controllers/repositories_controller.rb app/controllers/student_work_controller.rb app/controllers/users_controller.rb app/controllers/welcome_controller.rb app/controllers/words_controller.rb app/helpers/application_helper.rb app/helpers/student_work_helper.rb app/models/attachment.rb app/models/comment.rb app/models/course.rb app/models/exercise.rb app/models/forge_activity.rb app/models/message.rb app/models/org_document_comment.rb app/models/organization.rb app/models/project.rb app/models/student_work.rb app/models/user.rb app/views/account/about_us.html.erb app/views/account/login.html.erb app/views/comments/create.js.erb app/views/courses/_tool_expand.html.erb app/views/courses/settings.html.erb app/views/exercise/_edit_MC.html.erb app/views/exercise/_edit_MCQ.html.erb app/views/exercise/_edit_head.html.erb app/views/exercise/_exercise.html.erb app/views/exercise/_exercise_form.html.erb app/views/exercise/_exercises_list.html.erb app/views/exercise/_new_MC.html.erb app/views/exercise/_new_MCQ.html.erb app/views/exercise/_show_MC.html.erb app/views/exercise/_show_MCQ.html.erb app/views/exercise/_show_single.html.erb app/views/exercise/index.html.erb app/views/forums/_show_topics.html.erb app/views/forums/show.html.erb app/views/homework_common/score_rule_set.js.erb app/views/layouts/_logined_header.html.erb app/views/layouts/_unlogin_header.html.erb app/views/layouts/base_courses.html.erb app/views/layouts/base_forums.html.erb app/views/layouts/base_org.html.erb app/views/layouts/base_projects.html.erb app/views/mailer/send_mail_anonymous_comment_open.html.erb app/views/memos/edit.html.erb app/views/memos/show.html.erb app/views/org_document_comments/_new.html.erb app/views/org_document_comments/add_reply.js.erb app/views/org_document_comments/index.html.erb app/views/org_document_comments/show.html.erb app/views/organizations/_join_course_menu.html.erb app/views/organizations/_join_project_menu.html.erb app/views/organizations/_org_activities.html.erb app/views/organizations/_org_members.html.erb app/views/organizations/_show_org_document.html.erb app/views/organizations/join_courses.js.erb app/views/organizations/join_projects.js.erb app/views/organizations/setting.html.erb app/views/organizations/show.html.erb app/views/projects/show.html.erb app/views/repositories/_revisions.html.erb app/views/repositories/show.html.erb app/views/student_work/_evaluation_work.html.erb app/views/student_work/_programing_work_show.html.erb app/views/student_work/_set_score_rule.html.erb app/views/student_work/_show.html.erb app/views/student_work/_student_work_attachment_form.html.erb app/views/student_work/_student_work_list.html.erb app/views/student_work/_work_information.html.erb app/views/student_work/create.js.erb app/views/student_work/new.html.erb app/views/student_work/set_score_rule.js.erb app/views/student_work/update.js.erb app/views/tags/_user_tag.html.erb app/views/users/_course_homework.html.erb app/views/users/_course_poll.html.erb app/views/users/_project_attachment.html.erb app/views/users/_project_create.html.erb app/views/users/_project_document.html.erb app/views/users/_project_journal.html.erb app/views/users/_project_news.html.erb app/views/users/_resource_search_form.html.erb app/views/users/_resource_share_for_project_popup.html.erb app/views/users/_resource_share_popup.html.erb app/views/users/_resources_list.html.erb app/views/users/_user_activities.html.erb app/views/users/_user_homework_detail.html.erb app/views/users/_user_homework_form.html.erb app/views/users/_user_message_course.html.erb app/views/users/add_exist_file_to_course.js.erb app/views/users/add_exist_file_to_project.js.erb app/views/users/user_resource.html.erb config/application.rb config/locales/mailers/zh.yml config/locales/projects/zh.yml config/routes.rb db/schema.rb lib/gitlab-cli/bin/gitlab lib/gitlab-cli/lib/gitlab/client/projects.rb lib/grack/bin/console lib/grack/bin/testserver lib/tasks/homework_evaluation.rake lib/tasks/homework_publishtime.rake lib/tasks/sync_gitlab_user.rake lib/tasks/sync_sigle_rep.rake lib/trustie/gitlab/manage_member.rb |
11 years ago |
|
|
4eac0e0dab | merge | 11 years ago |
| @@ -30,21 +30,11 @@ gem 'rails_kindeditor',path:'lib/rails_kindeditor' | |||
| #gem "rmagick", ">= 2.0.0" | |||
| gem 'binding_of_caller' | |||
| gem 'chinese_pinyin' | |||
| # gem 'sunspot_rails', '~> 1.3.3' | |||
| # gem 'sunspot_solr' | |||
| # gem 'sunspot' | |||
| # gem 'progress_bar' | |||
| gem 'ansi' | |||
| gem 'kaminari' | |||
| gem 'elasticsearch-model' | |||
| gem 'elasticsearch-rails' | |||
| group :development do | |||
| gem 'grape-swagger' | |||
| gem 'better_errors', '~> 1.1.0' | |||
| gem 'rack-mini-profiler', '~> 0.9.3' | |||
| gem 'win32console' | |||
| end | |||
| group :development, :test do | |||
| @@ -374,7 +374,6 @@ class CoursesController < ApplicationController | |||
| def settings | |||
| if User.current.allowed_to?(:as_teacher,@course) | |||
| @select_tab = params[:tab] | |||
| @issue_custom_fields = IssueCustomField.sorted.all | |||
| @issue_category ||= IssueCategory.new | |||
| @member ||= @course.members.new | |||
| @@ -6,18 +6,6 @@ class ExerciseController < ApplicationController | |||
| include ExerciseHelper | |||
| def index | |||
| publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) | |||
| publish_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 2) | |||
| course = exercise.course | |||
| course.members.each do |m| | |||
| exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| end | |||
| end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) | |||
| end_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 3) | |||
| end | |||
| if @course.is_public == 0 && !User.current.member_of_course?(@course) | |||
| render_403 | |||
| return | |||
| @@ -36,18 +24,6 @@ class ExerciseController < ApplicationController | |||
| end | |||
| def show | |||
| publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) | |||
| publish_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 2) | |||
| course = exercise.course | |||
| course.members.each do |m| | |||
| exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| end | |||
| end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) | |||
| end_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 3) | |||
| end | |||
| unless User.current.member_of_course?(@course) | |||
| render_403 | |||
| return | |||
| @@ -340,9 +316,6 @@ class ExerciseController < ApplicationController | |||
| @exercise.exercise_status = 2 | |||
| @exercise.publish_time = Time.now | |||
| if @exercise.save | |||
| @exercise.course.members.each do |m| | |||
| @exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2) | |||
| end | |||
| #redirect_to exercise_index_url(:course_id=> @course.id) | |||
| respond_to do |format| | |||
| format.js | |||
| @@ -358,7 +331,6 @@ class ExerciseController < ApplicationController | |||
| @exercise.exercise_questions.each do |exercise_question| | |||
| exercise_question.exercise_answers.destroy_all | |||
| end | |||
| @exercise.course_messages.destroy_all | |||
| @exercise.exercise_users.destroy_all | |||
| @exercise.exercise_status = 1 | |||
| @exercise.publish_time = nil | |||
| @@ -512,10 +484,6 @@ class ExerciseController < ApplicationController | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| @exercise.update_attributes(:exercise_status => 2) | |||
| @exercise.update_attributes(:publish_time => Time.now) | |||
| course = @exercise.course | |||
| course.members.each do |m| | |||
| @exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| redirect_to exercise_url(@exercise) | |||
| return | |||
| elsif @exercise.publish_time > Time.now | |||
| @@ -0,0 +1,658 @@ | |||
| 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,:show_student_result] | |||
| before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] | |||
| include ExerciseHelper | |||
| def index | |||
| if @course.is_public == 0 && !User.current.member_of_course?(@course) | |||
| render_403 | |||
| return | |||
| end | |||
| remove_invalid_exercise(@course) | |||
| @is_teacher = User.current.allowed_to?(:as_teacher,@course) | |||
| if @is_teacher | |||
| exercises = @course.exercises.order("created_at asc") | |||
| else | |||
| exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") | |||
| 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 | |||
| exercise_end = @exercise.end_time > Time.now | |||
| if @exercise.time == -1 | |||
| @can_edit_excercise = exercise_end | |||
| else | |||
| @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin? | |||
| end | |||
| @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first | |||
| # 学生点击的时候即创建关联,自动保存 | |||
| #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) | |||
| # 已提交问卷的用户不能再访问该界面 | |||
| =begin | |||
| if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) | |||
| respond_to do |format| | |||
| format.html {render :layout => 'base_courses'} | |||
| end | |||
| else | |||
| =end | |||
| if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) | |||
| eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) | |||
| @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first | |||
| end | |||
| # @percent = get_percent(@exercise,User.current) | |||
| exercise_questions = @exercise.exercise_questions | |||
| @exercise_questions = paginateHelper exercise_questions,5 #分页 | |||
| score = calculate_student_score(@exercise, User.current) | |||
| eu = get_exercise_user(@exercise.id, User.current.id) | |||
| eu.update_attributes(:score => score) | |||
| 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 => 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 = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) | |||
| exercise.publish_time = params[:exercise][:publish_time] | |||
| exercise.user_id = User.current.id | |||
| exercise.time = params[:exercise][:time] | |||
| 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].blank? ? -1 : params[:exercise][:time] | |||
| @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) | |||
| @exercise.publish_time = params[:exercise][:publish_time] | |||
| @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : 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) | |||
| @index = params[:index] | |||
| @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) | |||
| @index = params[:index] | |||
| @exercise.exercise_questions.each do |exercise_question| | |||
| exercise_question.exercise_answers.destroy_all | |||
| end | |||
| @exercise.exercise_users.destroy_all | |||
| @exercise.exercise_status = 1 | |||
| @exercise.publish_time = nil | |||
| @exercise.save | |||
| respond_to do |format| | |||
| format.js | |||
| 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.where("exercise_status > 1").order("created_at desc") | |||
| @exercise_count = @exercise.exercise_users.where('score is not NULL').count | |||
| if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now) | |||
| @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? && @exercise.end_time > Time.now | |||
| @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?) && @exercise.time != -1) || @exercise.end_time < Time.now | |||
| 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 | |||
| # 保存成功返回成功信息及当前以答题百分比 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => "ok" ,:complete => complete,: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 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => "ok",:complete => complete,: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 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => ea.answer_text,:complete => complete,: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) | |||
| if @exercise.publish_time.nil? | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| @exercise.update_attributes(:exercise_status => 2) | |||
| @exercise.update_attributes(:publish_time => Time.now) | |||
| redirect_to exercise_url(@exercise) | |||
| return | |||
| elsif @exercise.publish_time > Time.now | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| redirect_to exercise_url(@exercise) | |||
| return | |||
| end | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| redirect_to exercise_url(@exercise) | |||
| # REDO: 提示提交成功 | |||
| 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 show_student_result | |||
| @user = User.find params[:user_id] | |||
| @can_edit_excercise = false | |||
| @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first | |||
| @exercise_questions = @exercise.exercise_questions | |||
| score = calculate_student_score(@exercise, @user) | |||
| eu = get_exercise_user(@exercise.id, @user.id) | |||
| eu.update_attributes(:score => score) | |||
| respond_to do |format| | |||
| format.html {render :layout => 'base_courses'} | |||
| 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.empty? | |||
| # 问答题有多个答案 | |||
| 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_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 | |||
| @@ -0,0 +1,690 @@ | |||
| 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,:show_student_result] | |||
| before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] | |||
| include ExerciseHelper | |||
| def index | |||
| publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) | |||
| publish_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 2) | |||
| course = exercise.course | |||
| course.members.each do |m| | |||
| exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| end | |||
| end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) | |||
| end_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 3) | |||
| end | |||
| if @course.is_public == 0 && !User.current.member_of_course?(@course) | |||
| render_403 | |||
| return | |||
| end | |||
| remove_invalid_exercise(@course) | |||
| @is_teacher = User.current.allowed_to?(:as_teacher,@course) | |||
| if @is_teacher | |||
| exercises = @course.exercises.order("created_at asc") | |||
| else | |||
| exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") | |||
| end | |||
| @exercises = paginateHelper exercises,20 #分页 | |||
| respond_to do |format| | |||
| format.html | |||
| end | |||
| end | |||
| def show | |||
| publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) | |||
| publish_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 2) | |||
| course = exercise.course | |||
| course.members.each do |m| | |||
| exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| end | |||
| end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) | |||
| end_exercises.each do |exercise| | |||
| exercise.update_column('exercise_status', 3) | |||
| end | |||
| 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 | |||
| exercise_end = @exercise.end_time > Time.now | |||
| if @exercise.time == -1 | |||
| @can_edit_excercise = exercise_end | |||
| else | |||
| @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin? | |||
| end | |||
| @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first | |||
| # 学生点击的时候即创建关联,自动保存 | |||
| #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) | |||
| # 已提交问卷的用户不能再访问该界面 | |||
| =begin | |||
| if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) | |||
| respond_to do |format| | |||
| format.html {render :layout => 'base_courses'} | |||
| end | |||
| else | |||
| =end | |||
| if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) | |||
| eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) | |||
| @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first | |||
| end | |||
| # @percent = get_percent(@exercise,User.current) | |||
| exercise_questions = @exercise.exercise_questions | |||
| @exercise_questions = paginateHelper exercise_questions,5 #分页 | |||
| score = calculate_student_score(@exercise, User.current) | |||
| eu = get_exercise_user(@exercise.id, User.current.id) | |||
| eu.update_attributes(:score => score) | |||
| 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 => 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 = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) | |||
| exercise.publish_time = params[:exercise][:publish_time] | |||
| exercise.user_id = User.current.id | |||
| exercise.time = params[:exercise][:time] | |||
| 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].blank? ? -1 : params[:exercise][:time] | |||
| @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) | |||
| @exercise.publish_time = params[:exercise][:publish_time] | |||
| @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : 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) | |||
| @index = params[:index] | |||
| @exercise.exercise_status = 2 | |||
| @exercise.publish_time = Time.now | |||
| if @exercise.save | |||
| @exercise.course.members.each do |m| | |||
| @exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2) | |||
| end | |||
| #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) | |||
| @index = params[:index] | |||
| @exercise.exercise_questions.each do |exercise_question| | |||
| exercise_question.exercise_answers.destroy_all | |||
| end | |||
| @exercise.course_messages.destroy_all | |||
| @exercise.exercise_users.destroy_all | |||
| @exercise.exercise_status = 1 | |||
| @exercise.publish_time = nil | |||
| @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.where("exercise_status > 1").order("created_at desc") | |||
| @exercise_count = @exercise.exercise_users.where('score is not NULL').count | |||
| if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now) | |||
| @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? && @exercise.end_time > Time.now | |||
| @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?) && @exercise.time != -1) || @exercise.end_time < Time.now | |||
| 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 | |||
| # 保存成功返回成功信息及当前以答题百分比 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => "ok" ,:complete => complete,: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 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => "ok",:complete => complete,: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 | |||
| uncomplete_question = get_uncomplete_question(@exercise, User.current) | |||
| if uncomplete_question.count < 1 | |||
| complete = 1; | |||
| else | |||
| complete = 0; | |||
| end | |||
| @percent = get_percent(@exercise,User.current) | |||
| render :json => {:text => ea.answer_text,:complete => complete,: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) | |||
| if @exercise.publish_time.nil? | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| @exercise.update_attributes(:exercise_status => 2) | |||
| @exercise.update_attributes(:publish_time => Time.now) | |||
| course = @exercise.course | |||
| course.members.each do |m| | |||
| @exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) | |||
| end | |||
| redirect_to exercise_url(@exercise) | |||
| return | |||
| elsif @exercise.publish_time > Time.now | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| redirect_to exercise_url(@exercise) | |||
| return | |||
| end | |||
| @exercise.update_attributes(:show_result => params[:show_result]) | |||
| redirect_to exercise_url(@exercise) | |||
| # REDO: 提示提交成功 | |||
| 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 show_student_result | |||
| @user = User.find params[:user_id] | |||
| @can_edit_excercise = false | |||
| @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first | |||
| @exercise_questions = @exercise.exercise_questions | |||
| score = calculate_student_score(@exercise, @user) | |||
| eu = get_exercise_user(@exercise.id, @user.id) | |||
| eu.update_attributes(:score => score) | |||
| respond_to do |format| | |||
| format.html {render :layout => 'base_courses'} | |||
| 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.empty? | |||
| # 问答题有多个答案 | |||
| 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_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 | |||
| @@ -262,7 +262,6 @@ class HomeworkCommonController < ApplicationController | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course] | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| private | |||
| @@ -0,0 +1,402 @@ | |||
| class HomeworkCommonController < ApplicationController | |||
| require 'net/http' | |||
| require 'json' | |||
| layout "base_courses" | |||
| before_filter :find_course, :only => [:index,:new,:create,:next_step] | |||
| before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy] | |||
| before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] | |||
| before_filter :member_of_course, :only => [:index] | |||
| def index | |||
| homeworks = @course.homework_commons.order("created_at desc") | |||
| @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) | |||
| @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) | |||
| @homeworks = paginateHelper homeworks,20 | |||
| respond_to do |format| | |||
| format.html | |||
| end | |||
| end | |||
| def new | |||
| # @homework_type = "1" | |||
| # | |||
| # @homework = HomeworkCommon.new | |||
| # @homework.safe_attributes = params[:homework_common] | |||
| # @homework.late_penalty = 0 | |||
| # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') | |||
| # @homework.publish_time = Time.now.strftime('%Y-%m-%d') | |||
| # | |||
| # if @homework_type == "1" | |||
| # #匿评作业相关属性 | |||
| # @homework_detail_manual = HomeworkDetailManual.new | |||
| # @homework_detail_manual.ta_proportion = 0.6 | |||
| # @homework_detail_manual.absence_penalty = 0 | |||
| # @homework_detail_manual.evaluation_num = 3 | |||
| # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') | |||
| # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') | |||
| # @homework.homework_detail_manual = @homework_detail_manual | |||
| # elsif @homework_type == "2" | |||
| # #编程作业相关属性 | |||
| # @homework_detail_programing = HomeworkDetailPrograming.new | |||
| # @homework.homework_detail_programing = @homework_detail_programing | |||
| # end | |||
| respond_to do |format| | |||
| format.html | |||
| end | |||
| end | |||
| #新建作业下一步 | |||
| def next_step | |||
| @homework_type = params[:homework_common_type] | |||
| @homework = HomeworkCommon.new | |||
| @homework.safe_attributes = params[:homework_common] | |||
| @homework.late_penalty = 0 | |||
| @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') | |||
| @homework.publish_time = Time.now.strftime('%Y-%m-%d') | |||
| if @homework_type == "1" | |||
| #匿评作业相关属性 | |||
| @homework_detail_manual = HomeworkDetailManual.new | |||
| @homework_detail_manual.ta_proportion = 0.6 | |||
| @homework_detail_manual.absence_penalty = 0 | |||
| @homework_detail_manual.evaluation_num = 3 | |||
| @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') | |||
| @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') | |||
| @homework.homework_detail_manual = @homework_detail_manual | |||
| elsif @homework_type == "2" | |||
| #编程作业相关属性 | |||
| @homework_detail_programing = HomeworkDetailPrograming.new | |||
| @homework.homework_detail_programing = @homework_detail_programing | |||
| end | |||
| respond_to do |format| | |||
| format.html | |||
| end | |||
| end | |||
| def create | |||
| if params[:homework_common] | |||
| homework = HomeworkCommon.new | |||
| homework.name = params[:homework_common][:name] | |||
| homework.description = params[:homework_common][:description] | |||
| homework.end_time = params[:homework_common][:end_time] | |||
| homework.publish_time = params[:homework_common][:publish_time] | |||
| homework.homework_type = params[:homework_common][:homework_type] | |||
| homework.late_penalty = params[:late_penalty] | |||
| homework.user_id = User.current.id | |||
| homework.course_id = @course.id | |||
| homework.save_attachments(params[:attachments]) | |||
| render_attachment_warning_if_needed(homework) | |||
| if homework.homework_type == 2 | |||
| homework_detail_programing = HomeworkDetailPrograming.new | |||
| homework_detail_programing.language = params[:language] | |||
| homework_detail_programing.standard_code = params[:standard_code] | |||
| homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 | |||
| question = {title:homework.name,content:homework.description} | |||
| question[:input] = [] | |||
| question[:output] = [] | |||
| if params[:input] && params[:output] && params[:result] | |||
| params[:input].each do |k,v| | |||
| if params[:output].include? k | |||
| homework_test = HomeworkTest.new | |||
| homework_test.input = v | |||
| homework_test.output = params[:output][k] | |||
| homework_test.result = params[:result][k] | |||
| homework.homework_tests << homework_test | |||
| question[:input] << homework_test.input | |||
| question[:output] << homework_test.output | |||
| end | |||
| end | |||
| end | |||
| # uri = URI('http://test.gitlab.trustie.net/api/questions.json') | |||
| # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) | |||
| # req.body = question.to_json | |||
| # res = Net::HTTP.start(uri.hostname, uri.port) do |http| | |||
| # http.request(req) | |||
| # end | |||
| uri = URI('http://192.168.80.21:8080/api/questions.json') | |||
| body = question.to_json | |||
| res = Net::HTTP.new(uri.host, uri.port).start do |client| | |||
| request = Net::HTTP::Post.new(uri.path) | |||
| request.body = body | |||
| request["Content-Type"] = "application/json" | |||
| client.request(request) | |||
| end | |||
| result = JSON.parse(res.body) | |||
| homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 | |||
| homework.homework_detail_programing = homework_detail_programing | |||
| else | |||
| #匿评作业相关属性 | |||
| homework_detail_manual = HomeworkDetailManual.new | |||
| homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 | |||
| homework_detail_manual.comment_status = 1 | |||
| homework_detail_manual.evaluation_start = params[:evaluation_start] | |||
| homework_detail_manual.evaluation_end = params[:evaluation_end] | |||
| homework_detail_manual.evaluation_num = params[:evaluation_num] | |||
| homework_detail_manual.absence_penalty = params[:absence_penalty] | |||
| homework.homework_detail_manual = homework_detail_manual | |||
| end | |||
| if homework.save | |||
| homework_detail_programing.save if homework_detail_programing | |||
| homework_detail_manual.save if homework_detail_manual | |||
| respond_to do |format| | |||
| format.html { | |||
| flash[:notice] = l(:notice_successful_create) | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| } | |||
| end | |||
| return | |||
| end | |||
| end | |||
| respond_to do |format| | |||
| format.html { | |||
| flash[:notice] = l(:notice_failed_create) | |||
| redirect_to new_homework_common_path(:course => @course.id) | |||
| } | |||
| end | |||
| end | |||
| def edit | |||
| respond_to do |format| | |||
| format.html | |||
| end | |||
| end | |||
| def update | |||
| @homework.name = params[:homework_common][:name] | |||
| @homework.description = params[:homework_common][:description] | |||
| @homework.end_time = params[:homework_common][:end_time] | |||
| @homework.publish_time = params[:homework_common][:publish_time] | |||
| @homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type] | |||
| unless @homework.late_penalty == params[:late_penalty] | |||
| @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work| | |||
| student_work.late_penalty = params[:late_penalty] | |||
| student_work.save | |||
| end | |||
| @homework.late_penalty = params[:late_penalty] | |||
| end | |||
| # @homework.course_id = @course.id | |||
| #匿评作业相关属性 | |||
| if @homework.homework_type == 1 && @homework_detail_manual | |||
| @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 | |||
| @homework_detail_manual.evaluation_start = params[:evaluation_start] | |||
| @homework_detail_manual.evaluation_end = params[:evaluation_end] | |||
| @homework_detail_manual.evaluation_num = params[:evaluation_num] | |||
| unless @homework_detail_manual.absence_penalty == params[:absence_penalty] | |||
| if @homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 | |||
| work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" | |||
| @homework.student_works.each do |student_work| | |||
| absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count | |||
| student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 | |||
| student_work.save | |||
| end | |||
| end | |||
| @homework_detail_manual.absence_penalty = params[:absence_penalty] | |||
| end | |||
| elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 | |||
| @homework.student_works.where("absence_penalty != 0").each do |student_work| | |||
| student_work.late_penalty = 0 | |||
| student_work.save | |||
| end | |||
| @homework_detail_manual.absence_penalty = 0 if @homework_detail_manual | |||
| end | |||
| if @homework.homework_type == 2 && @homework_detail_programing #编程作业 | |||
| @homework_detail_programing.language = params[:language] | |||
| @homework_detail_programing.standard_code = params[:standard_code] | |||
| @homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 | |||
| homework_tests = @homework.homework_tests | |||
| #需要删除的测试 | |||
| ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i) | |||
| ids.each do |id| | |||
| homework_test = HomeworkTest.find id | |||
| homework_test.destroy if homework_test | |||
| end | |||
| if params[:input] && params[:output] | |||
| params[:input].each do |k,v| | |||
| if params[:output].include? k | |||
| homework_test = HomeworkTest.find_by_id k | |||
| if homework_test #已存在的测试,修改 | |||
| homework_test.input = v | |||
| homework_test.output = params[:output][k] | |||
| else #不存在的测试,增加 | |||
| homework_test = HomeworkTest.new | |||
| homework_test.input = v | |||
| homework_test.output = params[:output][k] | |||
| homework_test.homework_common = @homework | |||
| end | |||
| homework_test.save | |||
| end | |||
| end | |||
| end | |||
| #发送修改作业的请求 | |||
| question = {title:@homework.name,content:@homework.description} | |||
| question[:input] = [] | |||
| question[:output] = [] | |||
| @homework.homework_tests.each do |test| | |||
| question[:input] << test.input | |||
| question[:output] << test.output | |||
| end | |||
| uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json") | |||
| body = question.to_json | |||
| res = Net::HTTP.new(uri.host, uri.port).start do |client| | |||
| request = Net::HTTP::Put.new(uri.path) | |||
| request.body = body | |||
| request["Content-Type"] = "application/json" | |||
| client.request(request) | |||
| end | |||
| result = JSON.parse(res.body) | |||
| end | |||
| @homework.save_attachments(params[:attachments]) | |||
| render_attachment_warning_if_needed(@homework) | |||
| if @homework.save | |||
| @homework_detail_manual.save if @homework_detail_manual | |||
| @homework_detail_programing.save if @homework_detail_programing | |||
| respond_to do |format| | |||
| format.html { | |||
| flash[:notice] = l(:notice_successful_edit) | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| } | |||
| end | |||
| return | |||
| else | |||
| respond_to do |format| | |||
| format.html { | |||
| flash[:notice] = l(:notice_failed_edit) | |||
| redirect_to edit_homework_common_path(@homework) | |||
| } | |||
| end | |||
| end | |||
| end | |||
| def destroy | |||
| if @homework.destroy | |||
| respond_to do |format| | |||
| format.html {redirect_to homework_common_index_path(:course => @course.id)} | |||
| end | |||
| end | |||
| end | |||
| #开启匿评 | |||
| #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限 | |||
| def start_anonymous_comment | |||
| @statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) | |||
| @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") | |||
| if @homework_detail_manual.comment_status == 1 | |||
| student_works = @homework.student_works | |||
| if student_works && student_works.size >=2 | |||
| student_works.each_with_index do |work, index| | |||
| user = work.user | |||
| n = @homework_detail_manual.evaluation_num | |||
| n = n < student_works.size ? n : student_works.size - 1 | |||
| assigned_homeworks = get_assigned_homeworks(student_works, n, index) | |||
| assigned_homeworks.each do |h| | |||
| student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) | |||
| student_works_evaluation_distributions.save | |||
| end | |||
| end | |||
| @homework_detail_manual.update_column('comment_status', 2) | |||
| @statue = 1 | |||
| else | |||
| @statue = 2 | |||
| end | |||
| else | |||
| @statue = 3 | |||
| end | |||
| end | |||
| #关闭匿评 | |||
| def stop_anonymous_comment | |||
| @homework_detail_manual.update_column('comment_status', 3) | |||
| work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" | |||
| @homework.student_works.each do |student_work| | |||
| absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count | |||
| student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 | |||
| student_work.save | |||
| end | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| #提示 | |||
| def alert_anonymous_comment | |||
| @cur_size = 0 | |||
| @totle_size = 0 | |||
| if @homework_detail_manual.comment_status == 1 | |||
| @totle_size = @course.student.count | |||
| @cur_size = @homework.student_works.size | |||
| elsif @homework_detail_manual.comment_status == 2 | |||
| @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count} | |||
| @cur_size = 0 | |||
| @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} | |||
| end | |||
| @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| def programing_test | |||
| test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]} | |||
| @index = params[:index] | |||
| uri = URI('http://192.168.80.21:8080/api/realtime.json') | |||
| body = test.to_json | |||
| res = Net::HTTP.new(uri.host, uri.port).start do |client| | |||
| request = Net::HTTP::Post.new(uri.path) | |||
| request.body = body | |||
| request["Content-Type"] = "application/json" | |||
| client.request(request) | |||
| end | |||
| result = JSON.parse(res.body) | |||
| result[:results].each do |re| | |||
| @result = re[:status] | |||
| end | |||
| end | |||
| private | |||
| #获取课程 | |||
| def find_course | |||
| @course = Course.find params[:course] | |||
| rescue | |||
| render_404 | |||
| end | |||
| #获取作业 | |||
| def find_homework | |||
| @homework = HomeworkCommon.find params[:id] | |||
| @homework_detail_manual = @homework.homework_detail_manual | |||
| @homework_detail_programing = @homework.homework_detail_programing | |||
| @course = @homework.course | |||
| rescue | |||
| render_404 | |||
| end | |||
| #是不是课程的老师 | |||
| def teacher_of_course | |||
| render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? | |||
| end | |||
| #当前用户是不是课程的成员 | |||
| def member_of_course | |||
| render_403 unless @course.is_public || User.current.member_of_course?(@course) || User.current.admin? | |||
| end | |||
| def get_assigned_homeworks(student_works, n, index) | |||
| student_works += student_works | |||
| student_works[index + 1 .. index + n] | |||
| end | |||
| end | |||
| @@ -0,0 +1,297 @@ | |||
| class HomeworkCommonController < ApplicationController | |||
| require 'net/http' | |||
| require 'json' | |||
| require "base64" | |||
| layout "base_courses" | |||
| include StudentWorkHelper | |||
| before_filter :find_course, :only => [:index,:new,:create] | |||
| before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] | |||
| before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] | |||
| before_filter :member_of_course, :only => [:index] | |||
| def index | |||
| @new_homework = HomeworkCommon.new | |||
| @new_homework.homework_detail_manual = HomeworkDetailManual.new | |||
| @new_homework.course = @course | |||
| @page = params[:page] ? params[:page].to_i + 1 : 0 | |||
| @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) | |||
| @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) | |||
| @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) | |||
| @is_new = params[:is_new] | |||
| respond_to do |format| | |||
| format.js | |||
| format.html | |||
| end | |||
| end | |||
| #新建作业,在个人作业列表创建作业 | |||
| def new | |||
| render_404 | |||
| end | |||
| #新建作业,在个人作业列表创建作业 | |||
| def create | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| end | |||
| def edit | |||
| @user = User.current | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.html{render :layout => 'new_base_user'} | |||
| end | |||
| end | |||
| def update | |||
| if params[:homework_common] | |||
| @homework.name = params[:homework_common][:name] | |||
| @homework.description = params[:homework_common][:description] | |||
| if params[:homework_common][:publish_time] == "" | |||
| @homework.publish_time = Date.today | |||
| else | |||
| @homework.publish_time = params[:homework_common][:publish_time] | |||
| end | |||
| @homework.end_time = params[:homework_common][:end_time] || Time.now | |||
| @homework.course_id = params[:course_id] | |||
| homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new | |||
| if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 | |||
| homework_detail_manual.comment_status = 1 | |||
| end | |||
| homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] | |||
| homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] | |||
| @homework.save_attachments(params[:attachments]) | |||
| render_attachment_warning_if_needed(@homework) | |||
| #编程作业相关属性 | |||
| if @homework.homework_type == 2 | |||
| @homework.homework_detail_programing ||= HomeworkDetailPrograming.new | |||
| @homework_detail_programing = @homework.homework_detail_programing | |||
| @homework_detail_programing.language = params[:language_type].to_i | |||
| @homework.homework_tests.delete_all | |||
| inputs = params[:program][:input] | |||
| if Array === inputs | |||
| inputs.each_with_index do |val, i| | |||
| @homework.homework_tests << HomeworkTest.new( | |||
| input: val, | |||
| output: params[:program][:output][i] | |||
| ) | |||
| end | |||
| end | |||
| end | |||
| if @homework.save | |||
| @homework_detail_manual.save if @homework_detail_manual | |||
| @homework_detail_programing.save if @homework_detail_programing | |||
| if params[:is_in_course] == "1" | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| elsif params[:is_in_course] == "0" | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" | |||
| redirect_to user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" | |||
| redirect_to course_path(@course.id) | |||
| end | |||
| end | |||
| end | |||
| end | |||
| def destroy | |||
| if @homework.destroy | |||
| respond_to do |format| | |||
| format.html { | |||
| if params[:is_in_course] == "1" | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| elsif params[:is_in_course] == "0" | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" | |||
| redirect_to user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" | |||
| redirect_to course_path(@course.id) | |||
| end | |||
| } | |||
| end | |||
| end | |||
| end | |||
| #开启匿评 | |||
| #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限 | |||
| def start_anonymous_comment | |||
| @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) | |||
| @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") | |||
| if @homework_detail_manual.comment_status == 1 | |||
| student_works = @homework.student_works | |||
| if student_works && student_works.size >= 2 | |||
| student_works.each_with_index do |work, index| | |||
| user = work.user | |||
| n = @homework_detail_manual.evaluation_num | |||
| n = n < student_works.size ? n : student_works.size - 1 | |||
| assigned_homeworks = get_assigned_homeworks(student_works, n, index) | |||
| assigned_homeworks.each do |h| | |||
| student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) | |||
| student_works_evaluation_distributions.save | |||
| end | |||
| end | |||
| @homework_detail_manual.update_column('comment_status', 2) | |||
| @statue = 1 | |||
| # 匿评开启消息邮件通知 | |||
| send_message_anonymous_comment(@homework, m_status = 2) | |||
| Mailer.send_mail_anonymous_comment_open(@homework).deliver | |||
| else | |||
| @statue = 2 | |||
| end | |||
| else | |||
| @statue = 3 | |||
| end | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| #关闭匿评 | |||
| def stop_anonymous_comment | |||
| @homework_detail_manual.update_column('comment_status', 3) | |||
| #计算缺评扣分 | |||
| work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" | |||
| @homework.student_works.each do |student_work| | |||
| absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count | |||
| student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 | |||
| student_work.save | |||
| end | |||
| # 匿评关闭消息邮件通知 | |||
| send_message_anonymous_comment(@homework, m_status = 3) | |||
| Mailer.send_mail_anonymous_comment_close(@homework).deliver | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| # 开启/关闭匿评消息通知 | |||
| def send_message_anonymous_comment(homework, m_status ) | |||
| # status 标记匿评状态 1为关闭 0为开启 | |||
| course = homework.course | |||
| course.members.each do |m| | |||
| @homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status) | |||
| end | |||
| end | |||
| #提示 | |||
| def alert_anonymous_comment | |||
| @cur_size = 0 | |||
| @totle_size = 0 | |||
| if @homework_detail_manual.comment_status == 1 | |||
| @totle_size = @course.student.count | |||
| @cur_size = @homework.student_works.size | |||
| elsif @homework_detail_manual.comment_status == 2 | |||
| @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count} | |||
| @cur_size = 0 | |||
| @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} | |||
| end | |||
| @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| def alert_forbidden_anonymous_comment | |||
| if params[:user_activity_id] | |||
| @user_activity_id = params[:user_activity_id] | |||
| else | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course] if params[:is_in_course] | |||
| @course_activity = params[:course_activity] if params[:course_Activity] | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| def programing_test | |||
| test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]} | |||
| @index = params[:index] | |||
| uri = URI('http://192.168.80.21:8080/api/realtime.json') | |||
| body = test.to_json | |||
| res = Net::HTTP.new(uri.host, uri.port).start do |client| | |||
| request = Net::HTTP::Post.new(uri.path) | |||
| request.body = body | |||
| request["Content-Type"] = "application/json" | |||
| client.request(request) | |||
| end | |||
| result = JSON.parse(res.body) | |||
| @err_msg = result["compile_error_msg"] | |||
| result["results"].each do |re| | |||
| @result = re["status"] | |||
| end | |||
| end | |||
| #启动匿评参数设置 | |||
| def start_evaluation_set | |||
| end | |||
| #设置匿评参数 | |||
| def set_evaluation_attr | |||
| if @homework_detail_manual | |||
| unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s | |||
| @homework_detail_manual.evaluation_start = params[:evaluation_start] | |||
| end | |||
| unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s | |||
| @homework_detail_manual.evaluation_end = params[:evaluation_end] | |||
| end | |||
| @homework_detail_manual.evaluation_num = params[:evaluation_num] | |||
| @homework_detail_manual.save | |||
| end | |||
| end | |||
| #评分设置 | |||
| def score_rule_set | |||
| if params[:user_activity_id] | |||
| @user_activity_id = params[:user_activity_id] | |||
| else | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course] | |||
| end | |||
| private | |||
| #获取课程 | |||
| def find_course | |||
| @course = Course.find params[:course] | |||
| rescue | |||
| render_404 | |||
| end | |||
| #获取作业 | |||
| def find_homework | |||
| @homework = HomeworkCommon.find params[:id] | |||
| @homework_detail_manual = @homework.homework_detail_manual | |||
| @homework_detail_programing = @homework.homework_detail_programing | |||
| @course = @homework.course | |||
| rescue | |||
| render_404 | |||
| end | |||
| #是不是课程的老师 | |||
| def teacher_of_course | |||
| render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? | |||
| end | |||
| #当前用户是不是课程的成员 | |||
| def member_of_course | |||
| render_403 unless @course.is_public || User.current.member_of_course?(@course) || User.current.admin? | |||
| end | |||
| def get_assigned_homeworks(student_works, n, index) | |||
| student_works += student_works | |||
| student_works[index + 1 .. index + n] | |||
| end | |||
| end | |||
| @@ -0,0 +1,298 @@ | |||
| class HomeworkCommonController < ApplicationController | |||
| require 'net/http' | |||
| require 'json' | |||
| require "base64" | |||
| layout "base_courses" | |||
| include StudentWorkHelper | |||
| before_filter :find_course, :only => [:index,:new,:create] | |||
| before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] | |||
| before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] | |||
| before_filter :member_of_course, :only => [:index] | |||
| def index | |||
| @new_homework = HomeworkCommon.new | |||
| @new_homework.homework_detail_manual = HomeworkDetailManual.new | |||
| @new_homework.course = @course | |||
| @page = params[:page] ? params[:page].to_i + 1 : 0 | |||
| @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) | |||
| @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) | |||
| @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) | |||
| @is_new = params[:is_new] | |||
| respond_to do |format| | |||
| format.js | |||
| format.html | |||
| end | |||
| end | |||
| #新建作业,在个人作业列表创建作业 | |||
| def new | |||
| render_404 | |||
| end | |||
| #新建作业,在个人作业列表创建作业 | |||
| def create | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| end | |||
| def edit | |||
| @user = User.current | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.html{render :layout => 'new_base_user'} | |||
| end | |||
| end | |||
| def update | |||
| if params[:homework_common] | |||
| @homework.name = params[:homework_common][:name] | |||
| @homework.description = params[:homework_common][:description] | |||
| if params[:homework_common][:publish_time] == "" | |||
| @homework.publish_time = Date.today | |||
| else | |||
| @homework.publish_time = params[:homework_common][:publish_time] | |||
| end | |||
| @homework.end_time = params[:homework_common][:end_time] || Time.now | |||
| @homework.course_id = params[:course_id] | |||
| homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new | |||
| if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 | |||
| homework_detail_manual.comment_status = 1 | |||
| end | |||
| homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] | |||
| homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] | |||
| @homework.save_attachments(params[:attachments]) | |||
| render_attachment_warning_if_needed(@homework) | |||
| #编程作业相关属性 | |||
| if @homework.homework_type == 2 | |||
| @homework.homework_detail_programing ||= HomeworkDetailPrograming.new | |||
| @homework_detail_programing = @homework.homework_detail_programing | |||
| @homework_detail_programing.language = params[:language_type].to_i | |||
| @homework.homework_tests.delete_all | |||
| inputs = params[:program][:input] | |||
| if Array === inputs | |||
| inputs.each_with_index do |val, i| | |||
| @homework.homework_tests << HomeworkTest.new( | |||
| input: val, | |||
| output: params[:program][:output][i] | |||
| ) | |||
| end | |||
| end | |||
| end | |||
| if @homework.save | |||
| @homework_detail_manual.save if @homework_detail_manual | |||
| @homework_detail_programing.save if @homework_detail_programing | |||
| if params[:is_in_course] == "1" | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| elsif params[:is_in_course] == "0" | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" | |||
| redirect_to user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" | |||
| redirect_to course_path(@course.id) | |||
| end | |||
| end | |||
| end | |||
| end | |||
| def destroy | |||
| if @homework.destroy | |||
| respond_to do |format| | |||
| format.html { | |||
| if params[:is_in_course] == "1" | |||
| redirect_to homework_common_index_path(:course => @course.id) | |||
| elsif params[:is_in_course] == "0" | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" | |||
| redirect_to user_path(User.current.id) | |||
| elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" | |||
| redirect_to course_path(@course.id) | |||
| end | |||
| } | |||
| end | |||
| end | |||
| end | |||
| #开启匿评 | |||
| #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限 | |||
| def start_anonymous_comment | |||
| @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) | |||
| @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") | |||
| if @homework_detail_manual.comment_status == 1 | |||
| student_works = @homework.student_works | |||
| if student_works && student_works.size >= 2 | |||
| student_works.each_with_index do |work, index| | |||
| user = work.user | |||
| n = @homework_detail_manual.evaluation_num | |||
| n = n < student_works.size ? n : student_works.size - 1 | |||
| assigned_homeworks = get_assigned_homeworks(student_works, n, index) | |||
| assigned_homeworks.each do |h| | |||
| student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) | |||
| student_works_evaluation_distributions.save | |||
| end | |||
| end | |||
| @homework_detail_manual.update_column('comment_status', 2) | |||
| @statue = 1 | |||
| # 匿评开启消息邮件通知 | |||
| send_message_anonymous_comment(@homework, m_status = 2) | |||
| Mailer.send_mail_anonymous_comment_open(@homework).deliver | |||
| else | |||
| @statue = 2 | |||
| end | |||
| else | |||
| @statue = 3 | |||
| end | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| #关闭匿评 | |||
| def stop_anonymous_comment | |||
| @homework_detail_manual.update_column('comment_status', 3) | |||
| #计算缺评扣分 | |||
| work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" | |||
| @homework.student_works.each do |student_work| | |||
| absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count | |||
| student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 | |||
| student_work.save | |||
| end | |||
| # 匿评关闭消息邮件通知 | |||
| send_message_anonymous_comment(@homework, m_status = 3) | |||
| Mailer.send_mail_anonymous_comment_close(@homework).deliver | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| # 开启/关闭匿评消息通知 | |||
| def send_message_anonymous_comment(homework, m_status ) | |||
| # status 标记匿评状态 1为关闭 0为开启 | |||
| course = homework.course | |||
| course.members.each do |m| | |||
| @homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status) | |||
| end | |||
| end | |||
| #提示 | |||
| def alert_anonymous_comment | |||
| @cur_size = 0 | |||
| @totle_size = 0 | |||
| if @homework_detail_manual.comment_status == 1 | |||
| @totle_size = @course.student.count | |||
| @cur_size = @homework.student_works.size | |||
| elsif @homework_detail_manual.comment_status == 2 | |||
| @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count} | |||
| @cur_size = 0 | |||
| @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} | |||
| end | |||
| @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| def alert_forbidden_anonymous_comment | |||
| if params[:user_activity_id] | |||
| @user_activity_id = params[:user_activity_id] | |||
| else | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course] if params[:is_in_course] | |||
| @course_activity = params[:course_activity] if params[:course_Activity] | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| def programing_test | |||
| test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]} | |||
| @index = params[:index] | |||
| uri = URI('http://192.168.80.21:8080/api/realtime.json') | |||
| body = test.to_json | |||
| res = Net::HTTP.new(uri.host, uri.port).start do |client| | |||
| request = Net::HTTP::Post.new(uri.path) | |||
| request.body = body | |||
| request["Content-Type"] = "application/json" | |||
| client.request(request) | |||
| end | |||
| result = JSON.parse(res.body) | |||
| @err_msg = result["compile_error_msg"] | |||
| result["results"].each do |re| | |||
| @result = re["status"] | |||
| end | |||
| end | |||
| #启动匿评参数设置 | |||
| def start_evaluation_set | |||
| end | |||
| #设置匿评参数 | |||
| def set_evaluation_attr | |||
| if @homework_detail_manual | |||
| unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s | |||
| @homework_detail_manual.evaluation_start = params[:evaluation_start] | |||
| end | |||
| unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s | |||
| @homework_detail_manual.evaluation_end = params[:evaluation_end] | |||
| end | |||
| @homework_detail_manual.evaluation_num = params[:evaluation_num] | |||
| @homework_detail_manual.save | |||
| end | |||
| end | |||
| #评分设置 | |||
| def score_rule_set | |||
| if params[:user_activity_id] | |||
| @user_activity_id = params[:user_activity_id] | |||
| else | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course] | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| private | |||
| #获取课程 | |||
| def find_course | |||
| @course = Course.find params[:course] | |||
| rescue | |||
| render_404 | |||
| end | |||
| #获取作业 | |||
| def find_homework | |||
| @homework = HomeworkCommon.find params[:id] | |||
| @homework_detail_manual = @homework.homework_detail_manual | |||
| @homework_detail_programing = @homework.homework_detail_programing | |||
| @course = @homework.course | |||
| rescue | |||
| render_404 | |||
| end | |||
| #是不是课程的老师 | |||
| def teacher_of_course | |||
| render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? | |||
| end | |||
| #当前用户是不是课程的成员 | |||
| def member_of_course | |||
| render_403 unless @course.is_public || User.current.member_of_course?(@course) || User.current.admin? | |||
| end | |||
| def get_assigned_homeworks(student_works, n, index) | |||
| student_works += student_works | |||
| student_works[index + 1 .. index + n] | |||
| end | |||
| end | |||
| @@ -73,7 +73,6 @@ class MemosController < ApplicationController | |||
| end | |||
| end | |||
| #end | |||
| format.js | |||
| format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } | |||
| format.json { render json: @memo, status: :created, location: @memo } | |||
| else | |||
| @@ -153,7 +152,6 @@ class MemosController < ApplicationController | |||
| end | |||
| def update | |||
| @flag = false | |||
| respond_to do |format| | |||
| if( #@memo.update_column(:subject, params[:memo][:subject]) && | |||
| @memo.update_column(:content, params[:memo][:content]) && | |||
| @@ -161,12 +159,10 @@ class MemosController < ApplicationController | |||
| @memo.update_column(:lock, params[:memo][:lock]) && | |||
| @memo.update_column(:subject,params[:memo][:subject])) | |||
| @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) | |||
| @flag = @memo.save | |||
| @memo.save | |||
| # @memo.root.update_attribute(:updated_at, @memo.updated_at) | |||
| format.js | |||
| format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} | |||
| else | |||
| format.js | |||
| format.html { render action: "edit" } | |||
| format.json { render json: @person.errors, status: :unprocessable_entity } | |||
| end | |||
| @@ -169,11 +169,6 @@ class MessagesController < ApplicationController | |||
| course_activity.updated_at = Time.now | |||
| course_activity.save | |||
| end | |||
| forge_activity = ForgeActivity.where("forge_act_type='Message' and forge_act_id=#{@topic.id}").first | |||
| if forge_activity | |||
| forge_activity.updated_at = Time.now | |||
| forge_activity.save | |||
| end | |||
| user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first | |||
| if user_activity | |||
| user_activity.updated_at = Time.now | |||
| @@ -13,7 +13,7 @@ class OrgDocumentCommentsController < ApplicationController | |||
| @org_document_comment.content = params[:org_document_comment][:content] | |||
| if @org_document_comment.save | |||
| flash.keep[:notice] = l(:notice_successful_create) | |||
| EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) | |||
| OrgActivity | |||
| redirect_to organization_org_document_comments_path(@organization) | |||
| else | |||
| redirect_to new_org_document_comment_path(:organization_id => @organization.id) | |||
| @@ -36,18 +36,13 @@ class OrgDocumentCommentsController < ApplicationController | |||
| 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) | |||
| EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now) | |||
| end | |||
| respond_to do |format| | |||
| format.html { | |||
| if params[:flag].to_i == 0 | |||
| redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id) | |||
| else | |||
| if params[:flag].to_i == 1 | |||
| redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) | |||
| else | |||
| redirect_to organization_path(@org_document.organization.id) | |||
| end | |||
| redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) | |||
| end | |||
| } | |||
| end | |||
| @@ -86,10 +81,10 @@ class OrgDocumentCommentsController < ApplicationController | |||
| def destroy | |||
| @org_document_comment = OrgDocumentComment.find(params[:id]) | |||
| org = @org_document_comment.organization | |||
| if @org_document_comment.id == org.home_id | |||
| org.update_attributes(:home_id => nil) | |||
| end | |||
| if @org_document_comment.destroy | |||
| if @org_document_comment.id == org.id | |||
| org.home_id == nil | |||
| end | |||
| end | |||
| respond_to do |format| | |||
| format.js | |||
| @@ -37,19 +37,6 @@ class OrganizationsController < ApplicationController | |||
| @organization = Organization.new | |||
| render :layout => 'new_base' | |||
| end | |||
| def edit | |||
| @organization = Organization.find(params[:id]) | |||
| end | |||
| def destroy | |||
| @organization = Organization.find(params[:id]) | |||
| @organization.destroy | |||
| respond_to do |format| | |||
| format.html{ redirect_to admin_organization_path } | |||
| end | |||
| end | |||
| def create | |||
| @organization = Organization.new | |||
| @organization.name = params[:organization][:name] | |||
| @@ -155,12 +142,6 @@ class OrganizationsController < ApplicationController | |||
| # end | |||
| end | |||
| def cancel_homepage | |||
| @org = Organization.find(params[:id]) | |||
| @org.home_id = nil | |||
| @org.save | |||
| end | |||
| def autocomplete_search | |||
| @project = Project.find(params[:project_id]) | |||
| #@flag = params[:flag] || false | |||
| @@ -320,20 +320,9 @@ class ProjectsController < ApplicationController | |||
| @activity.scope_select {|t| !has["show_#{t}"].nil?} | |||
| =end | |||
| @page = params[:page] ? params[:page].to_i + 1 : 0 | |||
| # 根据私密性,取出符合条件的所有数据 | |||
| if User.current.member_of?(@project) || User.current.admin? | |||
| case params[:type] | |||
| when nil | |||
| @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) | |||
| when 'issue' | |||
| @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) | |||
| when 'news' | |||
| @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) | |||
| when 'message' | |||
| @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) | |||
| end | |||
| @events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20); | |||
| #events = @activity.events(@date_from, @date_to) | |||
| else | |||
| @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public | |||
| @@ -31,7 +31,7 @@ class RepositoriesController < ApplicationController | |||
| default_search_scope :changesets | |||
| before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] | |||
| before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked] | |||
| before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] | |||
| before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] | |||
| before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] | |||
| before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] | |||
| @@ -64,52 +64,32 @@ class RepositoriesController < ApplicationController | |||
| end | |||
| def forked | |||
| # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 | |||
| unless has_forked?(@project, User.current) | |||
| project = project_from_current_project(@project.id, User.current.id) | |||
| redirect_to project_path(project) | |||
| else | |||
| # 自己不能fork自己的项目 | |||
| if User.current.id == @project.user_id | |||
| flash[:notice] = l(:project_gitlab_fork_own) | |||
| redirect_to repository_url(@repository) | |||
| else | |||
| g = Gitlab.client | |||
| gproject = g.fork(@project.gpid, User.current.gid) | |||
| if gproject | |||
| copy_project(@project, gproject) | |||
| forked_count = @project.forked_count.to_i + 1 | |||
| @project.update_attributes(:forked_count => forked_count) | |||
| end | |||
| # 被forked的标识如果不满足单个用户唯一性,则不执行fork | |||
| if is_sigle_identifier?(User.current, @repository.identifier) | |||
| # REDO: 那些人有权限forked项目 | |||
| g = Gitlab.client | |||
| gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.gid}") | |||
| if gproject | |||
| copy_project(@project, gproject) | |||
| end | |||
| else | |||
| flash[:notice] = l(:project_gitlab_fork_double_message) | |||
| redirect_to settings_project_url(@project, :tab => 'repositories') | |||
| end | |||
| end | |||
| # 判断用户是否已经fork过该项目 | |||
| def has_forked?(project, user) | |||
| projects = Project.where("user_id =?", user) | |||
| projects.map(&:forked_from_project_id).detect{|s| s == @project.id}.nil? ? true : false | |||
| end | |||
| # 获取当前用户fork过的项目 | |||
| def project_from_current_project(project, user) | |||
| project = Project.where("user_id =? and forked_from_project_id =?",user, project).first | |||
| end | |||
| # copy a project for fork | |||
| def copy_project(tproject, gproject) | |||
| def copy_project(project, gproject) | |||
| project = Project.new | |||
| project.name = tproject.name | |||
| project.is_public = tproject.is_public | |||
| project.status = tproject.status | |||
| project.description = tproject.description | |||
| project.hidden_repo = tproject.hidden_repo | |||
| project.name = @project.name | |||
| project.is_public = @project.is_public | |||
| project.status = @project.status | |||
| project.description = @project.description | |||
| project.hidden_repo = @project.hidden_repo | |||
| project.user_id = User.current.id | |||
| project.project_type = 0 | |||
| project.project_new_type = tproject.project_new_type | |||
| project.project_new_type = @project.project_new_type | |||
| project.gpid = gproject.id | |||
| project.forked_from_project_id = tproject.id | |||
| if project.save | |||
| r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first | |||
| m = Member.new(:user => User.current, :roles => [r]) | |||
| @@ -144,16 +124,16 @@ class RepositoriesController < ApplicationController | |||
| def copy_repository(project, gproject) | |||
| # 避免 | |||
| # if is_sigle_identifier?(project.user_id, gproject.name) | |||
| if is_sigle_identifier?(project.user_id, gproject.name) | |||
| repository = Repository.factory('Git') | |||
| repository.project_id = project.id | |||
| repository.type = 'Repository::Gitlab' | |||
| repository.url = gproject.name | |||
| repository.identifier = gproject.name | |||
| repository = repository.save | |||
| # else | |||
| # flash[:notice] = l(:project_gitlab_create_double_message) | |||
| # end | |||
| else | |||
| flash[:notice] = l(:project_gitlab_create_double_message) | |||
| end | |||
| end | |||
| def newrepo | |||
| @@ -3,8 +3,8 @@ class StudentWorkController < ApplicationController | |||
| include StudentWorkHelper | |||
| require 'bigdecimal' | |||
| require "base64" | |||
| before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work] | |||
| before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] | |||
| before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment] | |||
| before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] | |||
| before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] | |||
| before_filter :author_of_work, :only => [:edit, :update, :destroy] | |||
| before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] | |||
| @@ -222,7 +222,7 @@ class StudentWorkController < ApplicationController | |||
| def edit | |||
| @user = User.current | |||
| if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业 | |||
| if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业 | |||
| render_403 | |||
| else | |||
| respond_to do |format| | |||
| @@ -284,23 +284,6 @@ class StudentWorkController < ApplicationController | |||
| end | |||
| end | |||
| def delete_work | |||
| @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first | |||
| if @work | |||
| @work.destroy | |||
| end | |||
| redirect_to user_homeworks_user_path(User.current.id) | |||
| end | |||
| def retry_work | |||
| if @work.destroy | |||
| @student_work = StudentWork.new | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| end | |||
| #添加评分,已评分则为修改评分 | |||
| def add_score | |||
| @is_last = params[:is_last] == "true" | |||
| @@ -500,9 +483,8 @@ class StudentWorkController < ApplicationController | |||
| if params[:student_path] | |||
| redirect_to student_work_index_url(:homework => @homework.id) | |||
| else | |||
| @user_activity_id = params[:user_activity_id].to_i | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| @user_activity_id = params[:user_activity_id] | |||
| @is_in_course = params[:is_in_course] | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| @@ -528,18 +510,6 @@ class StudentWorkController < ApplicationController | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| def revise_attachment | |||
| Attachment.attach_filesex(@work, params[:attachments], params[:attachment_type]) | |||
| revise_attachments = @work.attachments.where("attachtype = 7").reorder("created_on desc") | |||
| if revise_attachments.count == 2 | |||
| revise_attachments.last.destroy | |||
| end | |||
| #@attachment = @work.attachments.where("attachtype = 7").order("created_on desc").first | |||
| respond_to do |format| | |||
| format.js | |||
| end | |||
| end | |||
| private | |||
| def hsd_committed_work?(user, homework) | |||
| sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first | |||
| @@ -92,7 +92,7 @@ class UsersController < ApplicationController | |||
| end | |||
| # 用户消息 | |||
| # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 | |||
| # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 | |||
| # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) | |||
| def user_messages | |||
| if !User.current.logged? | |||
| @@ -128,7 +128,7 @@ class UsersController < ApplicationController | |||
| #课程相关消息 | |||
| when 'homework' | |||
| @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user).order("created_at desc") | |||
| @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?", @user).order("created_at desc") | |||
| when 'course_message' | |||
| @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") | |||
| when 'course_news' | |||
| @@ -1367,7 +1367,7 @@ class UsersController < ApplicationController | |||
| end | |||
| end | |||
| if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 | |||
| if(params[:type].blank? || params[:type] == "1") #全部 | |||
| if User.current.id.to_i == params[:id].to_i | |||
| user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 | |||
| @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ | |||
| @@ -1429,7 +1429,6 @@ class UsersController < ApplicationController | |||
| @course = @user.courses | |||
| .select { |course| @user.allowed_to?(:as_teacher,course)} | |||
| end | |||
| @search = params[:search] | |||
| #这里仅仅是传递需要发送的资源id | |||
| @send_id = params[:send_id] | |||
| @send_ids = params[:checkbox1] || params[:send_ids] | |||
| @@ -1446,7 +1445,6 @@ class UsersController < ApplicationController | |||
| else | |||
| @projects = @user.projects | |||
| end | |||
| @search = params[:search] | |||
| #这里仅仅是传递需要发送的资源id | |||
| @send_id = params[:send_id] | |||
| @send_ids = params[:checkbox1] || params[:send_ids] #搜索的时候 和 直接 用表格提交的时候的send_ids | |||
| @@ -1858,7 +1856,7 @@ class UsersController < ApplicationController | |||
| # 根据资源关键字进行搜索 | |||
| def resource_search | |||
| search = params[:search].to_s.strip.downcase | |||
| if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 | |||
| if(params[:type].nil? || params[:type] == "1") #全部 | |||
| if User.current.id.to_i == params[:id].to_i | |||
| user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 | |||
| @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ | |||
| @@ -151,104 +151,36 @@ class WelcomeController < ApplicationController | |||
| end | |||
| def search | |||
| @name = params[:q] | |||
| @search_type = params[:search_type] | |||
| case params[:search_type] | |||
| when 'all' | |||
| @alls = Elasticsearch::Model.search({ | |||
| query: { | |||
| multi_match: { | |||
| query: @name, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['login', 'firstname','lastname','name','description^0.5','filename'] | |||
| } | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| login: {}, | |||
| firstname: {}, | |||
| lastname: {}, | |||
| name:{}, | |||
| description:{}, | |||
| filename:{} | |||
| } | |||
| } | |||
| },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results | |||
| when 'user' | |||
| @users = User.search(@name).page(params[:page] || 1).per(20) | |||
| when 'project' | |||
| @projects = Project.search(@name).page(params[:page] || 1).per(20).results | |||
| when 'course' | |||
| @courses = Course.search(@name).page(params[:page] || 1).per(20).results | |||
| when 'attachment' | |||
| @attachments = Attachment.search(@name).page(params[:page] || 1).per(20).results | |||
| else | |||
| @alls = Elasticsearch::Model.search({ | |||
| query: { | |||
| multi_match: { | |||
| query: @name, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['login', 'firstname','lastname','name','description^0.5','filename'] | |||
| } | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| login: {}, | |||
| firstname: {}, | |||
| lastname: {}, | |||
| name:{}, | |||
| description:{}, | |||
| filename:{} | |||
| } | |||
| } | |||
| },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results | |||
| search_condition = params[:q] | |||
| search_type = params[:search_type].to_sym unless search_condition.blank? | |||
| search_by = params[:search_by] | |||
| if search_type.nil? && params[:contests_search] && params[:name] != "" | |||
| search_type = :contests | |||
| search_condition = params[:name] | |||
| end | |||
| @users_count = User.search(@name).results.total | |||
| @course_count = Course.search(@name).results.total | |||
| @attach_count = Attachment.search(@name).results.total | |||
| @project_count = Project.search(@name).results.total | |||
| @total_count = Elasticsearch::Model.search({ | |||
| query: { | |||
| multi_match: { | |||
| query: @name, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['login', 'firstname','lastname','name','description^0.5','filename'] | |||
| } | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| login: {}, | |||
| firstname: {}, | |||
| lastname: {}, | |||
| name:{}, | |||
| description:{}, | |||
| filename:{} | |||
| } | |||
| } | |||
| },[User,Course,Attachment,Project] ).results.total | |||
| # search_type = params[:search_type].to_sym unless search_condition.blank? | |||
| # search_by = params[:search_by] | |||
| # | |||
| # if search_type.nil? && params[:contests_search] && params[:name] != "" | |||
| # search_type = :contests | |||
| # search_condition = params[:name] | |||
| # end | |||
| respond_to do |format| | |||
| format.js | |||
| format.html{ render :layout=>'users_base'} | |||
| format.html{ | |||
| case search_type | |||
| when :projects | |||
| redirect_to projects_search_url(:name => search_condition, | |||
| :project_type => Project::ProjectType_project) | |||
| when :courses | |||
| redirect_to courses_search_url(:name => search_condition) | |||
| when :contests | |||
| redirect_to contests_url(:name => search_condition) | |||
| when :users | |||
| redirect_to users_search_url(:name => search_condition,:search_by => search_by) | |||
| when :users_teacher | |||
| redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :teacher) | |||
| when :users_student | |||
| redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :student) | |||
| else | |||
| #redirect_to home_path, :alert => l(:label_sumbit_empty) | |||
| (redirect_to signin_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? | |||
| end | |||
| } | |||
| end | |||
| end | |||
| @@ -3,8 +3,6 @@ | |||
| class WordsController < ApplicationController | |||
| include ApplicationHelper | |||
| before_filter :find_user, :only => [:new, :create, :destroy, :more, :back] | |||
| before_filter :require_login, :only => [:create_reply] | |||
| def create | |||
| if params[:new_form][:user_message].size>0 && User.current.logged? | |||
| unless params[:user_id].nil? | |||
| @@ -104,15 +102,6 @@ class WordsController < ApplicationController | |||
| @user = User.find(@journal_destroyed.jour_id) | |||
| @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count | |||
| @is_user = true | |||
| elsif @journal_destroyed.jour_type == 'HomeworkCommon' | |||
| @homework = HomeworkCommon.find @journal_destroyed.jour_id | |||
| if params[:user_activity_id] | |||
| @user_activity_id = params[:user_activity_id] | |||
| else | |||
| @user_activity_id = -1 | |||
| end | |||
| @is_in_course = params[:is_in_course].to_i | |||
| @course_activity = params[:course_activity].to_i | |||
| end | |||
| respond_to do |format| | |||
| format.js | |||
| @@ -1869,23 +1869,6 @@ module ApplicationHelper | |||
| s | |||
| end | |||
| def get_user_identity identity | |||
| s = "" | |||
| case identity | |||
| when 0 | |||
| s = '教师' | |||
| when 1 | |||
| s = '学生' | |||
| when 2 | |||
| s = '组织' | |||
| when 3 | |||
| s= '开发者' | |||
| else | |||
| s = '学生' | |||
| end | |||
| s | |||
| end | |||
| def get_memo | |||
| @new_memo = Memo.new | |||
| @public_forum = Forum.find(1) rescue ActiveRecord::RecordNotFound | |||
| @@ -2443,7 +2426,7 @@ module ApplicationHelper | |||
| 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 => "开启匿评后不可修改作品" | |||
| elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 | |||
| link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束" | |||
| link_to "匿评结束", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束" | |||
| elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品 | |||
| link_to "修改作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' | |||
| elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") | |||
| @@ -126,15 +126,4 @@ module StudentWorkHelper | |||
| end | |||
| type | |||
| end | |||
| def revise_attachment_status homework, attach | |||
| date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d") | |||
| status = "" | |||
| if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date)) | |||
| status = "此时其他同学作品已公开" | |||
| else | |||
| status = "此时其他同学作品尚未公开" | |||
| end | |||
| return status | |||
| end | |||
| end | |||
| @@ -17,7 +17,7 @@ | |||
| require "digest/md5" | |||
| require "fileutils" | |||
| require 'elasticsearch/model' | |||
| class Attachment < ActiveRecord::Base | |||
| belongs_to :container, :polymorphic => true | |||
| belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" | |||
| @@ -38,18 +38,6 @@ class Attachment < ActiveRecord::Base | |||
| validates :description, length: {maximum: 254} | |||
| validate :validate_max_file_size | |||
| #elasticsearch | |||
| include Elasticsearch::Model | |||
| #elasticsearch kaminari init | |||
| Kaminari::Hooks.init | |||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||
| settings index: { number_of_shards: 5 } do | |||
| mappings dynamic: 'false' do | |||
| indexes :filename, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :downloads, analyzer: 'smartcn',index_options: 'offsets' | |||
| end | |||
| end | |||
| acts_as_taggable | |||
| acts_as_event :title => :filename, | |||
| @@ -86,9 +74,9 @@ class Attachment < ActiveRecord::Base | |||
| @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") | |||
| before_save :files_to_final_location,:act_as_course_activity | |||
| after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index | |||
| after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index | |||
| after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index | |||
| after_create :office_conver, :be_user_score,:act_as_forge_activity | |||
| after_update :office_conver, :be_user_score | |||
| after_destroy :delete_from_disk,:down_user_score | |||
| # add by nwb | |||
| # 获取所有可公开的资源文件列表 | |||
| @@ -104,35 +92,7 @@ class Attachment < ActiveRecord::Base | |||
| " LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id + " OR #{News.table_name}.course_id in " + self.public_course_id + ")" + | |||
| " LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id) | |||
| } | |||
| scope :indexable,lambda { where('is_public = 1 and ((container_type in ("Principal")) ' + | |||
| 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ | |||
| 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')')} #用于elastic建索引的scope | |||
| def self.search(query) | |||
| __elasticsearch__.search( | |||
| { | |||
| query: { | |||
| multi_match: { | |||
| query: query, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['filename'] | |||
| } | |||
| }, | |||
| sort:{ | |||
| _score:{order:"desc"}, | |||
| downloads: {order:"desc"} | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| filename: {} | |||
| } | |||
| } | |||
| } | |||
| ) | |||
| end | |||
| # add by nwb | |||
| # 公开的项目id列表 | |||
| def self.public_project_id | |||
| @@ -601,46 +561,4 @@ class Attachment < ActiveRecord::Base | |||
| end | |||
| end | |||
| def create_attachment_ealasticsearch_index | |||
| if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || | |||
| ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || | |||
| self.container_type == 'Principal') | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| end | |||
| def update_attachment_ealasticsearch_index | |||
| if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || | |||
| ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || | |||
| self.container_type == 'Principal') | |||
| begin | |||
| self.__elasticsearch__.update_document | |||
| rescue => e | |||
| end | |||
| else | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| def delete_attachment_ealasticsearch_index | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| # Delete the previous articles index in Elasticsearch | |||
| # Attachment.__elasticsearch__.client.indices.delete index: Attachment.index_name rescue nil | |||
| # | |||
| # # Create the new index with the new mapping | |||
| # Attachment.__elasticsearch__.client.indices.create \ | |||
| # index: Attachment.index_name, | |||
| # body: { settings: Attachment.settings.to_hash, mappings: Attachment.mappings.to_hash } | |||
| # Index all article records from the DB to Elasticsearch | |||
| #暂时只做公开课程/项目里的公开资源 和其他的公开资源 | |||
| #Attachment.where('is_public = 1 and ((container_type in ("Principal")) ' + | |||
| # 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ | |||
| # 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import :force=>true | |||
| @@ -17,8 +17,8 @@ | |||
| class Board < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| belongs_to :project,:touch => true | |||
| belongs_to :course,:touch=>true | |||
| belongs_to :project | |||
| belongs_to :course | |||
| has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC" | |||
| has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC" | |||
| belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id | |||
| @@ -31,7 +31,7 @@ class Comment < ActiveRecord::Base | |||
| :title=>Proc.new {|o| "RE: #{o.commented.title}" }, | |||
| :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} } | |||
| belongs_to :commented, :polymorphic => true, :counter_cache => true,:touch => true | |||
| belongs_to :commented, :polymorphic => true, :counter_cache => true | |||
| belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' | |||
| validates_presence_of :commented, :author, :comments | |||
| safe_attributes 'comments' | |||
| @@ -81,10 +81,8 @@ class Comment < ActiveRecord::Base | |||
| # 课程成员得分(英雄榜) | |||
| def act_as_student_score | |||
| if self.commented.course | |||
| unless self.author.allowed_to?(:as_teacher, self.commented.course) | |||
| course_member_score(self.commented.course.id, self.author_id, "NewReply") | |||
| end | |||
| unless self.author.allowed_to?(:as_teacher, self.commented.course) | |||
| course_member_score(self.commented.course.id, self.author_id, "NewReply") | |||
| end | |||
| end | |||
| @@ -1,24 +1,10 @@ | |||
| require 'elasticsearch/model' | |||
| class Course < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| STATUS_ACTIVE = 1 | |||
| STATUS_CLOSED = 5 | |||
| STATUS_ARCHIVED = 9 | |||
| #elasticsearch | |||
| include Elasticsearch::Model | |||
| #elasticsearch kaminari init | |||
| Kaminari::Hooks.init | |||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||
| settings index: { number_of_shards: 5 } do | |||
| mappings dynamic: 'false' do | |||
| indexes :name, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :description, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets',type:"date" | |||
| end | |||
| end | |||
| attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name | |||
| #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier | |||
| @@ -32,7 +18,7 @@ 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, :dependent => :destroy | |||
| 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 | |||
| @@ -70,9 +56,9 @@ class Course < ActiveRecord::Base | |||
| validates_length_of :description, :maximum => 10000 | |||
| before_save :self_validate | |||
| # 公开课程变成私有课程,所有资源都变成私有 | |||
| after_update :update_files_public,:update_course_ealasticsearch_index | |||
| after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index | |||
| before_destroy :delete_all_members,:delete_course_ealasticsearch_index | |||
| after_update :update_files_public | |||
| after_create :create_board_sync, :act_as_course_activity, :act_as_course_message | |||
| before_destroy :delete_all_members | |||
| safe_attributes 'extra', | |||
| 'time', | |||
| @@ -114,34 +100,6 @@ class Course < ActiveRecord::Base | |||
| where(" LOWER(name) LIKE :p ", :p => pattern) | |||
| end | |||
| } | |||
| scope :indexable,lambda { where('is_public = 1') } | |||
| def self.search(query) | |||
| __elasticsearch__.search( | |||
| { | |||
| query: { | |||
| multi_match: { | |||
| query: query, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['name', 'description^0.5'] | |||
| } | |||
| }, | |||
| sort: { | |||
| _score:{order: "desc" }, | |||
| updated_at:{order:"desc"} | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| name: {}, | |||
| description: {} | |||
| } | |||
| } | |||
| } | |||
| ) | |||
| end | |||
| def visible?(user=User.current) | |||
| user.allowed_to?(:view_course, self) | |||
| @@ -386,57 +344,6 @@ class Course < ActiveRecord::Base | |||
| #def name | |||
| # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) | |||
| #end | |||
| # after_commit on: [:create] do | |||
| # __elasticsearch__.index_document | |||
| # end | |||
| # | |||
| # after_commit on: [:update] do | |||
| # __elasticsearch__.update_document | |||
| # end | |||
| # | |||
| # after_commit on: [:destroy] do | |||
| # __elasticsearch__.delete_document | |||
| # end | |||
| def create_course_ealasticsearch_index | |||
| if self.is_public == 1 | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| end | |||
| def update_course_ealasticsearch_index | |||
| if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 | |||
| begin | |||
| self.__elasticsearch__.update_document | |||
| rescue => e | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| else #如果是更新成为私有的,那么索引就要被删除 | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| def delete_course_ealasticsearch_index | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| # Delete the previous articles index in Elasticsearch | |||
| # Course.__elasticsearch__.client.indices.delete index: Course.index_name rescue nil | |||
| # | |||
| # # Create the new index with the new mapping | |||
| # Course.__elasticsearch__.client.indices.create \ | |||
| # index: Course.index_name, | |||
| # body: { settings: Course.settings.to_hash, mappings: Course.mappings.to_hash } | |||
| # Index all article records from the DB to Elasticsearch | |||
| #Course.where('is_public = 1').import :force=>true | |||
| @@ -17,7 +17,7 @@ | |||
| class Document < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| belongs_to :project,:touch=>true | |||
| belongs_to :project | |||
| belongs_to :user | |||
| belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" | |||
| include UserScoreHelper | |||
| @@ -2,22 +2,7 @@ class Exercise < ActiveRecord::Base | |||
| #exercise_status: 1,新建;2,发布;3,关闭 | |||
| include Redmine::SafeAttributes | |||
| belongs_to :user | |||
| belongs_to :course ,:touch => true | |||
| has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" | |||
| has_many :exercise_users, :dependent => :destroy | |||
| has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 | |||
| # 课程消息 | |||
| has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy | |||
| after_create :acts_as_course_message | |||
| def acts_as_course_message | |||
| if self.course | |||
| if self.exercise_status == 2 #未发布 | |||
| #self.course.members.each do |m| | |||
| self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2) | |||
| #end | |||
| # else | |||
| # self.course_messages.destroy_all 这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的 | |||
| end | |||
| end | |||
| end | |||
| end | |||
| @@ -48,10 +48,8 @@ class ForgeActivity < ActiveRecord::Base | |||
| 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 | |||
| if org_activity | |||
| org_activity.created_at = self.created_at | |||
| org_activity.save | |||
| end | |||
| 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, | |||
| @@ -19,7 +19,7 @@ class Issue < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| include Redmine::Utils::DateCalculation | |||
| include UserScoreHelper | |||
| belongs_to :project,:touch=> true | |||
| belongs_to :project | |||
| belongs_to :tracker | |||
| belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id' | |||
| belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' | |||
| @@ -21,10 +21,9 @@ class JournalsForMessage < ActiveRecord::Base | |||
| after_destroy :delete_kindeditor_assets | |||
| belongs_to :project, | |||
| :foreign_key => 'jour_id', | |||
| :conditions => "#{self.table_name}.jour_type = 'Project' ",:touch => true | |||
| :conditions => "#{self.table_name}.jour_type = 'Project' " | |||
| belongs_to :course, | |||
| :foreign_key => 'jour_id',:touch=>true | |||
| :foreign_key => 'jour_id' | |||
| belongs_to :jour, :polymorphic => true | |||
| @@ -20,7 +20,7 @@ class Message < ActiveRecord::Base | |||
| include UserScoreHelper | |||
| include ApplicationHelper | |||
| has_many_kindeditor_assets :assets, :dependent => :destroy | |||
| belongs_to :board,:touch => true | |||
| belongs_to :board | |||
| belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' | |||
| has_many :praise_tread, as: :praise_tread_object, dependent: :destroy | |||
| @@ -287,15 +287,13 @@ class Message < ActiveRecord::Base | |||
| # 课程成员得分(英雄榜) | |||
| def act_as_student_score | |||
| if self.course | |||
| unless self.author.allowed_to?(:as_teacher, self.course) | |||
| if self.parent_id.nil? | |||
| # 发帖 | |||
| course_member_score(self.course.id, self.author_id, "Message") | |||
| else | |||
| # 回帖 | |||
| course_member_score(self.course.id, self.author_id, "MessageReply") | |||
| end | |||
| unless self.author.allowed_to?(:as_teacher, self.course) | |||
| if self.parent_id.nil? | |||
| # 发帖 | |||
| course_member_score(self.course.id, self.author_id, "Message") | |||
| else | |||
| # 回帖 | |||
| course_member_score(self.course.id, self.author_id, "MessageReply") | |||
| end | |||
| end | |||
| end | |||
| @@ -17,11 +17,11 @@ | |||
| class News < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| belongs_to :project,:touch => true | |||
| belongs_to :project | |||
| include ApplicationHelper | |||
| has_many_kindeditor_assets :assets, :dependent => :destroy | |||
| #added by nwb | |||
| belongs_to :course,:touch => true | |||
| belongs_to :course | |||
| belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' | |||
| has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on" | |||
| # fq | |||
| @@ -3,7 +3,7 @@ class OrgDocumentComment < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| belongs_to :organization | |||
| belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' | |||
| has_many :editor_of_documents, :dependent => :destroy | |||
| acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc" | |||
| has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy | |||
| after_create :document_save_as_org_activity | |||
| @@ -5,8 +5,7 @@ class Organization < ActiveRecord::Base | |||
| has_many :projects,:through => :org_projects | |||
| has_many :courses, :through => :org_courses | |||
| has_many :org_document_comments, :dependent => :destroy | |||
| has_many :org_courses, :dependent => :destroy | |||
| has_many :org_subfields, :dependent => :destroy | |||
| has_many :org_courses | |||
| has_many :users, :through => :org_members | |||
| validates_uniqueness_of :name | |||
| after_create :save_as_org_activity | |||
| @@ -14,7 +14,7 @@ | |||
| # You should have received a copy of the GNU General Public License | |||
| # along with this program; if not, write to the Free Software | |||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
| require 'elasticsearch/model' | |||
| class Project < ActiveRecord::Base | |||
| include Redmine::SafeAttributes | |||
| ProjectType_project = 0 | |||
| @@ -30,19 +30,6 @@ class Project < ActiveRecord::Base | |||
| # Specific overidden Activities | |||
| #elasticsearch | |||
| include Elasticsearch::Model | |||
| #elasticsearch kaminari init | |||
| Kaminari::Hooks.init | |||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||
| settings index: { number_of_shards: 5 } do | |||
| mappings dynamic: 'false' do | |||
| indexes :name, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :description, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets', type:'date' | |||
| end | |||
| end | |||
| has_many :student_works | |||
| has_many :time_entry_activities | |||
| has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" | |||
| @@ -151,9 +138,8 @@ class Project < ActiveRecord::Base | |||
| #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 | |||
| after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} | |||
| # 创建project之后默认创建一个board,之后的board去掉了board的概念 | |||
| after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index | |||
| before_destroy :delete_all_members,:delete_project_ealasticsearch_index | |||
| after_update :update_project_ealasticsearch_index | |||
| after_create :create_board_sync,:acts_as_forge_activities | |||
| before_destroy :delete_all_members | |||
| def remove_references_before_destroy | |||
| return if self.id.nil? | |||
| Watcher.delete_all ['watchable_id = ?', id] | |||
| @@ -186,33 +172,7 @@ class Project < ActiveRecord::Base | |||
| } | |||
| scope :project_entities, -> { where(project_type: ProjectType_project) } | |||
| scope :course_entities, -> { where(project_type: ProjectType_course) } | |||
| scope :indexable,lambda { where('is_public = 1')} #用于elastic建索引的scope | |||
| def self.search(query) | |||
| __elasticsearch__.search( | |||
| { | |||
| query: { | |||
| multi_match: { | |||
| query: query, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['name','description^0.5'] | |||
| } | |||
| }, | |||
| sort: { | |||
| _score:{order: "desc" }, | |||
| updated_on:{order: "desc" } | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| name: {}, | |||
| description: {} | |||
| } | |||
| } | |||
| } | |||
| ) | |||
| end | |||
| def new_course | |||
| self.where('project_type = ?', 1) | |||
| end | |||
| @@ -1216,36 +1176,5 @@ class Project < ActiveRecord::Base | |||
| end | |||
| def create_project_ealasticsearch_index | |||
| if self.is_public | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| end | |||
| def update_project_ealasticsearch_index | |||
| if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 | |||
| begin | |||
| self.__elasticsearch__.update_document | |||
| rescue => e | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| else #如果是更新成为私有的,那么索引就要被删除 | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| def delete_project_ealasticsearch_index | |||
| begin | |||
| self.__elasticsearch__.delete_document | |||
| rescue => e | |||
| end | |||
| end | |||
| end | |||
| #Project.where('is_public = 1').import :force=>true | |||
| @@ -2,7 +2,7 @@ | |||
| class ProjectTags < ActiveRecord::Base | |||
| attr_accessible :description, :project_id, :tag_id, :user_id | |||
| ####################################################################################################添加代码 | |||
| belongs_to :project,:touch => true | |||
| belongs_to :project | |||
| belongs_to :tag | |||
| belongs_to :user | |||
| @@ -10,7 +10,6 @@ class StudentWork < ActiveRecord::Base | |||
| has_many :student_work_tests, order: 'id desc' | |||
| # course's message | |||
| has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy | |||
| has_many :attachments, :dependent => :destroy | |||
| before_destroy :delete_praise | |||
| before_save :set_program_score, :set_src | |||
| @@ -16,7 +16,7 @@ | |||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
| require "digest/sha1" | |||
| require 'elasticsearch/model' | |||
| class User < Principal | |||
| TEACHER = 0 | |||
| STUDENT = 1 | |||
| @@ -25,20 +25,6 @@ class User < Principal | |||
| include Redmine::SafeAttributes | |||
| seems_rateable_rater | |||
| #elasticsearch | |||
| include Elasticsearch::Model | |||
| #elasticsearch kaminari init | |||
| Kaminari::Hooks.init | |||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||
| settings index: { number_of_shards: 5 } do | |||
| mappings dynamic: 'false' do | |||
| indexes :login, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' | |||
| indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date' | |||
| end | |||
| end | |||
| # Different ways of displaying/sorting users | |||
| USER_FORMATS = { | |||
| :firstname_lastname => { | |||
| @@ -78,7 +64,6 @@ class User < Principal | |||
| }, | |||
| } | |||
| #每日一报、一事一报、不报 | |||
| MAIL_NOTIFICATION_OPTIONS = [ | |||
| #['week', :label_user_mail_option_week], | |||
| @@ -177,7 +162,6 @@ class User < Principal | |||
| ##### | |||
| has_many :shares ,:dependent => :destroy | |||
| # add by zjc | |||
| has_one :level, :class_name => 'UserLevels', :dependent => :destroy | |||
| has_many :memos , :foreign_key => 'author_id' | |||
| @@ -238,12 +222,12 @@ class User < Principal | |||
| # validates_email_realness_of :mail | |||
| before_create :set_mail_notification | |||
| before_save :update_hashed_password | |||
| before_destroy :remove_references_before_destroy,:delete_user_ealasticsearch_index | |||
| before_destroy :remove_references_before_destroy | |||
| # added by fq | |||
| after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index | |||
| after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity | |||
| # end | |||
| # 更新邮箱用户或用户名的同事,同步更新邀请信息 | |||
| after_update :update_invite_list,:update_user_ealasticsearch_index | |||
| after_update :update_invite_list | |||
| include Trustie::Gitlab::ManageUser | |||
| @@ -256,7 +240,7 @@ class User < Principal | |||
| where("#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) | |||
| } | |||
| scope :sorted, lambda { order(*User.fields_for_order_statement)} | |||
| scope :indexable,lambda { where('id not in (2,4)')} #用于elastic建索引的scope,id为2是匿名用户,4是管理员,不能被索引 | |||
| scope :like, lambda {|arg, type| | |||
| if arg.blank? | |||
| where(nil) | |||
| @@ -274,33 +258,7 @@ class User < Principal | |||
| end | |||
| end | |||
| } | |||
| def self.search(query) | |||
| __elasticsearch__.search( | |||
| { | |||
| query: { | |||
| multi_match: { | |||
| query: query, | |||
| type:"most_fields", | |||
| operator: "or", | |||
| fields: ['login', 'firstname','lastname'] | |||
| } | |||
| }, | |||
| sort:{ | |||
| _score:{order:"desc"}, | |||
| last_login_on: {order:"desc"} | |||
| }, | |||
| highlight: { | |||
| pre_tags: ['<span class="c_red">'], | |||
| post_tags: ['</span>'], | |||
| fields: { | |||
| login: {}, | |||
| firstname: {}, | |||
| lastname: {} | |||
| } | |||
| } | |||
| } | |||
| ) | |||
| end | |||
| # ====================================================================== | |||
| @@ -477,7 +435,7 @@ class User < Principal | |||
| end | |||
| if user | |||
| # user is already in local database | |||
| return nil if user.locked? | |||
| #return nil unless user.active? | |||
| return nil unless user.check_password?(password) | |||
| else | |||
| # user is not yet registered, try to authenticate with available sources | |||
| @@ -1161,23 +1119,6 @@ class User < Principal | |||
| end | |||
| end | |||
| def create_user_ealasticsearch_index | |||
| if self.id != 2 && self.id != 4 | |||
| self.__elasticsearch__.index_document | |||
| end | |||
| end | |||
| def update_user_ealasticsearch_index | |||
| if self.id != 2 && self.id != 4 | |||
| self.__elasticsearch__.update_document | |||
| end | |||
| end | |||
| def delete_user_ealasticsearch_index | |||
| if self.id != 2 && self.id != 4 | |||
| self.__elasticsearch__.delete_document | |||
| end | |||
| end | |||
| end | |||
| class AnonymousUser < User | |||
| @@ -1212,17 +1153,4 @@ class AnonymousUser < User | |||
| def destroy | |||
| false | |||
| end | |||
| end | |||
| # Delete the previous articles index in Elasticsearch | |||
| # User.__elasticsearch__.client.indices.delete index: User.index_name rescue nil | |||
| # | |||
| # # Create the new index with the new mapping | |||
| # User.__elasticsearch__.client.indices.create \ | |||
| # index: User.index_name, | |||
| # body: { settings: User.settings.to_hash, mappings: User.mappings.to_hash } | |||
| # Index all article records from the DB to Elasticsearch | |||
| # 匿名用户 角色 和 管理员角色不能被索引 | |||
| #User.where('id not in (2,4)').import :force=>true | |||
| @@ -1,50 +1,50 @@ | |||
| <%= stylesheet_link_tag 'new_user'%> | |||
| <div class="homepageContent BgBox"> | |||
| <h2 class="BgBox_h2">关于我们</h2> | |||
| <div class="AgreementBox"> | |||
| <p class="AgreementTxt"> | |||
| Trustie是一个面向高校创新实践的在线协作社区,是在中国高校推行大规模开放在线研究(Massive Open Online Research, MOORE)的支撑平台,也简称Trustie平台。老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| MOORE是国防科学技术大学杨学军院士提出的一个面向高校科研教学活动的新型创新实践概念,为全面支持高校人才培养和科学研究提供了一种新思路。MOORE是对大规模在线开放课程(Massive Open Online Course, MOOC)的拓展,是课堂教学与创新实践深度结合的全新模式,可以看作MOOC2.0。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 2005年开始,Trustie研制团队围绕网络时代的软件开发效率和质量这一核心问题展开研究,经过十年的磨砺与攻关,逐步揭示出以大众化协同开发、开放式资源共享、持续性可信评估为核心的互联网大规模协同机理,提出了全新的软件开发群体化方法。2008年起,研制团队开始探索如何将这种协同机理引入软件人才培养。MOORE概念的提出为研制团队的人才培养实践提供了新的发展方向和应用模式,使Trustie技术和工具能够更直接、更有效地与高校人才培养对接,形成了今天已被大量师生接受的在线人才培养平台。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 研制团队认为MOORE的创新人才培养模式(如图1左图)是将互联网大规模协同机理与高校创新实践活动相结合的全新人才培养方法和模式,研制团队并基于本平台的架构形成了对MOORE核心机理的三方面认识(如图1右图)。 | |||
| </p> | |||
| <div class="AgreementImg" > | |||
| <img src="images/aboutus_01.jpg" width="619" height="215" /> | |||
| <p class="AgreementTxt T_C fb mt10">图1 基于MOORE的创新人才培养模式与核心机理</p> | |||
| </div> | |||
| <p class="AgreementTxt"> | |||
| 目前,Trustie平台已经初步展现出大规模开放在线研究的生态系统蓝图,其核心是在线教学实践平台和在线协同研究平台,如图2。Trustie在线教学实践平台是支持教师和学生围绕课堂学习开展实践的平台(如图2),Trustie在线协同研究平台是支持开发小组围绕实践任务或研究工作开展分布式协作的平台(如图2)。两个核心平台为一名"新手"大学生成长为具有一定创新能力的"创客"提供了从学习到研究的一个渐进式成长环境(如图2)。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 特别是,根据师生的实际需要,Trustie平台提供了私有模式和公开模式,支持针对未公开成果实施有效知识产权保护为前提的交流分享(如图2)。随着越来越多的高校、课程和研究小组的加入,MOORE创新实践模式的生态效益将不断显现出来。 | |||
| </p> | |||
| <div class="AgreementImg" > | |||
| <img src="images/aboutus_02.jpg" width="616" height="405" /> | |||
| <p class="AgreementTxt T_C fb mt10">图2 基于MOORE的支撑平台和生态系统</p> | |||
| </div> | |||
| <p class="AgreementTxt"> | |||
| 研制团队特别感谢高校老师和学生的积极反馈、无私创意。平台的很多实用便捷的功能都是老师们积极参与和设计的结果,汇聚了大量师生的宝贵贡献,是研制团队和用户群体共同成长的结果。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| Trustie平台的基本思路是将开源模式与中国高校人才培养活动相结合,但其本质上是一种O2O(Online To Offline)的创新人才培养模式,只有在以下两个方面同步推进,才能在持续解决实际需求的过程中快速发展:<br /> | |||
| (1)构建实践平台,激活创新能力:成为支持不同规模的团队进行协同研究和协同开发的实践平台,支持各类可公开的课程实验任务、教研室科研任务的在线协同,能够有效提升和评估学生的创新能力、协作能力和实践能力。<br /> | |||
| (2)引入开源理念,形成创客文化:将互联网开源软件运动中的自由、对等、共享、创新的理念引入高校,使"自主创意并亲自动手实现创意"的创客精神深入人才培养活动,在学生群体中形成大胆创意、大胆实践的创新文化。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 研制团队认为,Trustie平台是一种"互联网+"思维在高校教育领域的大型探索性实践。作为一种互联网应用,Trustie平台自身的开发也采取了互联网模式:Trustie研制团队采用了"网构化软件开发模式",坚持"每周一更"的快速上线、快速体验模式,以最大程度上贴近用户实际需求提升。欢迎高校师生一同投身创新实践,共同见证MOORE创新生态的早日形成。 | |||
| </p> | |||
| </div> | |||
| </div><!---BgBox end---> | |||
| <div class="footer"></div> | |||
| <%= stylesheet_link_tag 'new_user'%> | |||
| <div class="homepageContent BgBox"> | |||
| <h2 class="BgBox_h2">关于我们</h2> | |||
| <div class="AgreementBox"> | |||
| <p class="AgreementTxt"> | |||
| Trustie是一个面向高校创新实践的在线协作社区,是在中国高校推行大规模开放在线研究(Massive Open Online Research, MOORE)的支撑平台,也简称Trustie平台。老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| MOORE是国防科学技术大学杨学军院士提出的一个面向高校科研教学活动的新型创新实践概念,为全面支持高校人才培养和科学研究提供了一种新思路。MOORE是对大规模在线开放课程(Massive Open Online Course, MOOC)的拓展,是课堂教学与创新实践深度结合的全新模式,可以看作MOOC2.0。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 2005年开始,Trustie研制团队围绕网络时代的软件开发效率和质量这一核心问题展开研究,经过十年的磨砺与攻关,逐步揭示出以大众化协同开发、开放式资源共享、持续性可信评估为核心的互联网大规模协同机理,提出了全新的软件开发群体化方法。2008年起,研制团队开始探索如何将这种协同机理引入软件人才培养。MOORE概念的提出为研制团队的人才培养实践提供了新的发展方向和应用模式,使Trustie技术和工具能够更直接、更有效地与高校人才培养对接,形成了今天已被大量师生接受的在线人才培养平台。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 研制团队认为MOORE的创新人才培养模式(如图1左图)是将互联网大规模协同机理与高校创新实践活动相结合的全新人才培养方法和模式,研制团队并基于本平台的架构形成了对MOORE核心机理的三方面认识(如图1右图)。 | |||
| </p> | |||
| <div class="AgreementImg" > | |||
| <img src="images/aboutus_01.jpg" width="619" height="215" /> | |||
| <p class="AgreementTxt T_C fb mt10">图1 基于MOORE的创新人才培养模式与核心机理</p> | |||
| </div> | |||
| <p class="AgreementTxt"> | |||
| 目前,Trustie平台已经初步展现出大规模开放在线研究的生态系统蓝图,其核心是在线教学实践平台和在线协同研究平台,如图2。Trustie在线教学实践平台是支持教师和学生围绕课堂学习开展实践的平台(如图2),Trustie在线协同研究平台是支持开发小组围绕实践任务或研究工作开展分布式协作的平台(如图2)。两个核心平台为一名"新手"大学生成长为具有一定创新能力的"创客"提供了从学习到研究的一个渐进式成长环境(如图2)。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 特别是,根据师生的实际需要,Trustie平台提供了私有模式和公开模式,支持针对未公开成果实施有效知识产权保护为前提的交流分享(如图2)。随着越来越多的高校、课程和研究小组的加入,MOORE创新实践模式的生态效益将不断显现出来。 | |||
| </p> | |||
| <div class="AgreementImg" > | |||
| <img src="images/aboutus_02.jpg" width="616" height="405" /> | |||
| <p class="AgreementTxt T_C fb mt10">图2 基于MOORE的支撑平台和生态系统</p> | |||
| </div> | |||
| <p class="AgreementTxt"> | |||
| 研制团队特别感谢高校老师和学生的积极反馈、无私创意。平台的很多实用便捷的功能都是老师们积极参与和设计的结果,汇聚了大量师生的宝贵贡献,是研制团队和用户群体共同成长的结果。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| Trustie平台的基本思路是将开源模式与中国高校人才培养活动相结合,但其本质上是一种O2O(Online To Offline)的创新人才培养模式,只有在以下两个方面同步推进,才能在持续解决实际需求的过程中快速发展:<br /> | |||
| (1)构建实践平台,激活创新能力:成为支持不同规模的团队进行协同研究和协同开发的实践平台,支持各类可公开的课程实验任务、教研室科研任务的在线协同,能够有效提升和评估学生的创新能力、协作能力和实践能力。<br /> | |||
| (2)引入开源理念,形成创客文化:将互联网开源软件运动中的自由、对等、共享、创新的理念引入高校,使"自主创意并亲自动手实现创意"的创客精神深入人才培养活动,在学生群体中形成大胆创意、大胆实践的创新文化。 | |||
| </p> | |||
| <p class="AgreementTxt"> | |||
| 研制团队认为,Trustie平台是一种"互联网+"思维在高校教育领域的大型探索性实践。作为一种互联网应用,Trustie平台自身的开发也采取了互联网模式:Trustie研制团队采用了"网构化软件开发模式",坚持"每周一更"的快速上线、快速体验模式,以最大程度上贴近用户实际需求提升。欢迎高校师生一同投身创新实践,共同见证MOORE创新生态的早日形成。 | |||
| </p> | |||
| </div> | |||
| </div><!---BgBox end---> | |||
| <div class="footer"></div> | |||
| @@ -1,304 +1,304 @@ | |||
| <%= stylesheet_link_tag 'new_user'%> | |||
| <%= stylesheet_link_tag 'leftside'%> | |||
| <script type="text/javascript"> | |||
| // $(document).ready(function(){ | |||
| // $("#loginSignButton").click(function(){ | |||
| // $("#signUpBox").css({display:"block"}); | |||
| // $("#loginInBox").css({display:"none"}); | |||
| // }); | |||
| // $("#loginInButton").click(function(){ | |||
| // $("#signUpBox").css({display:"none"}); | |||
| // $("#loginInBox").css({display:"block"}); | |||
| // }); | |||
| // }); | |||
| // $(function(){ | |||
| // $("#username").keypress(function(e){ | |||
| // alert(11); | |||
| // if (e.keyCode == '13') { | |||
| // $('#main_login_form').submit(); | |||
| // } | |||
| // }); | |||
| // | |||
| // $("#password").keypress(function(e){ | |||
| // if (e.keyCode == '13') { | |||
| // $('#main_login_form').submit(); | |||
| // } | |||
| // }); | |||
| // }); | |||
| $(document).ready(function(){ | |||
| $(".homepageSearchIcon").click(function(){ | |||
| var val=$('input:radio[name="search_type"]:checked').val(); | |||
| if(val==null){ | |||
| $("#navSearchAlert").css({display:"block"}); | |||
| } | |||
| else { | |||
| $("#navSearchAlert").css({display:"none"}); | |||
| } | |||
| }); | |||
| // $("#loginInButton").click(function(){ | |||
| // $("#signUpBox").css({display:"none"}); | |||
| // $("#loginInBox").css({display:"block"}); | |||
| // }); | |||
| }); | |||
| $(document).ready(function(){ | |||
| $(".navHomepageSearchBoxcontainer").mouseover(function(){ | |||
| $(".navSearchTypeBox").css({display:"block"}); | |||
| }); | |||
| $(".navHomepageSearchBoxcontainer").mouseout(function(){ | |||
| $(".navSearchTypeBox").css({display:"none"}); | |||
| }); | |||
| }) | |||
| $(document).ready(function(){ | |||
| if(<%= @login%>){ | |||
| $("#signUpBox").css({display:"none"}); | |||
| $("#loginInBox").css({display:"block"}); | |||
| }else{ | |||
| $("#signUpBox").css({display:"block"}); | |||
| $("#loginInBox").css({display:"none"}); | |||
| } | |||
| }); | |||
| // $('#regist_btn').bind('keyup', function(event) { | |||
| // if (event.keyCode == "13" && $("#signUpBox").css('display') == 'block')) { | |||
| // register(); | |||
| // } | |||
| //}); | |||
| function clearInfo(id, content) { | |||
| var text = $('#' + id); | |||
| if (text.val() == content) { | |||
| $('#' + id).val(''); | |||
| } | |||
| } | |||
| function showInfo(id, content) { | |||
| var text = $('#' + id); | |||
| if (text.val() == '') { | |||
| $('#' + id).val(content); | |||
| } | |||
| } | |||
| function login(){ | |||
| $('#main_login_form').submit(); //表单提交没有任何反应的原因:js冲突 | |||
| } | |||
| function register(){ | |||
| if($("#loginUpButton").hasClass('loginUpDisableButton')){ | |||
| return; | |||
| } | |||
| if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct && $("#read_and_confirm").attr("checked") == 'checked'){ | |||
| $("#main_reg_form").submit(); | |||
| }else{ | |||
| $('#user_login').blur(); | |||
| $('#user_mail').blur(); | |||
| $('#user_password').blur(); | |||
| $('#user_password_confirmation').blur(); | |||
| } | |||
| } | |||
| var $login_correct = false; | |||
| var $mail_correct = false; | |||
| var $passwd_correct = false; | |||
| var $passwd_comfirm_correct = false; | |||
| jQuery(document).ready(function () { | |||
| var $login = $('#user_login') | |||
| var $mail = $('#user_mail') | |||
| var $password = $('#user_password') | |||
| var $password_confirmation = $('#user_password_confirmation') | |||
| $login.blur(function (event) { | |||
| if ($(this).is('#user_login')) { | |||
| $.get( | |||
| '<%=account_valid_ajax_path%>', | |||
| { valid: "login", | |||
| value: this.value }, | |||
| function (data) { | |||
| if (data.valid) { | |||
| $('#login_req').html('<span style="color: green">'+data.message+'</span>'); | |||
| $login_correct = true; | |||
| } else { | |||
| $('#login_req').html( '<span style="color: red">'+data.message+'</span>'); | |||
| $login_correct = false; | |||
| } | |||
| $('#login_req').css('display','block'); | |||
| }); | |||
| } | |||
| ; | |||
| }); | |||
| $mail.blur(function (event) { | |||
| if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ | |||
| $('#mail_req').html( '<span style="color: red">邮件格式不对</span>').show(); | |||
| $mail_correct = false; | |||
| return ; | |||
| } | |||
| if ($(this).is('#user_mail')) { | |||
| $.get('<%=account_valid_ajax_path%>', | |||
| { valid: "mail", | |||
| value: this.value }, | |||
| function (data) { | |||
| if (data.valid) { | |||
| $('#mail_req').html( '<span style="color: green">'+data.message+'</span>' ); | |||
| $mail_correct = true; | |||
| } else { | |||
| $('#mail_req').html( '<span style="color: red">'+data.message+'</span>' ); | |||
| $mail_correct = false; | |||
| } | |||
| $('#mail_req').css('display','block'); | |||
| }); | |||
| } | |||
| ; | |||
| }); | |||
| $password.blur(function () { | |||
| var pas1 = document.getElementById("user_password").value; | |||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||
| if (pas1.length >= password_min_length) { | |||
| $('#passwd_req').html(''); | |||
| $passwd_correct = true; | |||
| } | |||
| else { | |||
| $('#passwd_req').html( '<span style="color: red">'+'<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'+'</span>'); | |||
| $passwd_correct = false; | |||
| } | |||
| $('#passwd_req').css('display','block'); | |||
| }); | |||
| $password_confirmation.blur(function () { | |||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||
| var pas1 = document.getElementById("user_password").value; | |||
| var pas2 = document.getElementById("user_password_confirmation").value; | |||
| if (pas1.length >= password_min_length && pas1 == pas2 ) { | |||
| $('#confirm_req').html('<span style="color: green">'+'<%= l(:setting_password_success) %>'+'</span>'); | |||
| $passwd_comfirm_correct = true; | |||
| } | |||
| else { | |||
| $('#confirm_req').html('<span style="color: red">'+'<%= l(:setting_password_error) %>'+'</span>'); | |||
| $passwd_comfirm_correct = false; | |||
| } | |||
| $('#confirm_req').css('display','block'); | |||
| }); | |||
| }); | |||
| function user_name_keypress(e){ | |||
| if (e.keyCode == '13') { | |||
| $('#main_login_form').submit(); | |||
| } | |||
| } | |||
| function changeRegisterBtn(checkbox){ | |||
| if(checkbox.checked == true){ | |||
| $("#loginUpButton").removeClass('loginUpDisableButton'); | |||
| $("#loginUpButton").addClass('loginUpButton'); | |||
| }else{ | |||
| $("#loginUpButton").removeClass('loginUpButton') | |||
| $("#loginUpButton").addClass('loginUpDisableButton'); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="loginContentContainer"> | |||
| <div class="loginContent"> | |||
| <div class="loginLeft"> | |||
| <div class="loginLogo"><img src="images/trustie_big_log.png" width="100" height="88" alt="Trustie Logo" /></div> | |||
| <div class="loginInro"> 欢迎加入Trustie高校创新实践社区!老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。<br/><br/> Trustie是在中国推行大规模开放在线研究模式(MOORE)的支撑平台。</div> | |||
| </div> | |||
| <div class="loginRight"> | |||
| <div id="loginInBox"> | |||
| <div class="loginChooseBox"> | |||
| <div class="mb5"> | |||
| <ul class="loginChooseList"> | |||
| <li class="loginChoose fl"><span class="loginChooseTab">登录</span></li> | |||
| <li class="loginChooseBorder fl"></li> | |||
| </ul> | |||
| </div> | |||
| <div class="loginSignAlert" style="color: red"><%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %></div> | |||
| </div> | |||
| <div class="loginIn"> | |||
| <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> | |||
| <%= back_url_hidden_field_tag %> | |||
| <div class="mb20"> | |||
| <%= text_field_tag 'username', params[:username], :tabindex => '1' , | |||
| :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> | |||
| <!--<input type="text" placeholder="请输入邮箱地址或昵称" class="loginSignBox" />--> | |||
| </div> | |||
| <% if Setting.openid? %> | |||
| <div class="mb20"> | |||
| <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> | |||
| </div> | |||
| <% end %> | |||
| <div> | |||
| <!--<input type="text" placeholder="请输密码" class="loginSignBox" />--> | |||
| <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> | |||
| </div> | |||
| <div class="loginSignOption"> | |||
| <% if Setting.autologin? %> | |||
| <div class="fl mt3 mr5"> | |||
| <%= check_box_tag 'autologin', 1, true, :tabindex => 4 %> | |||
| </div> | |||
| <%= l(:label_stay_logged_in) %> | |||
| <% end %> | |||
| <a href="<%= lost_password_path %>" class="newsBlue mr40 fr"> | |||
| <% if Setting.lost_password? %> | |||
| <u>忘记密码?</u> | |||
| <% end %> | |||
| </a></div> | |||
| <% end %> | |||
| <div class="loginInButton" > | |||
| <a href="javascript:void(0);" id="login_btn" class="c_white db" onclick="$('#main_login_form').submit();">登录</a> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="signUpBox"> | |||
| <div class="loginChooseBox"> | |||
| <ul class="loginChooseList"> | |||
| <li class="loginChoose fl"><span class="loginChooseTab">注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></a></span> | |||
| <li class="loginChooseBorder fl"></li> | |||
| </ul> | |||
| </div> | |||
| <div class="loginIn"> | |||
| <%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %> | |||
| <%= error_messages_for 'user' %> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入邮箱地址" class="loginSignBox" />--> | |||
| <%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%> | |||
| <div class="loginSignAlert" id="mail_req" style="display: none" >请输入有效邮箱地址</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入密码" class="loginSignBox" />--> | |||
| <%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %> | |||
| <div class="loginSignAlert" id="passwd_req" style="display: none">至少需要 6 个字符</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请再次输入密码" class="loginSignBox" />--> | |||
| <%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %> | |||
| <div class="loginSignAlert" id="confirm_req" style="display: none">密码不一致</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入用户昵称" class="loginSignBox" />--> | |||
| <%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%> | |||
| <div class="loginSignAlert" id="login_req" style="display: none">用户昵称为2-18个中英文,数字或下划线</div> | |||
| </div> | |||
| <div class="loginSignOption"> | |||
| <div class="fl mt3 mr5"> | |||
| <input type="checkbox" id="read_and_confirm" onchange="changeRegisterBtn(this);"/> | |||
| </div> | |||
| 我已阅读并接受<a href="<%= agreement_path %>" class="newsBlue"><u>Trustie服务协议</u></a>条款</div> | |||
| <div class="loginUpDisableButton" id="loginUpButton"> | |||
| <a href="javascript:void(0);" class="c_white db" id="regist_btn" onclick="register();" >注册</a> | |||
| </div> | |||
| <% end %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| <%= stylesheet_link_tag 'new_user'%> | |||
| <%= stylesheet_link_tag 'leftside'%> | |||
| <script type="text/javascript"> | |||
| // $(document).ready(function(){ | |||
| // $("#loginSignButton").click(function(){ | |||
| // $("#signUpBox").css({display:"block"}); | |||
| // $("#loginInBox").css({display:"none"}); | |||
| // }); | |||
| // $("#loginInButton").click(function(){ | |||
| // $("#signUpBox").css({display:"none"}); | |||
| // $("#loginInBox").css({display:"block"}); | |||
| // }); | |||
| // }); | |||
| // $(function(){ | |||
| // $("#username").keypress(function(e){ | |||
| // alert(11); | |||
| // if (e.keyCode == '13') { | |||
| // $('#main_login_form').submit(); | |||
| // } | |||
| // }); | |||
| // | |||
| // $("#password").keypress(function(e){ | |||
| // if (e.keyCode == '13') { | |||
| // $('#main_login_form').submit(); | |||
| // } | |||
| // }); | |||
| // }); | |||
| $(document).ready(function(){ | |||
| $(".homepageSearchIcon").click(function(){ | |||
| var val=$('input:radio[name="search_type"]:checked').val(); | |||
| if(val==null){ | |||
| $("#navSearchAlert").css({display:"block"}); | |||
| } | |||
| else { | |||
| $("#navSearchAlert").css({display:"none"}); | |||
| } | |||
| }); | |||
| // $("#loginInButton").click(function(){ | |||
| // $("#signUpBox").css({display:"none"}); | |||
| // $("#loginInBox").css({display:"block"}); | |||
| // }); | |||
| }); | |||
| $(document).ready(function(){ | |||
| $(".navHomepageSearchBoxcontainer").mouseover(function(){ | |||
| $(".navSearchTypeBox").css({display:"block"}); | |||
| }); | |||
| $(".navHomepageSearchBoxcontainer").mouseout(function(){ | |||
| $(".navSearchTypeBox").css({display:"none"}); | |||
| }); | |||
| }) | |||
| $(document).ready(function(){ | |||
| if(<%= @login%>){ | |||
| $("#signUpBox").css({display:"none"}); | |||
| $("#loginInBox").css({display:"block"}); | |||
| }else{ | |||
| $("#signUpBox").css({display:"block"}); | |||
| $("#loginInBox").css({display:"none"}); | |||
| } | |||
| }); | |||
| // $('#regist_btn').bind('keyup', function(event) { | |||
| // if (event.keyCode == "13" && $("#signUpBox").css('display') == 'block')) { | |||
| // register(); | |||
| // } | |||
| //}); | |||
| function clearInfo(id, content) { | |||
| var text = $('#' + id); | |||
| if (text.val() == content) { | |||
| $('#' + id).val(''); | |||
| } | |||
| } | |||
| function showInfo(id, content) { | |||
| var text = $('#' + id); | |||
| if (text.val() == '') { | |||
| $('#' + id).val(content); | |||
| } | |||
| } | |||
| function login(){ | |||
| $('#main_login_form').submit(); //表单提交没有任何反应的原因:js冲突 | |||
| } | |||
| function register(){ | |||
| if($("#loginUpButton").hasClass('loginUpDisableButton')){ | |||
| return; | |||
| } | |||
| if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct && $("#read_and_confirm").attr("checked") == 'checked'){ | |||
| $("#main_reg_form").submit(); | |||
| }else{ | |||
| $('#user_login').blur(); | |||
| $('#user_mail').blur(); | |||
| $('#user_password').blur(); | |||
| $('#user_password_confirmation').blur(); | |||
| } | |||
| } | |||
| var $login_correct = false; | |||
| var $mail_correct = false; | |||
| var $passwd_correct = false; | |||
| var $passwd_comfirm_correct = false; | |||
| jQuery(document).ready(function () { | |||
| var $login = $('#user_login') | |||
| var $mail = $('#user_mail') | |||
| var $password = $('#user_password') | |||
| var $password_confirmation = $('#user_password_confirmation') | |||
| $login.blur(function (event) { | |||
| if ($(this).is('#user_login')) { | |||
| $.get( | |||
| '<%=account_valid_ajax_path%>', | |||
| { valid: "login", | |||
| value: this.value }, | |||
| function (data) { | |||
| if (data.valid) { | |||
| $('#login_req').html('<span style="color: green">'+data.message+'</span>'); | |||
| $login_correct = true; | |||
| } else { | |||
| $('#login_req').html( '<span style="color: red">'+data.message+'</span>'); | |||
| $login_correct = false; | |||
| } | |||
| $('#login_req').css('display','block'); | |||
| }); | |||
| } | |||
| ; | |||
| }); | |||
| $mail.blur(function (event) { | |||
| if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ | |||
| $('#mail_req').html( '<span style="color: red">邮件格式不对</span>').show(); | |||
| $mail_correct = false; | |||
| return ; | |||
| } | |||
| if ($(this).is('#user_mail')) { | |||
| $.get('<%=account_valid_ajax_path%>', | |||
| { valid: "mail", | |||
| value: this.value }, | |||
| function (data) { | |||
| if (data.valid) { | |||
| $('#mail_req').html( '<span style="color: green">'+data.message+'</span>' ); | |||
| $mail_correct = true; | |||
| } else { | |||
| $('#mail_req').html( '<span style="color: red">'+data.message+'</span>' ); | |||
| $mail_correct = false; | |||
| } | |||
| $('#mail_req').css('display','block'); | |||
| }); | |||
| } | |||
| ; | |||
| }); | |||
| $password.blur(function () { | |||
| var pas1 = document.getElementById("user_password").value; | |||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||
| if (pas1.length >= password_min_length) { | |||
| $('#passwd_req').html(''); | |||
| $passwd_correct = true; | |||
| } | |||
| else { | |||
| $('#passwd_req').html( '<span style="color: red">'+'<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'+'</span>'); | |||
| $passwd_correct = false; | |||
| } | |||
| $('#passwd_req').css('display','block'); | |||
| }); | |||
| $password_confirmation.blur(function () { | |||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||
| var pas1 = document.getElementById("user_password").value; | |||
| var pas2 = document.getElementById("user_password_confirmation").value; | |||
| if (pas1.length >= password_min_length && pas1 == pas2 ) { | |||
| $('#confirm_req').html('<span style="color: green">'+'<%= l(:setting_password_success) %>'+'</span>'); | |||
| $passwd_comfirm_correct = true; | |||
| } | |||
| else { | |||
| $('#confirm_req').html('<span style="color: red">'+'<%= l(:setting_password_error) %>'+'</span>'); | |||
| $passwd_comfirm_correct = false; | |||
| } | |||
| $('#confirm_req').css('display','block'); | |||
| }); | |||
| }); | |||
| function user_name_keypress(e){ | |||
| if (e.keyCode == '13') { | |||
| $('#main_login_form').submit(); | |||
| } | |||
| } | |||
| function changeRegisterBtn(checkbox){ | |||
| if(checkbox.checked == true){ | |||
| $("#loginUpButton").removeClass('loginUpDisableButton'); | |||
| $("#loginUpButton").addClass('loginUpButton'); | |||
| }else{ | |||
| $("#loginUpButton").removeClass('loginUpButton') | |||
| $("#loginUpButton").addClass('loginUpDisableButton'); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="loginContentContainer"> | |||
| <div class="loginContent"> | |||
| <div class="loginLeft"> | |||
| <div class="loginLogo"><img src="images/trustie_big_log.png" width="100" height="88" alt="Trustie Logo" /></div> | |||
| <div class="loginInro"> 欢迎加入Trustie高校创新实践社区!老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。<br/><br/> Trustie是在中国推行大规模开放在线研究模式(MOORE)的支撑平台。</div> | |||
| </div> | |||
| <div class="loginRight"> | |||
| <div id="loginInBox"> | |||
| <div class="loginChooseBox"> | |||
| <div class="mb5"> | |||
| <ul class="loginChooseList"> | |||
| <li class="loginChoose fl"><span class="loginChooseTab">登录</span></li> | |||
| <li class="loginChooseBorder fl"></li> | |||
| </ul> | |||
| </div> | |||
| <div class="loginSignAlert" style="color: red"><%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %></div> | |||
| </div> | |||
| <div class="loginIn"> | |||
| <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> | |||
| <%= back_url_hidden_field_tag %> | |||
| <div class="mb20"> | |||
| <%= text_field_tag 'username', params[:username], :tabindex => '1' , | |||
| :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> | |||
| <!--<input type="text" placeholder="请输入邮箱地址或昵称" class="loginSignBox" />--> | |||
| </div> | |||
| <% if Setting.openid? %> | |||
| <div class="mb20"> | |||
| <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> | |||
| </div> | |||
| <% end %> | |||
| <div> | |||
| <!--<input type="text" placeholder="请输密码" class="loginSignBox" />--> | |||
| <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> | |||
| </div> | |||
| <div class="loginSignOption"> | |||
| <% if Setting.autologin? %> | |||
| <div class="fl mt3 mr5"> | |||
| <%= check_box_tag 'autologin', 1, true, :tabindex => 4 %> | |||
| </div> | |||
| <%= l(:label_stay_logged_in) %> | |||
| <% end %> | |||
| <a href="<%= lost_password_path %>" class="newsBlue mr40 fr"> | |||
| <% if Setting.lost_password? %> | |||
| <u>忘记密码?</u> | |||
| <% end %> | |||
| </a></div> | |||
| <% end %> | |||
| <div class="loginInButton" > | |||
| <a href="javascript:void(0);" id="login_btn" class="c_white db" onclick="$('#main_login_form').submit();">登录</a> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="signUpBox"> | |||
| <div class="loginChooseBox"> | |||
| <ul class="loginChooseList"> | |||
| <li class="loginChoose fl"><span class="loginChooseTab">注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></a></span> | |||
| <li class="loginChooseBorder fl"></li> | |||
| </ul> | |||
| </div> | |||
| <div class="loginIn"> | |||
| <%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %> | |||
| <%= error_messages_for 'user' %> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入邮箱地址" class="loginSignBox" />--> | |||
| <%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%> | |||
| <div class="loginSignAlert" id="mail_req" style="display: none" >请输入有效邮箱地址</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入密码" class="loginSignBox" />--> | |||
| <%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %> | |||
| <div class="loginSignAlert" id="passwd_req" style="display: none">至少需要 6 个字符</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请再次输入密码" class="loginSignBox" />--> | |||
| <%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %> | |||
| <div class="loginSignAlert" id="confirm_req" style="display: none">密码不一致</div> | |||
| </div> | |||
| <div class="loginSignRow"> | |||
| <!--<input type="text" placeholder="请输入用户昵称" class="loginSignBox" />--> | |||
| <%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%> | |||
| <div class="loginSignAlert" id="login_req" style="display: none">用户昵称为2-18个中英文,数字或下划线</div> | |||
| </div> | |||
| <div class="loginSignOption"> | |||
| <div class="fl mt3 mr5"> | |||
| <input type="checkbox" id="read_and_confirm" onchange="changeRegisterBtn(this);"/> | |||
| </div> | |||
| 我已阅读并接受<a href="<%= agreement_path %>" class="newsBlue"><u>Trustie服务协议</u></a>条款</div> | |||
| <div class="loginUpDisableButton" id="loginUpButton"> | |||
| <a href="javascript:void(0);" class="c_white db" id="regist_btn" onclick="register();" >注册</a> | |||
| </div> | |||
| <% end %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| @@ -1,9 +1,5 @@ | |||
| <% if @is_destroy%> | |||
| $("#attachment_<%= @attachment.id%>").remove(); | |||
| if(document.getElementById("uploadReviseBox")) { | |||
| $("#uploadReviseBox").removeClass('disable_link'); | |||
| $("#choose_revise_attach").attr("onclick","_file.click();"); | |||
| } | |||
| <%else%> | |||
| var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>'); | |||
| //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start | |||
| @@ -30,10 +26,5 @@ | |||
| $('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传"); | |||
| } | |||
| } | |||
| if(document.getElementById("uploadReviseBox")) { | |||
| $("#uploadReviseBox").removeClass('disable_link'); | |||
| $("#choose_revise_attach").attr("onclick","_file.click();"); | |||
| } | |||
| //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end | |||
| <% end%> | |||
| @@ -1,6 +1,3 @@ | |||
| <% if @course %> | |||
| $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); | |||
| <% else %> | |||
| $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); | |||
| <% end %> | |||
| init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); | |||
| @@ -1,47 +1,47 @@ | |||
| <% course_file_num = visable_attachemnts_incourse(@course).count%> | |||
| <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> | |||
| <% if show_nav?(@course.homework_commons.count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10"%> | |||
| <%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(@course.news.count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_file_num) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %> | |||
| <!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')--> | |||
| <a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a> | |||
| <% end %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_feedback_count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_poll_count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10"%> | |||
| <%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %> | |||
| <div class="subNav"> | |||
| <%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10"%> | |||
| <%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %> | |||
| </div> | |||
| <% course_file_num = visable_attachemnts_incourse(@course).count%> | |||
| <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> | |||
| <% if show_nav?(@course.homework_commons.count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10"%> | |||
| <%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(@course.news.count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_file_num) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %> | |||
| <!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')--> | |||
| <a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a> | |||
| <% end %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_feedback_count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10" %> | |||
| <%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(course_poll_count) %> | |||
| <div class="subNav"> | |||
| <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10"%> | |||
| <%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| <% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %> | |||
| <div class="subNav"> | |||
| <%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10"%> | |||
| <%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %> | |||
| </div> | |||
| <% end %> | |||
| @@ -1,14 +1,9 @@ | |||
| <div class="project_r_h"> | |||
| <h2 class="project_h2 fl"><%= @subPage_title%></h2> | |||
| <% if User.current.allowed_to?(:as_teacher,@course) %> | |||
| <span class="fr f14 fontGrey2" style="height: 40px; line-height: 40px; margin-right: 15px;"> | |||
| <%=link_to "修改角色", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member' %> | |||
| </span> | |||
| <% end %> | |||
| </div> | |||
| <% if @subPage_title == l(:label_student_list)%> | |||
| <%= render :partial => 'course_student', :locals => {:members => @members} %> | |||
| <% else%> | |||
| <%= render :partial => 'course_teacher', :locals => {:members => @members} %> | |||
| <% end%> | |||
| <div class="project_r_h"> | |||
| <h2 class="project_h2"><%= @subPage_title%></h2> | |||
| </div> | |||
| <% if @subPage_title == l(:label_student_list)%> | |||
| <%= render :partial => 'course_student', :locals => {:members => @members} %> | |||
| <% else%> | |||
| <%= render :partial => 'course_teacher', :locals => {:members => @members} %> | |||
| <% end%> | |||
| @@ -1,13 +1,6 @@ | |||
| <div class="project_r_h"> | |||
| <h2 class="project_h2"><%= l(:label_course_modify_settings)%></h2> | |||
| </div> | |||
| <script> | |||
| $(function(){ | |||
| <% if @select_tab == 'member'%> | |||
| $("#tb_2").click(); | |||
| <% end %> | |||
| }) | |||
| </script> | |||
| <div class="hwork_new"> | |||
| <div id="tb_" class="hwork_tb_"> | |||
| <ul> | |||
| @@ -125,4 +118,4 @@ | |||
| } | |||
| $("#time_selected").click(select); | |||
| $("#term_selected").click(select); | |||
| </script> | |||
| </script> | |||
| @@ -1,63 +1,63 @@ | |||
| <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> | |||
| <!--编辑单选start--> | |||
| <script type="text/javascript"> | |||
| function resetQuestion<%=exercise_question.id%>() | |||
| { | |||
| $("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>") | |||
| $("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>") | |||
| $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") | |||
| $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + | |||
| "<li class='ur_item'>" + | |||
| "<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" + | |||
| "<input maxlength='200' type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" + | |||
| "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" + | |||
| "</li>" + | |||
| "<div class='cl'></div>" + | |||
| "<% end%>"); | |||
| } | |||
| </script> | |||
| <div class="questionContainer" style="width: 680px;"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="<%=exercise_question.question_type %>" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入单选题题目" type="text" value="<%=exercise_question.question_title %>"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div id="poll_answers_<%=exercise_question.id%>"> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <li class="ur_item"> | |||
| <label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>"> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <% end %> | |||
| </div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,1);"> | |||
| 保存 | |||
| </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);"> | |||
| <%= l(:button_cancel)%> | |||
| </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--编辑单选 end--> | |||
| <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> | |||
| <!--编辑单选start--> | |||
| <script type="text/javascript"> | |||
| function resetQuestion<%=exercise_question.id%>() | |||
| { | |||
| $("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>") | |||
| $("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>") | |||
| $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") | |||
| $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + | |||
| "<li class='ur_item'>" + | |||
| "<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" + | |||
| "<input maxlength='200' type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" + | |||
| "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" + | |||
| "</li>" + | |||
| "<div class='cl'></div>" + | |||
| "<% end%>"); | |||
| } | |||
| </script> | |||
| <div class="questionContainer" style="width: 680px;"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="<%=exercise_question.question_type %>" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入单选题题目" type="text" value="<%=exercise_question.question_title %>"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div id="poll_answers_<%=exercise_question.id%>"> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <li class="ur_item"> | |||
| <label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[<%=exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>"> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <% end %> | |||
| </div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,1);"> | |||
| 保存 | |||
| </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);"> | |||
| <%= l(:button_cancel)%> | |||
| </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--编辑单选 end--> | |||
| <% end%> | |||
| @@ -1,63 +1,63 @@ | |||
| <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> | |||
| <!--编辑单选start--> | |||
| <script type="text/javascript"> | |||
| function resetQuestion<%=exercise_question.id%>() | |||
| { | |||
| $("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>") | |||
| $("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>") | |||
| $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") | |||
| $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + | |||
| "<li class='ur_item'>" + | |||
| "<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" + | |||
| "<input maxlength='200' type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" + | |||
| "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" + | |||
| "</li>" + | |||
| "<div class='cl'></div>" + | |||
| "<% end%>"); | |||
| } | |||
| </script> | |||
| <div class="questionContainer" style="width: 680px;"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="<%=exercise_question.question_type %>" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入多选题题目" type="text" value="<%=exercise_question.question_title %>"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div id="poll_answers_<%=exercise_question.id%>"> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <li class="ur_item"> | |||
| <label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>"> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <% end %> | |||
| </div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,2);"> | |||
| 保存 | |||
| </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);"> | |||
| <%= l(:button_cancel)%> | |||
| </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--编辑单选 end--> | |||
| <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> | |||
| <!--编辑单选start--> | |||
| <script type="text/javascript"> | |||
| function resetQuestion<%=exercise_question.id%>() | |||
| { | |||
| $("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>") | |||
| $("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>") | |||
| $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") | |||
| $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + | |||
| "<li class='ur_item'>" + | |||
| "<label>选项<%=convert_to_char (index+1).to_s %><span class='ur_index'></span>: </label>" + | |||
| "<input maxlength='200' type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value='<%=exercise_choice.choice_text %>'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" + | |||
| "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" + | |||
| "</li>" + | |||
| "<div class='cl'></div>" + | |||
| "<% end%>"); | |||
| } | |||
| </script> | |||
| <div class="questionContainer" style="width: 680px;"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="<%=exercise_question.question_type %>" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入多选题题目" type="text" value="<%=exercise_question.question_title %>"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input type="text" id="poll_question_score_<%=exercise_question.id %>" name="question_score" style="width:40px; text-align:center; padding-left:0px;" value="<%= exercise_question.question_score %>">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div id="poll_answers_<%=exercise_question.id%>"> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <li class="ur_item"> | |||
| <label>选项<%=convert_to_char (index+1).to_s %><span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[<%= exercise_choice.id %>]' placeholder='输入选项内容' value="<%=exercise_choice.choice_text %>"> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <% end %> | |||
| </div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="poll_question_standard_answer_<%=exercise_question.id %>" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text" value="<%=convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="edit_poll_question($(this),<%= exercise_question.id %>,2);"> | |||
| 保存 | |||
| </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="resetQuestion<%=exercise_question.id%>();pollQuestionCancel(<%= exercise_question.id%>);"> | |||
| <%= l(:button_cancel)%> | |||
| </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--编辑单选 end--> | |||
| <% end%> | |||
| @@ -20,7 +20,7 @@ | |||
| <a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));"> | |||
| 保存 | |||
| </a> | |||
| <a class="btn_cancel" data-button="cancel" onclick="pollsCancel();"> | |||
| <a class="btn_cancel" data-button="cancel" onclick="resetHead();pollsCancel();"> | |||
| <%= l(:button_cancel)%> | |||
| </a> | |||
| </div> | |||
| @@ -35,5 +35,6 @@ | |||
| $("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>"); | |||
| $("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>"); | |||
| /*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/ | |||
| document.getElementById("exercise_description").innerText = <%=exercise.exercise_description.html_safe %>; | |||
| } | |||
| </script> | |||
| @@ -1,60 +1,60 @@ | |||
| <%# has_commit = has_commit_poll?(poll.id ,User.current)%> | |||
| <% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%> | |||
| <% if @is_teacher%> | |||
| <li title="<%= exercise.exercise_name %>"> | |||
| <div style="width: 310px;float: left;"> | |||
| <%# if has_commit %> | |||
| <%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> | |||
| <%# else %> | |||
| <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> | |||
| <%# end %> | |||
| <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> | |||
| </div> | |||
| </li> | |||
| <%# if exercise.exercise_status == 2 %> | |||
| <!--<li><a class="polls_de fr ml5" onclick="" href="javascript:">关闭</a></li>--> | |||
| <%# else %> | |||
| <!--<li class="polls_de_grey fr ml5" title="发布的问卷才能进行关闭">关闭</li>--> | |||
| <%# end%> | |||
| <%# if exercise.exercise_status == 1%> | |||
| <!--<li class="polls_de_grey fr ml5">导出</li>--> | |||
| <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> | |||
| <!--<li><%#= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%></li>--> | |||
| <%# end%> | |||
| <% if exercise.exercise_status == 1 %> | |||
| <li><a href="javascript:" class="pollsbtn btn_pu fr mr5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li> | |||
| <% elsif exercise.exercise_status == 2%> | |||
| <li><a href="javascript:" class="pollsbtn btn_de fr mr5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li> | |||
| <% else%> | |||
| <li class="pollsbtn fr mr10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li> | |||
| <% end%> | |||
| <% if exercise.exercise_status == 1%> | |||
| <li class="pollsbtn fr mr10 pollsbtn_grey">统计结果</li> | |||
| <% else %> | |||
| <li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%></li> | |||
| <% end%> | |||
| <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> | |||
| <% if exercise.exercise_status == 1 %> | |||
| <li><%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%></li> | |||
| <li class="polls_date fr"><%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%></li> | |||
| <% else%> | |||
| <li class="polls_de_grey fr ml10" title="未发布的试卷才能进行编辑">编辑</li> | |||
| <li class="polls_date fr">已发布</li> | |||
| <% end%> | |||
| <% else%> | |||
| <% if exercise.exercise_status == 2%> | |||
| <%# if has_commit%> | |||
| <!--li><%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_st fl c_dblue" %></li> | |||
| <li class="pollsbtn_tip fl ml5">已答</li--> | |||
| <%#else%> | |||
| <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> | |||
| <%#end%> | |||
| <% end%> | |||
| <li class="polls_date fr mr10">截止时间:<%= format_time(exercise.end_time.to_s)%></li> | |||
| <%# has_commit = has_commit_poll?(poll.id ,User.current)%> | |||
| <% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%> | |||
| <% if @is_teacher%> | |||
| <li title="<%= exercise.exercise_name %>"> | |||
| <div style="width: 310px;float: left;"> | |||
| <%# if has_commit %> | |||
| <%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> | |||
| <%# else %> | |||
| <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> | |||
| <%# end %> | |||
| <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> | |||
| </div> | |||
| </li> | |||
| <%# if exercise.exercise_status == 2 %> | |||
| <!--<li><a class="polls_de fr ml5" onclick="" href="javascript:">关闭</a></li>--> | |||
| <%# else %> | |||
| <!--<li class="polls_de_grey fr ml5" title="发布的问卷才能进行关闭">关闭</li>--> | |||
| <%# end%> | |||
| <%# if exercise.exercise_status == 1%> | |||
| <!--<li class="polls_de_grey fr ml5">导出</li>--> | |||
| <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> | |||
| <!--<li><%#= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%></li>--> | |||
| <%# end%> | |||
| <% if exercise.exercise_status == 1 %> | |||
| <li><a href="javascript:" class="pollsbtn btn_pu fr mr5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li> | |||
| <% elsif exercise.exercise_status == 2%> | |||
| <li><a href="javascript:" class="pollsbtn btn_de fr mr5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li> | |||
| <% else%> | |||
| <li class="pollsbtn fr mr10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li> | |||
| <% end%> | |||
| <% if exercise.exercise_status == 1%> | |||
| <li class="pollsbtn fr mr10 pollsbtn_grey">统计结果</li> | |||
| <% else %> | |||
| <li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%></li> | |||
| <% end%> | |||
| <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> | |||
| <% if exercise.exercise_status == 1 %> | |||
| <li><%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%></li> | |||
| <li class="polls_date fr"><%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%></li> | |||
| <% else%> | |||
| <li class="polls_de_grey fr ml10" title="未发布的试卷才能进行编辑">编辑</li> | |||
| <li class="polls_date fr">已发布</li> | |||
| <% end%> | |||
| <% else%> | |||
| <% if exercise.exercise_status == 2%> | |||
| <%# if has_commit%> | |||
| <!--li><%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_st fl c_dblue" %></li> | |||
| <li class="pollsbtn_tip fl ml5">已答</li--> | |||
| <%#else%> | |||
| <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> | |||
| <%#end%> | |||
| <% end%> | |||
| <li class="polls_date fr mr10">截止时间:<%= format_time(exercise.end_time.to_s)%></li> | |||
| <% end%> | |||
| @@ -1,219 +1,219 @@ | |||
| <%= stylesheet_link_tag 'polls', :media => 'all' %> | |||
| <script type="text/javascript"> | |||
| $(function(){ | |||
| $("#RSide").removeAttr("id"); | |||
| $("#homework_page_right").css("min-height",$("#LSide").height()-30); | |||
| $("#Container").css("width","1000px"); | |||
| }); | |||
| //编辑问卷描述之后 | |||
| var popWindow ; //弹出框的引用 | |||
| var importPollPopWindow; //选择导入的弹出框引用 | |||
| function edit_head(){ | |||
| $("#exercise_description").val($("#exercise_description_div").html()); | |||
| } | |||
| $(function(){ | |||
| //点击空白处 | |||
| $(document).bind('click',function(e){ | |||
| //弹出框非空 不是a标签 点击的不是弹出框 ,那么弹出框就会隐藏 | |||
| if(popWindow && e.target.nodeName != 'A' && !popWindow.is(e.target) && popWindow.has(e.target).length === 0){ // Mark 1 | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| if(importPollPopWindow && e.target.nodeName != 'A' && !importPollPopWindow.is(e.target) && importPollPopWindow.has(e.target).length === 0){ | |||
| importPollPopWindow.css('display', 'none'); | |||
| } | |||
| }); | |||
| }) | |||
| function dismiss(quest_type,quest_id){ | |||
| popWindow = $("#div_"+quest_type+"_"+quest_id); | |||
| if(popWindow){ | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| } | |||
| function chooseQuestionType(quest_type,quest_id){ | |||
| //quest_type 分为 mc mcq single multi | |||
| //quest_id 是quetion的id 下同 | |||
| if(popWindow){ | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| popWindow = $("#div_"+quest_type+"_"+quest_id); | |||
| $("#div_"+quest_type+"_"+quest_id).click(function(e){ | |||
| e.stopPropagation(); //组织冒泡到document.body中去 | |||
| }); | |||
| $("#div_"+quest_type+"_"+quest_id).css("position", "absolute"); | |||
| $("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30); | |||
| $("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10); | |||
| if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') { | |||
| $("#div_"+quest_type+"_"+quest_id).css('display', 'none'); | |||
| } | |||
| else{ | |||
| $("#div_"+quest_type+"_"+quest_id).css('display', 'block'); | |||
| } | |||
| } | |||
| //选择导入调查问卷 | |||
| function importPoll(){ | |||
| importPollPopWindow = $("#import_poll"); | |||
| $("#import_poll").css("position", "absolute"); | |||
| $("#import_poll").css("top", $("#import_btn").offset().top+30); | |||
| $("#import_poll").css("left", $("#import_btn").offset().left-65); | |||
| $("#import_poll").css("display","block") | |||
| } | |||
| function remote_import(){ | |||
| importPollPopWindow.css('display', 'none'); | |||
| if($("#import_poll").val() === 0){ | |||
| return; | |||
| }else{ | |||
| if(confirm("确认导入问卷"+$("#import_poll").find("option:selected").text()+"?")){ | |||
| $("#import_form").submit(); | |||
| }else{ | |||
| return; | |||
| } | |||
| } | |||
| } | |||
| //添加标题时确定按钮 | |||
| function add_poll_question(doc,quest_type) | |||
| { | |||
| var title = $.trim($("#poll_questions_title").val()); | |||
| var score = $.trim($("#question_score").val()); | |||
| var standard_ans = $.trim($("#question_standard_ans").val()); | |||
| if(title.length == 0 || score.length == 0){ | |||
| alert("题目标题/分数不能为空"); | |||
| }else if(!/^[1-9][0-9]*$/.test(score)) { | |||
| alert("分数必须是非零开头的数字"); | |||
| }else if(quest_type !=3 && standard_ans.length == 0) { | |||
| alert("标准答案不能为空"); | |||
| }else{ | |||
| doc.parent().parent().parent().submit();} | |||
| } | |||
| //修改标题时确定按钮 | |||
| function edit_poll_question(doc,id,quest_type) | |||
| { | |||
| var title = $.trim($("#poll_questions_title_" + id).val()); | |||
| var score = $.trim($("#poll_question_score_"+ id).val()); | |||
| var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val()); | |||
| if(title.length == 0 || score.length == 0){ | |||
| alert("题目标题/分数不能为空"); | |||
| }else if(!/^[1-9][0-9]*$/.test(score)) { | |||
| alert("分数必须是非零开头的数字"); | |||
| }else if(quest_type !=3 && standard_ans.length == 0) { | |||
| alert("标准答案不能为空"); | |||
| }else if(quest_type ==3) { | |||
| var div = $("#poll_answers_" + id); | |||
| var candiate_answer = $(".candiate_answer",div); | |||
| if(candiate_answer.length > 0) { | |||
| for(i=0;i<candiate_answer.length;i++) { | |||
| if(i<candiate_answer.length-1 && $.trim($(candiate_answer[i]).val()) == "") { | |||
| continue; | |||
| } else if(i == (candiate_answer.length-1) && $.trim($(candiate_answer[i]).val()) == "") { | |||
| alert("候选答案不能为空"); | |||
| } else if($.trim($(candiate_answer[i]).val()) != ""){ | |||
| doc.parent().parent().parent().submit(); | |||
| break; | |||
| } | |||
| } | |||
| } else{ | |||
| alert("候选答案不能为空"); | |||
| } | |||
| }else{ | |||
| doc.parent().parent().parent().submit();} | |||
| } | |||
| //问卷头 | |||
| function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();} | |||
| function pollsSubmit(doc){ | |||
| var title = $.trim($("#exercise_name").val()); | |||
| if(title.length == 0){ | |||
| alert("测验标题不能为空"); | |||
| } else if($.trim($("#exercise_end_time").val()) =="") { | |||
| alert("截止时间不能为空"); | |||
| } else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) { | |||
| alert("截止时间不能小于当前时间"); | |||
| } else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) { | |||
| alert("测验时长必须为非零开头的数字"); | |||
| } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) { | |||
| alert("发布时间不能小于当前时间"); | |||
| } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) { | |||
| alert("截止时间不能小于发布时间"); | |||
| } else { | |||
| doc.parent().parent().parent().submit(); | |||
| } | |||
| } | |||
| function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();} | |||
| // | |||
| function pollQuestionCancel(question_id){ | |||
| $("#show_poll_questions_"+question_id).show(); | |||
| $("#edit_poll_questions_"+question_id).hide(); | |||
| } | |||
| function pollQuestionEdit(question_id){ | |||
| $("#show_poll_questions_"+question_id).hide(); | |||
| $("#edit_poll_questions_"+question_id).show(); | |||
| $("#poll_questions_title_"+question_id).focus(); | |||
| } | |||
| //单选题 | |||
| function add_single_answer(doc) | |||
| { | |||
| doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+ | |||
| "</li><div class='cl'></div>"); | |||
| } | |||
| function add_candidate_answer(doc) | |||
| { | |||
| doc.parent().after("<li class='ur_item'><label>候选答案<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='exercise_choice["+new Date().getTime()+"]' placeholder='请输入候选答案(选填)'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+ | |||
| "</li><div class='cl'></div>"); | |||
| } | |||
| function remove_single_answer(doc) | |||
| { | |||
| if(doc.parent().siblings("li").length == 0) | |||
| { | |||
| alert("至少有一个选项或一个候选答案"); | |||
| } | |||
| else | |||
| { | |||
| doc.parent().remove(); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="homepageRight mt0 ml10"> | |||
| <div class="resources"> | |||
| <!-- 头部 --> | |||
| <div id="polls_head_show" style="display: none;"> | |||
| <%= render :partial => 'show_head', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div id="polls_head_edit"> | |||
| <%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <% current_score = get_current_score @exercise %> | |||
| <div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%= current_score %> | |||
| 分</span></div> | |||
| <!-- 问题 --> | |||
| <div id="poll_content"> | |||
| <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div class="testQuestion" id="new_exercise_question"> | |||
| <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <!--选项 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="new_poll_question"> | |||
| </div> | |||
| <div id="exercise_submit"> | |||
| <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <!--contentbox end--> | |||
| </div> | |||
| </div><!--编辑end--> | |||
| <%= stylesheet_link_tag 'polls', :media => 'all' %> | |||
| <script type="text/javascript"> | |||
| $(function(){ | |||
| $("#RSide").removeAttr("id"); | |||
| $("#homework_page_right").css("min-height",$("#LSide").height()-30); | |||
| $("#Container").css("width","1000px"); | |||
| }); | |||
| //编辑问卷描述之后 | |||
| var popWindow ; //弹出框的引用 | |||
| var importPollPopWindow; //选择导入的弹出框引用 | |||
| function edit_head(){ | |||
| $("#exercise_description").val($("#exercise_description_div").html()); | |||
| } | |||
| $(function(){ | |||
| //点击空白处 | |||
| $(document).bind('click',function(e){ | |||
| //弹出框非空 不是a标签 点击的不是弹出框 ,那么弹出框就会隐藏 | |||
| if(popWindow && e.target.nodeName != 'A' && !popWindow.is(e.target) && popWindow.has(e.target).length === 0){ // Mark 1 | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| if(importPollPopWindow && e.target.nodeName != 'A' && !importPollPopWindow.is(e.target) && importPollPopWindow.has(e.target).length === 0){ | |||
| importPollPopWindow.css('display', 'none'); | |||
| } | |||
| }); | |||
| }) | |||
| function dismiss(quest_type,quest_id){ | |||
| popWindow = $("#div_"+quest_type+"_"+quest_id); | |||
| if(popWindow){ | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| } | |||
| function chooseQuestionType(quest_type,quest_id){ | |||
| //quest_type 分为 mc mcq single multi | |||
| //quest_id 是quetion的id 下同 | |||
| if(popWindow){ | |||
| popWindow.css('display', 'none'); | |||
| } | |||
| popWindow = $("#div_"+quest_type+"_"+quest_id); | |||
| $("#div_"+quest_type+"_"+quest_id).click(function(e){ | |||
| e.stopPropagation(); //组织冒泡到document.body中去 | |||
| }); | |||
| $("#div_"+quest_type+"_"+quest_id).css("position", "absolute"); | |||
| $("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30); | |||
| $("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10); | |||
| if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') { | |||
| $("#div_"+quest_type+"_"+quest_id).css('display', 'none'); | |||
| } | |||
| else{ | |||
| $("#div_"+quest_type+"_"+quest_id).css('display', 'block'); | |||
| } | |||
| } | |||
| //选择导入调查问卷 | |||
| function importPoll(){ | |||
| importPollPopWindow = $("#import_poll"); | |||
| $("#import_poll").css("position", "absolute"); | |||
| $("#import_poll").css("top", $("#import_btn").offset().top+30); | |||
| $("#import_poll").css("left", $("#import_btn").offset().left-65); | |||
| $("#import_poll").css("display","block") | |||
| } | |||
| function remote_import(){ | |||
| importPollPopWindow.css('display', 'none'); | |||
| if($("#import_poll").val() === 0){ | |||
| return; | |||
| }else{ | |||
| if(confirm("确认导入问卷"+$("#import_poll").find("option:selected").text()+"?")){ | |||
| $("#import_form").submit(); | |||
| }else{ | |||
| return; | |||
| } | |||
| } | |||
| } | |||
| //添加标题时确定按钮 | |||
| function add_poll_question(doc,quest_type) | |||
| { | |||
| var title = $.trim($("#poll_questions_title").val()); | |||
| var score = $.trim($("#question_score").val()); | |||
| var standard_ans = $.trim($("#question_standard_ans").val()); | |||
| if(title.length == 0 || score.length == 0){ | |||
| alert("题目标题/分数不能为空"); | |||
| }else if(!/^[1-9][0-9]*$/.test(score)) { | |||
| alert("分数必须是非零开头的数字"); | |||
| }else if(quest_type !=3 && standard_ans.length == 0) { | |||
| alert("标准答案不能为空"); | |||
| }else{ | |||
| doc.parent().parent().parent().submit();} | |||
| } | |||
| //修改标题时确定按钮 | |||
| function edit_poll_question(doc,id,quest_type) | |||
| { | |||
| var title = $.trim($("#poll_questions_title_" + id).val()); | |||
| var score = $.trim($("#poll_question_score_"+ id).val()); | |||
| var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val()); | |||
| if(title.length == 0 || score.length == 0){ | |||
| alert("题目标题/分数不能为空"); | |||
| }else if(!/^[1-9][0-9]*$/.test(score)) { | |||
| alert("分数必须是非零开头的数字"); | |||
| }else if(quest_type !=3 && standard_ans.length == 0) { | |||
| alert("标准答案不能为空"); | |||
| }else if(quest_type ==3) { | |||
| var div = $("#poll_answers_" + id); | |||
| var candiate_answer = $(".candiate_answer",div); | |||
| if(candiate_answer.length > 0) { | |||
| for(i=0;i<candiate_answer.length;i++) { | |||
| if(i<candiate_answer.length-1 && $.trim($(candiate_answer[i]).val()) == "") { | |||
| continue; | |||
| } else if(i == (candiate_answer.length-1) && $.trim($(candiate_answer[i]).val()) == "") { | |||
| alert("候选答案不能为空"); | |||
| } else if($.trim($(candiate_answer[i]).val()) != ""){ | |||
| doc.parent().parent().parent().submit(); | |||
| break; | |||
| } | |||
| } | |||
| } else{ | |||
| alert("候选答案不能为空"); | |||
| } | |||
| }else{ | |||
| doc.parent().parent().parent().submit();} | |||
| } | |||
| //问卷头 | |||
| function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();} | |||
| function pollsSubmit(doc){ | |||
| var title = $.trim($("#exercise_name").val()); | |||
| if(title.length == 0){ | |||
| alert("测验标题不能为空"); | |||
| } else if($.trim($("#exercise_end_time").val()) =="") { | |||
| alert("截止时间不能为空"); | |||
| } else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) { | |||
| alert("截止时间不能小于当前时间"); | |||
| } else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) { | |||
| alert("测验时长必须为非零开头的数字"); | |||
| } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) { | |||
| alert("发布时间不能小于当前时间"); | |||
| } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) { | |||
| alert("截止时间不能小于发布时间"); | |||
| } else { | |||
| doc.parent().parent().parent().submit(); | |||
| } | |||
| } | |||
| function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();} | |||
| // | |||
| function pollQuestionCancel(question_id){ | |||
| $("#show_poll_questions_"+question_id).show(); | |||
| $("#edit_poll_questions_"+question_id).hide(); | |||
| } | |||
| function pollQuestionEdit(question_id){ | |||
| $("#show_poll_questions_"+question_id).hide(); | |||
| $("#edit_poll_questions_"+question_id).show(); | |||
| $("#poll_questions_title_"+question_id).focus(); | |||
| } | |||
| //单选题 | |||
| function add_single_answer(doc) | |||
| { | |||
| doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+ | |||
| "</li><div class='cl'></div>"); | |||
| } | |||
| function add_candidate_answer(doc) | |||
| { | |||
| doc.parent().after("<li class='ur_item'><label>候选答案<span class='ur_index'></span>: </label><input maxlength='200' type='text' name='exercise_choice["+new Date().getTime()+"]' placeholder='请输入候选答案(选填)'/>" + | |||
| "<a class='icon_add' title='向下插入选项' onclick='add_candidate_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+ | |||
| "</li><div class='cl'></div>"); | |||
| } | |||
| function remove_single_answer(doc) | |||
| { | |||
| if(doc.parent().siblings("li").length == 0) | |||
| { | |||
| alert("至少有一个选项或一个候选答案"); | |||
| } | |||
| else | |||
| { | |||
| doc.parent().remove(); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="homepageRight mt0 ml10"> | |||
| <div class="resources"> | |||
| <!-- 头部 --> | |||
| <div id="polls_head_show" style="display: none;"> | |||
| <%= render :partial => 'show_head', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div id="polls_head_edit"> | |||
| <%= render :partial => 'edit_head', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <% current_score = get_current_score @exercise %> | |||
| <div class="mb5" style="display: <%= current_score == 0 ? "none" : "" %>" id="current_score_div">目前试卷总分:<span class="c_red" id="current_score"><%= current_score %> | |||
| 分</span></div> | |||
| <!-- 问题 --> | |||
| <div id="poll_content"> | |||
| <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div class="testQuestion" id="new_exercise_question"> | |||
| <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <!--选项 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="new_poll_question"> | |||
| </div> | |||
| <div id="exercise_submit"> | |||
| <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <!--contentbox end--> | |||
| </div> | |||
| </div><!--编辑end--> | |||
| @@ -1,25 +1,25 @@ | |||
| <div class="polls_head" style="width:730px;"> | |||
| <h2>所有试卷 | |||
| <span>(<%= @obj_count%>)</span> | |||
| </h2> | |||
| <% if @is_teacher%> | |||
| <%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> | |||
| <%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %> | |||
| <% end%> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div id="polls_list" class="polls_list"> | |||
| <% @exercises.each_with_index do |exercise,index|%> | |||
| <ul id="exercises_<%= exercise.id %>" class="polls_list_ul"> | |||
| <%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| <ul class="wlist"> | |||
| <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| <div class="polls_head" style="width:730px;"> | |||
| <h2>所有试卷 | |||
| <span>(<%= @obj_count%>)</span> | |||
| </h2> | |||
| <% if @is_teacher%> | |||
| <%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> | |||
| <%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %> | |||
| <% end%> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div id="polls_list" class="polls_list"> | |||
| <% @exercises.each_with_index do |exercise,index|%> | |||
| <ul id="exercises_<%= exercise.id %>" class="polls_list_ul"> | |||
| <%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| <ul class="wlist"> | |||
| <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| </div><!--列表end--> | |||
| @@ -1,62 +1,62 @@ | |||
| <%= form_for(ExerciseQuestion.new, | |||
| :html => { :multipart => true }, | |||
| :url=>create_exercise_question_exercise_path(exercise.id), | |||
| :remote=>true ) do |f| %> | |||
| <div class="questionContainer"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="1" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <li class="ur_item"> | |||
| <label>选项A<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项B<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项C<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项D<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);"> 保存 </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <%= form_for(ExerciseQuestion.new, | |||
| :html => { :multipart => true }, | |||
| :url=>create_exercise_question_exercise_path(exercise.id), | |||
| :remote=>true ) do |f| %> | |||
| <div class="questionContainer"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="1" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <li class="ur_item"> | |||
| <label>选项A<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项B<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项C<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'/> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项D<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'/> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);"> 保存 </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <% end %> | |||
| @@ -1,62 +1,62 @@ | |||
| <%= form_for(ExerciseQuestion.new, | |||
| :html => { :multipart => true }, | |||
| :url=>create_exercise_question_exercise_path(exercise.id), | |||
| :remote=>true ) do |f| %> | |||
| <div class="questionContainer"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="2" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <li class="ur_item"> | |||
| <label>选项A<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项B<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项C<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项D<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);"> 保存 </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <%= form_for(ExerciseQuestion.new, | |||
| :html => { :multipart => true }, | |||
| :url=>create_exercise_question_exercise_path(exercise.id), | |||
| :remote=>true ) do |f| %> | |||
| <div class="questionContainer"> | |||
| <div class="ur_editor_title"> | |||
| <label>问题: </label> | |||
| <input name="question_type" value="2" type="hidden"> | |||
| <input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"> | |||
| </div> | |||
| <div class="ur_editor_content"> | |||
| <ul> | |||
| <li class="ur_item"> | |||
| <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> | |||
| <label>分数<span class="ur_index"></span>: </label> | |||
| <input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分 | |||
| </li> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <li class="ur_item"> | |||
| <label>选项A<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[0]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项B<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[1]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项C<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[2]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>选项D<span class="ur_index"></span>: </label> | |||
| <input maxlength="200" type='text' name='question_answer[3]' placeholder='输入选项内容'> | |||
| <a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> | |||
| <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> | |||
| </li> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <li class="ur_item"> | |||
| <label>标准答案<span class="ur_index"></span>: </label> | |||
| <input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text"> | |||
| </li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| </div> | |||
| <div class="ur_editor_footer"> | |||
| <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);"> 保存 </a> | |||
| <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <% end %> | |||
| @@ -1,111 +1,111 @@ | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| <span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div class="ur_inputs"> | |||
| <table class="ur_table" style="width:675px;"> | |||
| <tbody> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <tr> | |||
| <td> | |||
| <label> | |||
| <input class="ur_radio" type="radio" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" > | |||
| <%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%> | |||
| </label> | |||
| </td> | |||
| </tr> | |||
| <% end %> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div><!--单选题显示 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_mc_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_MC(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else{ | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="1"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项A<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项B<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项C<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项D<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>标准答案<span class="ur_index"></span>: </label>'+ | |||
| '<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,在此输入A即可" type="text">'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| } | |||
| else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| <span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div class="ur_inputs"> | |||
| <table class="ur_table" style="width:675px;"> | |||
| <tbody> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <tr> | |||
| <td> | |||
| <label> | |||
| <input class="ur_radio" type="radio" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" > | |||
| <%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%> | |||
| </label> | |||
| </td> | |||
| </tr> | |||
| <% end %> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div><!--单选题显示 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_mc_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_MC(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else{ | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="1"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项A<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项B<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项C<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项D<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>标准答案<span class="ur_index"></span>: </label>'+ | |||
| '<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,在此输入A即可" type="text">'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| } | |||
| else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| </script> | |||
| @@ -1,109 +1,109 @@ | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| <span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div class="ur_inputs"> | |||
| <table class="ur_table" style="width:675px;"> | |||
| <tbody> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <tr> | |||
| <td> | |||
| <label> | |||
| <input class="ur_radio" type="checkbox" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" > | |||
| <%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%> | |||
| </label> | |||
| </td> | |||
| </tr> | |||
| <% end %> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div><!--多选题显示 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_mcq_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_MCQ(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){ | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else { | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="2"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项A<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项B<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项C<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项D<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>标准答案<span class="ur_index"></span>: </label>'+ | |||
| '<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| }else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| <span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div class="ur_inputs"> | |||
| <table class="ur_table" style="width:675px;"> | |||
| <tbody> | |||
| <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> | |||
| <tr> | |||
| <td> | |||
| <label> | |||
| <input class="ur_radio" type="checkbox" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" > | |||
| <%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%> | |||
| </label> | |||
| </td> | |||
| </tr> | |||
| <% end %> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div><!--多选题显示 end--> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_mcq_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_MCQ(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){ | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else { | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="2"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项A<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项B<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项C<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>选项D<span class="ur_index"></span>: </label>'+ | |||
| '<input maxlength="200" type="text" name="question_answer[3]" placeholder="输入选项内容"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>标准答案<span class="ur_index"></span>: </label>'+ | |||
| '<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,B,C,在答案输入框填入ABC即可" type="text">'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| }else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| </script> | |||
| @@ -1,85 +1,85 @@ | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> | |||
| 候选答案:<%= exercise_choice.answer_text%><br /> | |||
| <% end %> | |||
| </div> | |||
| </div> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_single_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_SINGLE(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else { | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="3"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content" id="new_single">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案一<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案二<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案三<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| } else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| <div> | |||
| <div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br /> | |||
| <%= exercise_question.question_title %> | |||
| </div> | |||
| <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), | |||
| method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %> | |||
| <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a> | |||
| <a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a> | |||
| <div class="cl"></div> | |||
| <div> | |||
| <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> | |||
| 候选答案:<%= exercise_choice.answer_text%><br /> | |||
| <% end %> | |||
| </div> | |||
| </div> | |||
| <!-- 新增问题 --> | |||
| <div id="insert_new_poll_question_single_<%=exercise_question.id%>"> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function insert_SINGLE(quest_type,quest_num,quest_id){ | |||
| var forms = $("form.new_exercise_question"); | |||
| if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { | |||
| if(forms.length > 0){ | |||
| alert("请先保存正在编辑的题目再新建。"); | |||
| } else { | |||
| <% score =exercise_question.question_score %> | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( | |||
| '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ | |||
| ' <div class="questionContainer" style="width: 680px;"> '+ | |||
| '<div class="ur_editor_title"> '+ | |||
| '<label>问题: </label>'+ | |||
| '<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+ | |||
| '<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+ | |||
| '<input type="hidden" name="question_type" value="3"/>'+ | |||
| '<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_content" id="new_single">'+ | |||
| '<ul>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>分数<span class="ur_index"></span>: </label>'+ | |||
| '<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+ | |||
| '</li><div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案一<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[0]" placeholder="请输入候选答案一"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案二<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[1]" placeholder="请输入候选答案二(选填)"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li>'+ | |||
| '<div class="cl"></div>'+ | |||
| '<li class="ur_item">'+ | |||
| '<label>候选答案三<span class="ur_index"></span>: </label>'+ | |||
| '<input class="candiate_answer" type="text" name="exercise_choice[2]" placeholder="请输入候选答案三(选填)"/>'+ | |||
| '<a class="icon_add" title="向下插入选项" onclick="add_candidate_answer($(this));"></a>'+ | |||
| '<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+ | |||
| '</li></div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</ul>'+ | |||
| '</div>'+ | |||
| '<div class="ur_editor_footer">'+ | |||
| '<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);">'+ | |||
| '保存'+ | |||
| '</a>'+ | |||
| '<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+ | |||
| '<%= l(:button_cancel)%>'+ | |||
| '</a>'+ | |||
| '</div>'+ | |||
| '<div class="cl"></div>'+ | |||
| '</div>'+ | |||
| '<% end%>' | |||
| ); | |||
| $("#poll_questions_title").focus(); | |||
| } | |||
| } else { | |||
| $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); | |||
| } | |||
| } | |||
| </script> | |||
| @@ -1,68 +1,68 @@ | |||
| <%= stylesheet_link_tag 'polls', :media => 'all' %> | |||
| <script type="text/javascript"> | |||
| $(function(){ | |||
| $("#RSide").css("width","730px"); | |||
| $("#homework_page_right").css("min-height",$("#LSide").height()-30); | |||
| $("#Container").css("width","1000px"); | |||
| }); | |||
| function republish_exercise(exercise_id,index) | |||
| { | |||
| $('#ajax-modal').html("<div id='popbox02'>" + | |||
| "<div class='upload_con'>" + | |||
| "<div class='upload_box'>" + | |||
| "<p class='polls_box_p'>取消发布后学生答题将会被清空<br />是否确定取消发布该测验?</p>" + | |||
| "<div class='polls_btn_box'>" + | |||
| "<a href='/exercise/"+ exercise_id +"/republish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" + | |||
| "<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" + | |||
| "</div>" + | |||
| "<div class='cl'></div>" + | |||
| "</div>" + | |||
| "</div>" + | |||
| "</div>"); | |||
| showModal('ajax-modal', '310px'); | |||
| $('#ajax-modal').css('height','120px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| "<a onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| $('#ajax-modal').parent().removeClass("alert_praise"); | |||
| $('#ajax-modal').parent().css("top","").css("left",""); | |||
| $('#ajax-modal').parent().addClass("popbox_polls"); | |||
| } | |||
| function clickCanel(){hideModal("#popbox02");} | |||
| function exercise_submit(exercise_id,exercise_name,index) | |||
| { | |||
| if(exercise_name == 0) | |||
| { | |||
| alert("试卷标题不能为空"); | |||
| } | |||
| else | |||
| { | |||
| $('#ajax-modal').html("<div id='popbox02'>" + | |||
| "<div class='upload_con'>" + | |||
| "<div class='upload_box'>" + | |||
| "<p class='polls_box_p'>测验发布后将不能对测验进行修改,<br />是否确定发布该测验?</p>" + | |||
| "<div class='polls_btn_box'>" + | |||
| "<a href='/exercise/"+ exercise_id +"/publish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" + | |||
| "<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" + | |||
| "</div>" + | |||
| "<div class='cl'></div>" + | |||
| "</div>" + | |||
| "</div>" + | |||
| "</div>"); | |||
| showModal('ajax-modal', '310px'); | |||
| $('#ajax-modal').css('height','120px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| $('#ajax-modal').parent().removeClass("alert_praise"); | |||
| $('#ajax-modal').parent().css("top","").css("left",""); | |||
| $('#ajax-modal').parent().addClass("popbox_polls"); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="polls_content02" id="exercise" style="width: 730px;"> | |||
| <%= render :partial => 'exercises_list'%> | |||
| <%= stylesheet_link_tag 'polls', :media => 'all' %> | |||
| <script type="text/javascript"> | |||
| $(function(){ | |||
| $("#RSide").css("width","730px"); | |||
| $("#homework_page_right").css("min-height",$("#LSide").height()-30); | |||
| $("#Container").css("width","1000px"); | |||
| }); | |||
| function republish_exercise(exercise_id,index) | |||
| { | |||
| $('#ajax-modal').html("<div id='popbox02'>" + | |||
| "<div class='upload_con'>" + | |||
| "<div class='upload_box'>" + | |||
| "<p class='polls_box_p'>取消发布后学生答题将会被清空<br />是否确定取消发布该测验?</p>" + | |||
| "<div class='polls_btn_box'>" + | |||
| "<a href='/exercise/"+ exercise_id +"/republish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" + | |||
| "<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" + | |||
| "</div>" + | |||
| "<div class='cl'></div>" + | |||
| "</div>" + | |||
| "</div>" + | |||
| "</div>"); | |||
| showModal('ajax-modal', '310px'); | |||
| $('#ajax-modal').css('height','120px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| "<a onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| $('#ajax-modal').parent().removeClass("alert_praise"); | |||
| $('#ajax-modal').parent().css("top","").css("left",""); | |||
| $('#ajax-modal').parent().addClass("popbox_polls"); | |||
| } | |||
| function clickCanel(){hideModal("#popbox02");} | |||
| function exercise_submit(exercise_id,exercise_name,index) | |||
| { | |||
| if(exercise_name == 0) | |||
| { | |||
| alert("试卷标题不能为空"); | |||
| } | |||
| else | |||
| { | |||
| $('#ajax-modal').html("<div id='popbox02'>" + | |||
| "<div class='upload_con'>" + | |||
| "<div class='upload_box'>" + | |||
| "<p class='polls_box_p'>测验发布后将不能对测验进行修改,<br />是否确定发布该测验?</p>" + | |||
| "<div class='polls_btn_box'>" + | |||
| "<a href='/exercise/"+ exercise_id +"/publish_exercise?index="+index+"' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" + | |||
| "<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" + | |||
| "</div>" + | |||
| "<div class='cl'></div>" + | |||
| "</div>" + | |||
| "</div>" + | |||
| "</div>"); | |||
| showModal('ajax-modal', '310px'); | |||
| $('#ajax-modal').css('height','120px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| $('#ajax-modal').parent().removeClass("alert_praise"); | |||
| $('#ajax-modal').parent().css("top","").css("left",""); | |||
| $('#ajax-modal').parent().addClass("popbox_polls"); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="polls_content02" id="exercise" style="width: 730px;"> | |||
| <%= render :partial => 'exercises_list'%> | |||
| </div><!--问卷内容end--> | |||
| @@ -16,7 +16,7 @@ | |||
| <div class="postDetailCreater">最后回复:<a href="<%= user_path(author) %>" class="linkBlue2" target="_blank"><%= author.name%></a></div> | |||
| <div class="postDetailDate"><%= format_date(topic.last_reply.created_at)%></div> | |||
| <% end%> | |||
| <span class=" fr" style="color: #888888; font-size: 12px;">更新时间:<%= format_date(topic.updated_at)%></span> | |||
| </div> | |||
| <div class="postDetailReply"> | |||
| <a href="<%= forum_memo_path(topic.forum, topic)%>" class="postReplyIcon mr5" target="_blank"></a> | |||
| @@ -3,7 +3,7 @@ | |||
| <div class="postRightContainer"> | |||
| <div id="create_memo_div" style="display: none"> | |||
| <div id="error" class="red fl mb10" style="display: none">error</div> | |||
| <%= labelled_form_for(@memo, :url => forum_memos_path(@forum),:remote=>true) do |f| %> | |||
| <%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %> | |||
| <div> | |||
| <textarea type="text" name="memo[subject]" id="memo_subject" maxlength="50" onblur="check_memo_name();" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子标题" ></textarea> | |||
| <script> | |||
| @@ -112,21 +112,7 @@ | |||
| } | |||
| if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() ){ | |||
| memo_content.sync(); | |||
| $.ajax({ | |||
| url:'/forums/'+'<%= @forum.id.to_s%>'+'/memos', | |||
| type:'post', | |||
| data:{ | |||
| 'memo[content]':$("#memo_content").val(), | |||
| 'memo[subject]':$("#memo_subject").val() | |||
| }, | |||
| success:function(data){ | |||
| }, | |||
| error:function(){ | |||
| alert('请检查当前网络连接') | |||
| } | |||
| }); | |||
| //$("#new_memo").submit(); | |||
| $("#new_memo").submit(); | |||
| }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){ | |||
| $("#error").html("主题和内容不能为空").show(); | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity =>@course_activity,:remote=>true}) %>'); | |||
| $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:remote=>true}) %>'); | |||
| showModal('ajax-modal', '350px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| @@ -7,5 +7,5 @@ | |||
| remote: data-remote | |||
| -%> | |||
| <%= link_to_unless false, t('views.pagination.last').html_safe, url, :remote => remote %> | |||
| <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %> | |||
| @@ -7,5 +7,5 @@ | |||
| remote: data-remote | |||
| -%> | |||
| <li> | |||
| <%= link_to_unless false, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote, :class => "next c_blue" %> | |||
| <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote, :class => "next c_blue" %> | |||
| </li> | |||
| @@ -8,7 +8,8 @@ | |||
| -%> | |||
| <%= paginator.render do -%> | |||
| <ul id="paginator" class="wlist"> | |||
| <%= prev_page_tag %> | |||
| <%#= first_page_tag unless current_page.first? %> | |||
| <%= prev_page_tag unless current_page.first? %> | |||
| <% each_page do |page| -%> | |||
| <% if page.left_outer? || page.right_outer? || page.inside_window? -%> | |||
| <%= page_tag page %> | |||
| @@ -16,7 +17,7 @@ | |||
| <%= gap_tag %> | |||
| <% end -%> | |||
| <% end -%> | |||
| <%= next_page_tag %> | |||
| <%= next_page_tag unless current_page.last? %> | |||
| <!--<%#= last_page_tag unless current_page.last? %>--> | |||
| </ul> | |||
| <% end -%> | |||
| @@ -7,6 +7,6 @@ | |||
| remote: data-remote | |||
| -%> | |||
| <li > | |||
| <%= link_to_unless false, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote ,:class=>"previous c_blue"%> | |||
| <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote ,:class=>"previous c_blue"%> | |||
| </li> | |||
| @@ -18,24 +18,24 @@ | |||
| </ul> | |||
| </div> | |||
| <script> | |||
| <%# type = type%> | |||
| // $(function (){ | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'courses' ){ | |||
| // $('input:radio[value="courses"]').attr('checked','checked'); | |||
| // } | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'projects' ){ | |||
| // $('input:radio[value="projects"]').attr('checked','checked'); | |||
| // } | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'users' ){ | |||
| // $('input:radio[value="users"]').attr('checked','checked'); | |||
| // } | |||
| // }); | |||
| <% type = type%> | |||
| $(function (){ | |||
| if('<%= type %>' != null && '<%= type %>' == 'courses' ){ | |||
| $('input:radio[value="courses"]').attr('checked','checked'); | |||
| } | |||
| if('<%= type %>' != null && '<%= type %>' == 'projects' ){ | |||
| $('input:radio[value="projects"]').attr('checked','checked'); | |||
| } | |||
| if('<%= type %>' != null && '<%= type %>' == 'users' ){ | |||
| $('input:radio[value="users"]').attr('checked','checked'); | |||
| } | |||
| }); | |||
| $(function(){ | |||
| $("#navHomepageSearchInput").keypress(function(e){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (e.keyCode == '13' && name != "" && name.length != 0) { | |||
| //$('#type').val($('input[type=radio]:checked').val()); | |||
| $('#type').val($('input[type=radio]:checked').val()); | |||
| $(this).parent().submit(); | |||
| } | |||
| }) | |||
| @@ -44,7 +44,7 @@ | |||
| function search_in_header(obj){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (name != "" && name.length != 0) { | |||
| //$('#type').val($('input[type=radio]:checked').val()); | |||
| $('#type').val($('input[type=radio]:checked').val()); | |||
| obj.parent().submit(); | |||
| } | |||
| } | |||
| @@ -54,28 +54,28 @@ | |||
| <% name = name%> | |||
| <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> | |||
| <input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户以及资源"/> | |||
| <input type="hidden" name="search_type" id="type" value="all"/> | |||
| <input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词进行搜索"/> | |||
| <input type="hidden" name="search_type" id="type" value=""/> | |||
| <input type="text" style="display: none;"/> | |||
| <a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a> | |||
| <% end %> | |||
| <!--<div class="navSearchTypeBox" id="navHomepageSearchType">--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="courses" name="search_type" checked/>--> | |||
| <!--课程--> | |||
| <!--</div>--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="projects" name="search_type" />--> | |||
| <!--项目--> | |||
| <!--</div>--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="users" name="search_type" />--> | |||
| <!--用户--> | |||
| <!--</div>--> | |||
| <!--<div id="navSearchAlert" class="fr mr10">--> | |||
| <!--<span class="c_red">请选择搜索类型</span>--> | |||
| <!--</div>--> | |||
| <!--</div>--> | |||
| <div class="navSearchTypeBox" id="navHomepageSearchType"> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="courses" name="search_type" checked/> | |||
| 课程 | |||
| </div> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="projects" name="search_type" /> | |||
| 项目 | |||
| </div> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="users" name="search_type" /> | |||
| 用户 | |||
| </div> | |||
| <div id="navSearchAlert" class="fr mr10"> | |||
| <span class="c_red">请选择搜索类型</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="navHomepageProfile" id="navHomepageProfile"> | |||
| @@ -1,95 +1,95 @@ | |||
| <div class="navHomepage"> | |||
| <div class="navHomepageLogo fl"> | |||
| <%=link_to image_tag("../images/nav_logo.png",width:"51px", height: "45px",class: "mt3"), signin_path%> | |||
| </div> | |||
| <div class="fl"> | |||
| <ul> | |||
| <li class="navHomepageMenu fl mr40"> | |||
| <a href="http://forge.trustie.net/forums/1/memos/1168" class="c_white f16 p10">帮助中心</a> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| <script> | |||
| function search(doc){ | |||
| //alert(1) | |||
| // val = $('input:radio[name="search_type"]:checked').val(); | |||
| // alert(2) | |||
| // $("#search_type").val(val); | |||
| // alert(3) | |||
| $(doc).parent().submit(); | |||
| } | |||
| <!--<%# type = type%>--> | |||
| // $(function (){ | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'courses' ){ | |||
| // $('input:radio[value="courses"]').attr('checked','checked'); | |||
| // } | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'projects' ){ | |||
| // $('input:radio[value="projects"]').attr('checked','checked'); | |||
| // } | |||
| // if('<%#= type %>' != null && '<%#= type %>' == 'users' ){ | |||
| // $('input:radio[value="users"]').attr('checked','checked'); | |||
| // } | |||
| // }); | |||
| function search_in_header(obj){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (name != "" && name.length != 0) { | |||
| //$('#type').val($('input[type=radio]:checked').val()); | |||
| obj.parent().submit(); | |||
| } | |||
| } | |||
| function search_in_header_I(e,obj){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (e.keyCode == '13' && name != "" && name.length != 0) { | |||
| //$('#type').val($('input[type=radio]:checked').val()); | |||
| obj.parent().submit(); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="fl" id="navHomepageSearch"> | |||
| <!--<form class="navHomepageSearchBox">--> | |||
| <% name = name%> | |||
| <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> | |||
| <input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户以及资源" onkeypress="search_in_header_I(event,$(this));"/> | |||
| <input type="hidden" name="search_type" id="type" value="all"/> | |||
| <input type="text" style="display: none;"/> | |||
| <a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a> | |||
| <% end %> | |||
| <!--<div class="navSearchTypeBox" id="navHomepageSearchType">--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="courses" name="search_type" checked/>--> | |||
| <!--课程--> | |||
| <!--</div>--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="projects" name="search_type" />--> | |||
| <!--项目--> | |||
| <!--</div>--> | |||
| <!--<div class="fl mr15 mt8">--> | |||
| <!--<input type="radio" value="users" name="search_type" />--> | |||
| <!--用户--> | |||
| <!--</div>--> | |||
| <!--<div id="navSearchAlert" class="fr mr10">--> | |||
| <!--<span class="c_red">请选择搜索类型</span>--> | |||
| <!--</div>--> | |||
| <!--</div>--> | |||
| </div> | |||
| <div id="loginInButton" class="fr ml20"> | |||
| <a href="<%= signin_path(:login=>true) %>" class="c_white db">登录</a> | |||
| </div> | |||
| <div id="loginSignButton" class="fr"> | |||
| <a href="<%= signin_path(:login=>false) %>" class="c_white db">注册</a> | |||
| </div> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| //搜索相关 | |||
| $("#navHomepageSearch").mouseover(function(){ | |||
| $("#navHomepageSearchType").show(); | |||
| }).mouseout(function(){ | |||
| $("#navHomepageSearchType").hide(); | |||
| }); | |||
| </script> | |||
| <div class="navHomepage"> | |||
| <div class="navHomepageLogo fl"> | |||
| <%=link_to image_tag("../images/nav_logo.png",width:"51px", height: "45px",class: "mt3"), signin_path%> | |||
| </div> | |||
| <div class="fl"> | |||
| <ul> | |||
| <li class="navHomepageMenu fl mr40"> | |||
| <a href="http://forge.trustie.net/forums/1/memos/1168" class="c_white f16 p10">帮助中心</a> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| <script> | |||
| function search(doc){ | |||
| //alert(1) | |||
| // val = $('input:radio[name="search_type"]:checked').val(); | |||
| // alert(2) | |||
| // $("#search_type").val(val); | |||
| // alert(3) | |||
| $(doc).parent().submit(); | |||
| } | |||
| <% type = type%> | |||
| $(function (){ | |||
| if('<%= type %>' != null && '<%= type %>' == 'courses' ){ | |||
| $('input:radio[value="courses"]').attr('checked','checked'); | |||
| } | |||
| if('<%= type %>' != null && '<%= type %>' == 'projects' ){ | |||
| $('input:radio[value="projects"]').attr('checked','checked'); | |||
| } | |||
| if('<%= type %>' != null && '<%= type %>' == 'users' ){ | |||
| $('input:radio[value="users"]').attr('checked','checked'); | |||
| } | |||
| }); | |||
| function search_in_header(obj){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (name != "" && name.length != 0) { | |||
| $('#type').val($('input[type=radio]:checked').val()); | |||
| obj.parent().submit(); | |||
| } | |||
| } | |||
| function search_in_header_I(e,obj){ | |||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||
| if (e.keyCode == '13' && name != "" && name.length != 0) { | |||
| $('#type').val($('input[type=radio]:checked').val()); | |||
| obj.parent().submit(); | |||
| } | |||
| } | |||
| </script> | |||
| <div class="fl" id="navHomepageSearch"> | |||
| <!--<form class="navHomepageSearchBox">--> | |||
| <% name = name%> | |||
| <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> | |||
| <input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词进行搜索" onkeypress="search_in_header_I(event,$(this));"/> | |||
| <input type="hidden" name="search_type" id="type" value=""/> | |||
| <input type="text" style="display: none;"/> | |||
| <a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a> | |||
| <% end %> | |||
| <div class="navSearchTypeBox" id="navHomepageSearchType"> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="courses" name="search_type" checked/> | |||
| 课程 | |||
| </div> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="projects" name="search_type" /> | |||
| 项目 | |||
| </div> | |||
| <div class="fl mr15 mt8"> | |||
| <input type="radio" value="users" name="search_type" /> | |||
| 用户 | |||
| </div> | |||
| <div id="navSearchAlert" class="fr mr10"> | |||
| <span class="c_red">请选择搜索类型</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="loginInButton" class="fr ml20"> | |||
| <a href="<%= signin_path(:login=>true) %>" class="c_white db">登录</a> | |||
| </div> | |||
| <div id="loginSignButton" class="fr"> | |||
| <a href="<%= signin_path(:login=>false) %>" class="c_white db">注册</a> | |||
| </div> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| //搜索相关 | |||
| $("#navHomepageSearch").mouseover(function(){ | |||
| $("#navHomepageSearchType").show(); | |||
| }).mouseout(function(){ | |||
| $("#navHomepageSearchType").hide(); | |||
| }); | |||
| </script> | |||
| @@ -208,11 +208,11 @@ | |||
| <div class="cl"></div> | |||
| <% unless contributor_course_scor(@course.id).count == 0 %> | |||
| <ul class="rankList"> | |||
| <h4>课程活跃度</h4> | |||
| <h4>课程贡献榜</h4> | |||
| <% contributor_course_scor(@course.id).each do |contributor_score| %> | |||
| <% unless contributor_score.total_score ==0 %> | |||
| <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a> | |||
| <p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p> | |||
| <p><a href="javascript:void:(0);"><%=link_to contributor_score.user, user_path(contributor_score.user), :title => contributor_score.user %></a></p> | |||
| <p><span class="c_green" style="cursor:pointer"> | |||
| <a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p> | |||
| <div style="display: none" class="numIntro"> | |||
| @@ -240,13 +240,13 @@ | |||
| <% end %> | |||
| <% hero_homework_scores = hero_homework_score(@course, "desc") %> | |||
| <% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %> | |||
| <% unless hero_homework_scores.map(&:score).detect{|s| s != nil}.nil? %> | |||
| <ul class="rankList"> | |||
| <h4>课程英雄榜</h4> | |||
| <% hero_homework_scores.each do |student_score| %> | |||
| <% if student_score.score.to_i != 0 %> | |||
| <% unless student_score.score.nil? %> | |||
| <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a> | |||
| <p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p> | |||
| <p><a href="javascript:void:(0);"><%=link_to student_score.user, user_path(student_score.user), :title => student_score.user %></a></p> | |||
| <p><span class="c_red" style="cursor:pointer" title="作业总分:<%= student_score.score %>"><%= student_score.score.to_i %></span></p> | |||
| </li> | |||
| <% end %> | |||
| @@ -9,7 +9,7 @@ | |||
| <%= favicon %> | |||
| <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','application','prettify', 'nyan','leftside', :media => 'all' %> | |||
| <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> | |||
| <%= javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min') %> | |||
| <%= javascript_heads %> | |||
| <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'prettify' %> | |||
| <%= heads_for_theme %> | |||
| @@ -241,8 +241,7 @@ | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div> | |||
| <div id="ajax-modal" style="display:none;"></div> | |||
| <div class="cl"></div> | |||
| <%= render :partial => 'layouts/footer' %> | |||
| <div class="cl"></div> | |||
| @@ -1,158 +1,174 @@ | |||
| <% @nav_dispaly_project_label = 1 | |||
| @nav_dispaly_forum_label = 1 %> | |||
| <%#@nav_dispaly_project_label = 1 %> | |||
| <!DOCTYPE html> | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="utf-8" /> | |||
| <title><%= h html_title %></title> | |||
| <meta name="description" content="<%= Redmine::Info.app_name %>" /> | |||
| <meta name="keywords" content="issue,bug,tracker" /> | |||
| <%= csrf_meta_tag %> | |||
| <%= favicon %> | |||
| <%= javascript_heads %> | |||
| <%= heads_for_theme %> | |||
| <%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> | |||
| <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> | |||
| <%= call_hook :view_layouts_base_html_head %> | |||
| <!-- page specific tags --> | |||
| <%= yield :header_tags -%> | |||
| </head> | |||
| <!--add by huang--> | |||
| <body onload="prettyPrint();"> | |||
| <div class="orgContainer"> | |||
| <div class="orgNav"> | |||
| <div class="navOrgLogo fl"><a href="javascript:void(0);"><img src="/images/home_logo.png" width="21" height="19" alt="确实Trustie" class="mt3" /></a></div> | |||
| <ul> | |||
| <li class="navOrgMenu fl"> <%= link_to '首页', organization_path(@organization, :show_homepage => 1),:class=>"linkGrey8 f14" %></li> | |||
| <% if User.current.logged? %> | |||
| <li class="navOrgMenu fr"><%=link_to User.current, user_path(User.current), :class => "linkGrey8 f14" %></li> | |||
| <% else %> | |||
| <li class="navOrgMenu fr"><a href="<%= signin_path(:login=>true) %>" class="linkGrey8 f14">登录</a></li> | |||
| <li class="navOrgMenu fr"><a href="<%= signin_path(:login=>false) %>" class="linkGrey8 f14 mr15">注册</a></li> | |||
| <% end %> | |||
| </ul> | |||
| <!--<div class="navHomepageProfile"> | |||
| <ul> | |||
| <li class="homepageProfileMenuIcon"><a href="javascript:void(0);"> | |||
| <div class="mt5 mb8"><img src="images/homepageProfileImage.png" width="40" height="40" /></div> | |||
| </a> | |||
| <ul class="topnav_login_list" style="display:none;"> | |||
| <li><a href="javascript:void(0);" class="menuGrey">修改资料</a> </li> | |||
| <li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li> | |||
| <li><a href="javascript:void(0);" class="menuGrey">退出</a></li> | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| </div>--> | |||
| </div> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="homepageContentContainer"> | |||
| <div class="homepageContent"> | |||
| <div class="homepageLeft"> | |||
| <div class="homepagePortraitContainer"> | |||
| <!--<div class="pr_info_logo fl mr10 mb5">--> | |||
| <!--<%#= image_tag(url_to_avatar(@organization), :width=>"60", :height=>"60", :alt=>"组织logo") %>--> | |||
| <!--</div>--> | |||
| <div class="pr_info_logo fl fl mr10 mb5" id="homepage_portrait_image"> | |||
| <%= image_tag(url_to_avatar(@organization),width:"60", height: "60", :id=>'nh_user_tx') %> | |||
| <% if User.current.logged?%> | |||
| <% if User.current.id == @organization.creator_id%> | |||
| <div id="edit_org_file_btn" class="none"> | |||
| <div class="homepageEditProfile"> | |||
| <a href="<%= clear_org_avatar_temp_organization_path(@organization) %>" data-remote="true" class="homepageEditProfileIcon"></a> | |||
| </div> | |||
| </div> | |||
| <% end %> | |||
| <% end%> | |||
| </div> | |||
| <!--<div class="orgName fl mb5 f14">组织id:<%#= @organization.id %></div>--> | |||
| <div class="orgName fl mb5 f14"> | |||
| <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> | |||
| <% if @organization.is_public? %> | |||
| <span class="img_private"><%= l(:label_public)%></span> | |||
| <% else %> | |||
| <span class="img_private"><%= l(:label_private)%></span> | |||
| <% end %> | |||
| </div> | |||
| <% if User.current.admin_of_org?(@organization) %> | |||
| <a href="<%= setting_organization_path(@organization) %>" class="pr_join_a c_white"><span class="pr_setting"></span>配置</a> | |||
| <% end %> | |||
| <!--<div style="clear:both;">--> | |||
| <!--<%#= link_to l(:label_org_name)+"#{@organization.name}", organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %>--> | |||
| <!--<%# if @organization.is_public? %>--> | |||
| <!--<span class="img_private"><%#= l(:label_public)%></span>--> | |||
| <!--<%# else %>--> | |||
| <!--<span class="img_private"><%#= l(:label_private)%></span>--> | |||
| <!--<%# end %>--> | |||
| <!--</div>--> | |||
| <div class="cl"></div> | |||
| <div class="f12 fontGrey3"> | |||
| <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( | |||
| <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> | |||
| ) | | |||
| <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) | |||
| </div> | |||
| </div> | |||
| <div class="homepageLeftMenuContainer" id="sub_field_left_lists"> | |||
| <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> | |||
| </div> | |||
| </div> | |||
| <div class="homepageRight" style="margin-top:<%= params[:show_homepage].nil? ? '10px':'0px' %>;"> | |||
| <%= render_flash_messages %> | |||
| <%= yield %> | |||
| <%= call_hook :view_layouts_base_content %> | |||
| <div style="clear:both;"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <!--页面底部--> | |||
| <div class="cl"></div> | |||
| <div id="Footer"> | |||
| <div class="footerAboutContainer"> | |||
| <ul class="footerAbout"> | |||
| <li class="fl"><a href="<%= about_us_path %>" class=" f_grey mw20" target="_blank">关于我们</a>|</li> | |||
| <li class="fl"><a href="<%= agreement_path %>" class=" f_grey mw20" target="_blank">服务协议</a>|</li> | |||
| <li class="fl"><a href="http://forge.trustie.net/forums/1/memos/1168" class="f_grey mw20" target="_blank">帮助中心</a>|</li> | |||
| <li class="fl"><a href="<%= forums_path(:reorder_complex=>'desc')%>" class="f_grey mw20" target="_blank">贴吧交流</a></li> | |||
| </ul> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <ul class="copyright mt10"> | |||
| <li class="fl mr30">Copyright © 2007-2015, All Rights Riserved</li> | |||
| <li>ICP备09019772</li> | |||
| </ul> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div id="ajax-modal" style="display:none;"></div> | |||
| <div id="ajax-indicator" style="display:none;"> | |||
| <span><%= l(:label_loading) %></span> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| $("#courseMenu").mouseenter(function(){ | |||
| $("#topnav_course_menu").show(); | |||
| }); | |||
| $("#courseMenu").mouseleave(function(){ | |||
| $("#topnav_course_menu").hide(); | |||
| }); | |||
| $("#projectMenu").mouseenter(function(){ | |||
| $("#topnav_project_menu").show(); | |||
| }); | |||
| $("#projectMenu").mouseleave(function(){ | |||
| $("#topnav_project_menu").hide(); | |||
| }); | |||
| </script> | |||
| </body> | |||
| </html> | |||
| <% @nav_dispaly_project_label = 1 | |||
| @nav_dispaly_forum_label = 1 %> | |||
| <%#@nav_dispaly_project_label = 1 %> | |||
| <!DOCTYPE html> | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="utf-8" /> | |||
| <title><%= h html_title %></title> | |||
| <meta name="description" content="<%= Redmine::Info.app_name %>" /> | |||
| <meta name="keywords" content="issue,bug,tracker" /> | |||
| <%= csrf_meta_tag %> | |||
| <%= favicon %> | |||
| <%= javascript_heads %> | |||
| <%= heads_for_theme %> | |||
| <%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> | |||
| <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> | |||
| <%= call_hook :view_layouts_base_html_head %> | |||
| <!-- page specific tags --> | |||
| <%= yield :header_tags -%> | |||
| </head> | |||
| <!--add by huang--> | |||
| <body onload="prettyPrint();"> | |||
| <div class="navContainer"> | |||
| <% if User.current.logged? %> | |||
| <%= render :partial => 'layouts/logined_header' %> | |||
| <% else %> | |||
| <%= render :partial => 'layouts/unlogin_header' %> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="homepageContentContainer"> | |||
| <div class="homepageContent"> | |||
| <div class="homepageLeft"> | |||
| <div class="homepagePortraitContainer"> | |||
| <!--<div class="pr_info_logo fl mr10 mb5">--> | |||
| <!--<%#= image_tag(url_to_avatar(@organization), :width=>"60", :height=>"60", :alt=>"组织logo") %>--> | |||
| <!--</div>--> | |||
| <div class="pr_info_logo fl fl mr10 mb5" id="homepage_portrait_image"> | |||
| <%= image_tag(url_to_avatar(@organization),width:"60", height: "60", :id=>'nh_user_tx') %> | |||
| <% if User.current.logged?%> | |||
| <% if User.current.id == @organization.creator_id%> | |||
| <div id="edit_org_file_btn" class="none"> | |||
| <div class="homepageEditProfile"> | |||
| <a href="<%= clear_org_avatar_temp_organization_path(@organization) %>" data-remote="true" class="homepageEditProfileIcon"></a> | |||
| </div> | |||
| </div> | |||
| <% end %> | |||
| <% end%> | |||
| </div> | |||
| <!--<div class="orgName fl mb5 f14">组织id:<%#= @organization.id %></div>--> | |||
| <div class="orgName fl mb5 f14"> | |||
| <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> | |||
| <% if @organization.is_public? %> | |||
| <span class="img_private"><%= l(:label_public)%></span> | |||
| <% else %> | |||
| <span class="img_private"><%= l(:label_private)%></span> | |||
| <% end %> | |||
| </div> | |||
| <% if User.current.admin_of_org?(@organization) %> | |||
| <a href="<%= setting_organization_path(@organization) %>" class="pr_join_a c_white"><span class="pr_setting"></span>配置</a> | |||
| <% end %> | |||
| <!--<div style="clear:both;">--> | |||
| <!--<%#= link_to l(:label_org_name)+"#{@organization.name}", organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %>--> | |||
| <!--<%# if @organization.is_public? %>--> | |||
| <!--<span class="img_private"><%#= l(:label_public)%></span>--> | |||
| <!--<%# else %>--> | |||
| <!--<span class="img_private"><%#= l(:label_private)%></span>--> | |||
| <!--<%# end %>--> | |||
| <!--</div>--> | |||
| <div class="cl"></div> | |||
| <div class="f12 fontGrey3"> | |||
| <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( | |||
| <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> | |||
| ) | | |||
| <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) | |||
| </div> | |||
| </div> | |||
| <div class="homepageLeftMenuContainer"> | |||
| <div class="homepageLeftMenuBlock"> | |||
| <%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %> | |||
| </div> | |||
| <div class="homepageLeftMenuBlock"> | |||
| <a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuProjects').slideToggle();">项目</a> | |||
| <%=link_to "", join_project_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> | |||
| <!--<div class="courseMenu" id="projectMenu">--> | |||
| <!--<ul>--> | |||
| <!--<li class="courseMenuIcon" id="projectMenuIcon">--> | |||
| <!--<ul class="topnav_course_menu" id="topnav_project_menu" style="line-height:1;">--> | |||
| <!--<!–<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>–>--> | |||
| <!--<li>--> | |||
| <!--<%#= link_to "关联项目",join_project_menu_organization_path(@organization),:remote => true,:class => "menuGrey",:method => "post"%>--> | |||
| <!--</li>--> | |||
| <!--</ul>--> | |||
| <!--</li>--> | |||
| <!--</ul>--> | |||
| <!--</div>--> | |||
| <!--<a href="javascript:void(0);" class="homepageMenuSetting fr" title="关联您的已有项目"></a>--> | |||
| </div> | |||
| <div class="homepageLeftMenuCourses borderBottomNone" id="homepageLeftMenuProjects"> | |||
| <ul > | |||
| <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> | |||
| <!--<%#= @organization.org_projects.each do |p|%>--> | |||
| <!--<li class="homepageLeftMenuCoursesLine"><a href="javascript:void(0);" class="coursesLineGrey"><%#= p.name%></a></li>--> | |||
| <!--<%# end %>--> | |||
| <!--<li class="homepageLeftMenuMore"><a href="javascript:void(0);" class="homepageLeftMenuMoreIcon"></a></li>--> | |||
| </ul> | |||
| </div> | |||
| <div class="homepageLeftMenuBlock"> | |||
| <a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a> | |||
| <%=link_to "", join_course_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> | |||
| <%#= link_to "关联课程",join_course_menu_organization_path(@organization),:remote => true,:class => "menuGrey",:method => "post"%> | |||
| <!--<div class="courseMenu" id="courseMenu">--> | |||
| <!--<ul>--> | |||
| <!--<li class="courseMenuIcon" id="courseMenuIcon">--> | |||
| <!--<ul class="topnav_course_menu" id="topnav_course_menu" style="line-height:1;">--> | |||
| <!--<!–<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>–>--> | |||
| <!--<li>--> | |||
| <!--<%#= link_to "关联课程",join_course_menu_organization_path(@organization),:remote => true,:class => "menuGrey",:method => "post"%>--> | |||
| <!--</li>--> | |||
| <!--</ul>--> | |||
| <!--</li>--> | |||
| <!--</ul>--> | |||
| <!--</div>--> | |||
| <!--<a href="javascript:void(0);" class="homepageMenuSetting fr" title="关联您的已有项目"></a>--> | |||
| </div> | |||
| <div class="homepageLeftMenuCourses borderBottomNone" id="homepageLeftMenuCourses"> | |||
| <ul > | |||
| <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="homepageRight"> | |||
| <%= render_flash_messages %> | |||
| <%= yield %> | |||
| <%= call_hook :view_layouts_base_content %> | |||
| <div style="clear:both;"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <!--页面底部--> | |||
| <div class="cl"></div> | |||
| <%= render :partial => 'layouts/footer' %> | |||
| <div class="cl"></div> | |||
| <div id="ajax-modal" style="display:none;"></div> | |||
| <div id="ajax-indicator" style="display:none;"> | |||
| <span><%= l(:label_loading) %></span> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| $("#courseMenu").mouseenter(function(){ | |||
| $("#topnav_course_menu").show(); | |||
| }); | |||
| $("#courseMenu").mouseleave(function(){ | |||
| $("#topnav_course_menu").hide(); | |||
| }); | |||
| $("#projectMenu").mouseenter(function(){ | |||
| $("#topnav_project_menu").show(); | |||
| }); | |||
| $("#projectMenu").mouseleave(function(){ | |||
| $("#topnav_project_menu").hide(); | |||
| }); | |||
| </script> | |||
| </body> | |||
| </html> | |||
| @@ -12,7 +12,7 @@ | |||
| <%= favicon %> | |||
| <%= javascript_heads %> | |||
| <%= heads_for_theme %> | |||
| <%= stylesheet_link_tag 'public', 'pleft', 'project','courses','prettify','jquery/jquery-ui-1.9.2','header','repository' %> | |||
| <%= stylesheet_link_tag 'public', 'pleft', 'project','prettify','jquery/jquery-ui-1.9.2','header','repository' %> | |||
| <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','attachments' %> | |||
| <%= call_hook :view_layouts_base_html_head %> | |||
| <!-- page specific tags --> | |||
| @@ -2,7 +2,7 @@ | |||
| <ul style="list-style-type:none; margin:0; padding:0;"> | |||
| <li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span> | |||
| <span style="float: left; width: 526px"> | |||
| <p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @anonymous_comment_close_name, @anonymous_comment_close_url%> <span style="color: red; padding-left: 10px;">已经开启匿评了,请您关注!</span></p> | |||
| <p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @anonymous_comment_close_name, @anonymous_comment_close_url%> <span style="color: red; padding-left: 10px;">已经开启匿评了!</span></p> | |||
| </span> | |||
| </li> | |||
| </ul> | |||
| @@ -13,21 +13,7 @@ | |||
| return false; | |||
| } | |||
| memo_content.sync(); | |||
| $.ajax({ | |||
| url:' /forums/'+'<%= @memo.forum_id.to_s %>'+'/memos/<%= @memo.id.to_s%>', | |||
| type:'put', | |||
| data:{ | |||
| 'memo[subject]':$("#memo_subject").val(), | |||
| 'memo[content]':$("#memo_content").val() | |||
| }, | |||
| success:function(data){ | |||
| }, | |||
| error:function(){ | |||
| alert('请检查当前网络连接') | |||
| } | |||
| }); | |||
| //$("#edit_memo").submit(); | |||
| $("#edit_memo").submit(); | |||
| }else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){ | |||
| $("#error").html("主题不能为空").show(); | |||
| }else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){ | |||
| @@ -79,8 +79,6 @@ | |||
| <%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <span class=" fr" style="color: #888888; font-size: 12px;">更新时间:<%= format_date(@memo.updated_at)%></span> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| @@ -1,58 +1,58 @@ | |||
| <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> | |||
| <script> | |||
| function check_org_title() | |||
| { | |||
| if($("#document_title").val().trim() == "") | |||
| { | |||
| $("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show(); | |||
| return false; | |||
| } | |||
| else | |||
| { | |||
| $("#doc_title_hint").hide(); | |||
| return true; | |||
| } | |||
| } | |||
| function create_org_document() | |||
| { | |||
| if(check_org_title() == true) | |||
| { | |||
| org_document_description_editor.sync(); | |||
| $('#new_org_document_form').submit(); | |||
| } | |||
| } | |||
| function cancel_create_org_document(){ | |||
| $("#document_title").val(""); | |||
| org_document_description_editor.html(""); | |||
| org_document_description_editor.sync(); | |||
| $('#org_document_editor').hide(); | |||
| $('#doc_title_hint').hide(); | |||
| } | |||
| </script> | |||
| <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> | |||
| <div class="resources"> | |||
| <div> | |||
| <input class="postDetailInput fl" maxlength="250" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题" /> | |||
| </div> | |||
| <div id="doc_title_hint"></div> | |||
| <div class="cl"></div> | |||
| <div id="org_document_editor" class="mt10" style="display: none"> | |||
| <div> | |||
| <%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <p id="homework_course_id_span" class="c_red mt5"></p> | |||
| <div class="cl"></div> | |||
| <div class="mt5"> | |||
| <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="create_org_document();">确定</a> | |||
| <span class="fr mr10 mt3">或</span> | |||
| <a href="javascript:void(0);" onclick="cancel_create_org_document();" class="fr mr10 mt3">取消</a> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> | |||
| <script> | |||
| function check_org_title() | |||
| { | |||
| if($("#document_title").val().trim() == "") | |||
| { | |||
| $("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show(); | |||
| return false; | |||
| } | |||
| else | |||
| { | |||
| $("#doc_title_hint").hide(); | |||
| return true; | |||
| } | |||
| } | |||
| function create_org_document() | |||
| { | |||
| if(check_org_title() == true) | |||
| { | |||
| org_document_description_editor.sync(); | |||
| $('#new_org_document_form').submit(); | |||
| } | |||
| } | |||
| function cancel_create_org_document(){ | |||
| $("#document_title").val(""); | |||
| org_document_description_editor.html(""); | |||
| org_document_description_editor.sync(); | |||
| $('#org_document_editor').hide(); | |||
| $('#doc_title_hint').hide(); | |||
| } | |||
| </script> | |||
| <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> | |||
| <div class="resources"> | |||
| <div> | |||
| <input class="postDetailInput fl" maxlength="250" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题" /> | |||
| </div> | |||
| <div id="doc_title_hint"></div> | |||
| <div class="cl"></div> | |||
| <div id="org_document_editor" class="mt10" style="display: none"> | |||
| <div> | |||
| <%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <p id="homework_course_id_span" class="c_red mt5"></p> | |||
| <div class="cl"></div> | |||
| <div class="mt5"> | |||
| <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="create_org_document();">确定</a> | |||
| <span class="fr mr10 mt3">或</span> | |||
| <a href="javascript:void(0);" onclick="cancel_create_org_document();" class="fr mr10 mt3">取消</a> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <% end %> | |||
| @@ -1,3 +1,3 @@ | |||
| $("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document,:flag => params[:flag], :act => @act}) %>"); | |||
| $("#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%"); | |||
| @@ -19,6 +19,6 @@ | |||
| init_activity_KindEditor_data(<%= OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first.id %>, null, "87%"); | |||
| }); | |||
| </script> | |||
| <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %> | |||
| <%= 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 %> | |||
| @@ -25,7 +25,7 @@ | |||
| <div class="homepagePostDate"> | |||
| 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %></div> | |||
| <% unless @document.content.blank? %> | |||
| <div class="homepagePostIntro" style="width:640px;"> | |||
| <div class="homepagePostIntro"> | |||
| <%= @document.content.html_safe %> | |||
| </div> | |||
| <% end %> | |||
| @@ -13,7 +13,6 @@ | |||
| $(".resourcePopupClose").click(function(){ | |||
| location.reload(); | |||
| $(".resourceSharePopup").css("display","none"); | |||
| }); | |||
| }); | |||
| @@ -13,7 +13,6 @@ | |||
| $(".resourcePopupClose").click(function(){ | |||
| location.reload(); | |||
| $(".resourceSharePopup").css("display","none"); | |||
| }); | |||
| }); | |||
| @@ -22,7 +22,7 @@ | |||
| </div> | |||
| <% 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, :flag => 2} %> | |||
| <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act} %> | |||
| <% end %> | |||
| <% end %> | |||
| <% if act.container_type == 'Project' %> | |||
| @@ -56,7 +56,7 @@ | |||
| <% end %> | |||
| <% if org_act_count == 10 %> | |||
| <div id="show_more_activities" class="loadMore mt10 f_grey">展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1, :show_homepage =>params[:show_homepage],:type => params[:type]),:id => "more_org_activities_link",:remote => "true",:class => "none" %></div> | |||
| <div id="show_more_activities" class="loadMore mt10 f_grey">展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1, :type => params[:type]),:id => "more_org_activities_link",:remote => "true",:class => "none" %></div> | |||
| <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> | |||
| <% end%> | |||
| @@ -1,32 +1,32 @@ | |||
| <%= stylesheet_link_tag 'courses' %> | |||
| <div class="resources mt10"> | |||
| <div class="project_r_h" style="width: 720px;"> | |||
| <h2 class="project_h2"> 组织成员</h2> | |||
| </div> | |||
| <div class="st_list" style="width: 720px;"> | |||
| <div class="st_box"> | |||
| <span class="fr fb fontGrey3">加入时间</span> | |||
| <div class="cl"></div><!--st_box_top end--> | |||
| <% members.each do |member| %> | |||
| <div class="st_boxlist"> | |||
| <a href="javascript:" class="st_img"> | |||
| <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %> | |||
| </a> | |||
| <span class="fl ml10 c_grey"><%= l(:label_username)%></span> | |||
| <%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %><br /> | |||
| <span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span> | |||
| <% if member.created_at %> | |||
| <span class="fr c_grey"><%= format_time(member.created_at) %></span> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| <ul class="wlist"> | |||
| <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| <%= stylesheet_link_tag 'courses' %> | |||
| <div class="resources mt10"> | |||
| <div class="project_r_h" style="width: 720px;"> | |||
| <h2 class="project_h2"> 组织成员</h2> | |||
| </div> | |||
| <div class="st_list" style="width: 720px;"> | |||
| <div class="st_box"> | |||
| <span class="fr fb fontGrey3">加入时间</span> | |||
| <div class="cl"></div><!--st_box_top end--> | |||
| <% members.each do |member| %> | |||
| <div class="st_boxlist"> | |||
| <a href="javascript:" class="st_img"> | |||
| <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %> | |||
| </a> | |||
| <span class="fl ml10 c_grey"><%= l(:label_username)%></span> | |||
| <%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %><br /> | |||
| <span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span> | |||
| <% if member.created_at %> | |||
| <span class="fr c_grey"><%= format_time(member.created_at) %></span> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| <ul class="wlist"> | |||
| <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> | |||
| </ul> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -8,20 +8,24 @@ | |||
| <%= 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 %> | |||
| <span style="color:#269ac9;">首页</span> | |||
| <% else %> | |||
| <span style="color:#269ac9;">组织文章</span> | |||
| <% end %> | |||
| </div> | |||
| <div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div> | |||
| <div class="homepagePostDate"> | |||
| 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %></div> | |||
| <% unless document.content.blank? %> | |||
| <div class="homepagePostIntro" style="width:640px;"> | |||
| <div class="homepagePostIntro"> | |||
| <%= document.content.html_safe %> | |||
| </div> | |||
| <% end %> | |||
| <!-- <%# if defined?(home_id) %> | |||
| <div style="float:right;">最后编辑:<%#= User.find() %></div> | |||
| <%# end %>--> | |||
| <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %> | |||
| <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> | |||
| <div class="homepagePostSetting"> | |||
| <ul> | |||
| <li class="homepagePostSettingIcon"> | |||
| @@ -32,7 +36,7 @@ | |||
| <% end %> | |||
| </li> | |||
| <li> | |||
| <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag), :class => "postOptionLink" %> | |||
| <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => 0), :class => "postOptionLink" %> | |||
| </li> | |||
| <li> | |||
| <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', | |||
| @@ -88,7 +92,7 @@ | |||
| </div> | |||
| <div class="homepagePostReplyInputContainer"> | |||
| <div nhname='new_message_<%= act.id %>' style="display:none;"> | |||
| <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :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| %> | |||
| <input type="hidden" name="org_activity_id" value="<%= act.id %>"/> | |||
| <textarea placeholder="有问题或建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= act.id %>' name="org_content"></textarea> | |||
| @@ -2,5 +2,4 @@ $("#homepageLeftMenuCourses").html(""); | |||
| $("#homepageLeftMenuCourses").append("<ul>"); | |||
| $("#homepageLeftMenuCourses").append("<%= escape_javascript(render :partial => 'layouts/org_courses', | |||
| :locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=> 1}) %>"); | |||
| $("#homepageLeftMenuCourses").append("</ul>"); | |||
| $("#homepageLeftMenuCourses").show(); | |||
| $("#homepageLeftMenuCourses").append("</ul>"); | |||
| @@ -2,5 +2,4 @@ $("#homepageLeftMenuProjects").html(""); | |||
| $("#homepageLeftMenuProjects").append("<ul>"); | |||
| $("#homepageLeftMenuProjects").append("<%= escape_javascript(render :partial => 'layouts/org_projects', | |||
| :locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=> 1}) %>"); | |||
| $("#homepageLeftMenuProjects").append("</ul>"); | |||
| $("#homepageLeftMenuProjects").show(); | |||
| $("#homepageLeftMenuProjects").append("</ul>"); | |||
| @@ -2,7 +2,7 @@ | |||
| function g(o){return document.getElementById(o);} | |||
| function HoverLi(n){ | |||
| //如果有N个标签,就将i<=N; | |||
| for(var i=1;i<=3;i++){ | |||
| for(var i=1;i<=2;i++){ | |||
| g('orgSetting_'+i).className='orgSettingOp'; | |||
| g('orgContent_'+i).className='undis';} | |||
| g('orgContent_'+n).className='dis ml15 mr15'; | |||
| @@ -34,7 +34,6 @@ | |||
| <ul class="mb10"> | |||
| <li class="orgSettingOp orgOpActive" id="orgSetting_1" onclick="HoverLi(1);">信息</li> | |||
| <li class="orgSettingOp" id="orgSetting_2" onclick="HoverLi(2);">成员</li> | |||
| <li class="orgSettingOp" id="orgSetting_3" onclick="HoverLi(3);">栏目</li> | |||
| <li class="orgBorder"></li> | |||
| <div class="cl"></div> | |||
| </ul> | |||
| @@ -46,11 +45,13 @@ | |||
| <%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %> | |||
| <!--<div class="cl"></div>--> | |||
| <!--</div>--> | |||
| <div class="orgRow mb10"><span class="c_red">* </span>组织名称:<input type="text" name="organization[name]" id="organization_name" maxlength="100" onblur="check_uniq(<%=@organization.id %>);" onfocus="$('#check_name_hint').hide()" class="orgNameInput" value="<%= @organization.name%>" /> | |||
| <div class="orgRow mb10"><span class="c_red">* </span>组织名称: | |||
| <input type="text" name="organization[name]" id="organization_name" maxlength="100" onblur="check_uniq(<%=@organization.id %>);" onfocus="$('#check_name_hint').hide()" class="orgNameInput" value="<%= @organization.name%>" /> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <div style="margin-left: 80px " id="check_name_hint"></div> | |||
| <div class="orgRow mb10"><span class="ml10">组织描述:</span><textarea type="text" name="organization[description]" class="orgDes" id="org_desc" placeholder="最多3000个汉字(或6000个英文字符)"><%= @organization.description%></textarea> | |||
| <div class="orgRow mb10"><span class="ml10">组织描述:</span> | |||
| <textarea type="text" name="organization[description]" class="orgDes" id="org_desc" placeholder="最多3000个汉字(或6000个英文字符)"><%= @organization.description%></textarea> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <div style="margin-left: 80px " id="check_desc_hint"></div> | |||
| @@ -105,26 +106,4 @@ | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <div class="undis ml15 mr15" id="orgContent_3"> | |||
| <div class="orgMemberList" id="org_subfield_list"> | |||
| <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> | |||
| </div> | |||
| <div class="fr orgMemContainer"> | |||
| <div class="orgMemberAdd"> | |||
| <p class="fontBlue fb mb5">新增栏目</p> | |||
| <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> | |||
| <input type="text" id="subfield_name" name="name" placeholder="栏目名称" class="orgAddSearch mb20" /> | |||
| <div class="cl"></div> | |||
| <a href="javascript:void(0);" class="saveBtn db fl mt10" onclick="add_org_subfield();">确定</a> | |||
| <% end %> | |||
| </div> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| </div> | |||
| <script> | |||
| function add_org_subfield(){ | |||
| if ($("#subfield_name").val().trim() != "") | |||
| $("#add_subfield_form").submit(); | |||
| } | |||
| </script> | |||
| </div> | |||
| @@ -12,7 +12,6 @@ | |||
| .homepagePostReplyInputContainer .ke-inline-block {display: none;} | |||
| .homepagePostReplyInputContainer .ke-container {float: left;} | |||
| </style> | |||
| <% if params[:show_homepage].nil? %> | |||
| <div class="homepageRightBanner"> | |||
| <div class="NewsBannerName">最新动态</div> | |||
| <ul class="resourcesSelect"> | |||
| @@ -50,16 +49,17 @@ | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| <% end %> | |||
| <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> | |||
| <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> | |||
| <script> | |||
| $(function() { | |||
| init_activity_KindEditor_data(<%= OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?",@organization.home_id).first.id %>, null, "87%"); | |||
| }); | |||
| </script> | |||
| <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> | |||
| <%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> | |||
| <%= 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', | |||
| @@ -1,33 +1,114 @@ | |||
| <%#= stylesheet_link_tag 'courses' %> | |||
| <script type="text/javascript"> | |||
| $(function () { | |||
| $("#RSide").removeAttr("id"); | |||
| $("#Container").css("width", "1000px"); | |||
| }); | |||
| </script> | |||
| <input type="hidden" value="<%= @type %>" name="type" id="user_activities_type"> | |||
| <div class="homepageRight mt0 ml10"> | |||
| <div class="homepageRightBanner"> | |||
| <div class="NewsBannerName">项目动态</div> | |||
| <ul class="resourcesSelect" class="resourcesSelect"> | |||
| <li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a> | |||
| <ul class="homepagePostType"> | |||
| <li> | |||
| <ul class="homepagePostTypeHomework fl"> | |||
| <li><%= link_to "全部动态", {:controller => "projects", :action => "show", :type => nil}, :class => "homepagePostTypeAll postTypeGrey" %></li> | |||
| <li><%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %></li> | |||
| <!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>--> | |||
| <li><%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li> | |||
| <!--<li><%#= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>--> | |||
| <li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li> | |||
| <!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>--> | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| </ul> | |||
| <!--CONTENT LIST--> | |||
| <%= javascript_include_tag "jquery.infinitescroll.js" %> | |||
| <div class="project_r_h"> | |||
| <h2 class="project_h2"><%= l(:label_activity) %></h2> | |||
| </div> | |||
| <!--CONTENT LIST--> | |||
| <% unless @events_pages.empty? %> | |||
| <% @events_pages.each do |e| -%> | |||
| <!--创建--> | |||
| <% if e.forge_act_type == "ProjectCreateInfo"%> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word"> | |||
| <%= link_to e.user, user_path(e.user), :class => "problem_name c_orange fl" %> <span class="fl"> <%= l(:label_project_create) %> :</span> | |||
| <%= link_to e.project.name,{} ,:class => "problem_tit fl fb" %></a><br /> | |||
| <p class="mt5"><br /> <%= l :label_create_time %> :<%= format_time(e.project.created_on) %></p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <% end %> | |||
| <% next if e.forge_act_type.safe_constantize.nil? | |||
| act = e.forge_act; | |||
| next if act.nil? %> | |||
| <!--缺陷动态--> | |||
| <% if e.forge_act_type == "Issue" %> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(act.author), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word list_style"> | |||
| <a class="problem_name fl "> | |||
| <%= h(e.project) if @project.nil? || @project.id != e.project_id %> | |||
| <%= link_to act.author, user_path(act.author), :class => "problem_name c_orange fl" %><span class="fl"> <%= l(:label_new_activity) %> :</span> | |||
| <%= link_to format_activity_title("#{act.source_from}##{act.project_issues_index} (#{act.status}): #{act.tracker.name} #{act.subject}"), | |||
| {:controller => 'issues', | |||
| :action => 'show', | |||
| :id => act.id}, | |||
| :class => "problem_tit fl fb " %> | |||
| </a><br /> | |||
| <p class="mt5 break_word"><%= act.description.html_safe %><br /> | |||
| <%= l :label_activity_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %> | |||
| </p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--缺陷 jou留言 --> | |||
| <% elsif e.forge_act_type == "Journal" %> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word"> | |||
| <a class="problem_name fl "> | |||
| <%= h(e.project) if @project.nil? || @project.id != e.project_id %> | |||
| <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %><span class="fl"> <%= l(:label_new_activity) %> :</span> | |||
| <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.project_issues_index}: #{act.issue.subject}"), | |||
| {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"}, :class => "problem_tit fl fb" %> | |||
| </a><br /> | |||
| <p class="mt5 break_word"><%= act.notes.html_safe %><br /> | |||
| <%= l :label_activity_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--message --> | |||
| <% elsif e.forge_act_type == "Message" %> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word list_style"> | |||
| <a class="problem_name fl "> | |||
| <%= h(e.project) if @project.nil? || @project.id != e.project_id %> | |||
| <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %></a><span class="fl"> <%= l(:label_new_activity) %> :</span> | |||
| </div> | |||
| <%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %> | |||
| </div> | |||
| <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), | |||
| project_boards_path(@project,:topic_id => act.id), | |||
| :class => "problem_tit fl fb " %> | |||
| <br /> | |||
| <p class="mt5 break_word"><%= textAreailizable act,:content %><br /> | |||
| <div class="cl"></div> | |||
| <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--new 新闻--> | |||
| <% elsif e.forge_act_type == "News" %> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word list_style"> | |||
| <a class="problem_name fl "> | |||
| <%= h(e.project) if @project.nil? || @project.id != e.project_id %> | |||
| <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %></a><span class="fl"> <%= l(:label_new_activity) %> :</span> | |||
| <a class="problem_tit fl fb"> | |||
| <% unless act.nil? %> | |||
| <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id}, :class => "problem_tit fl fb " %> | |||
| <% end %> | |||
| </a><br /> | |||
| <p class="mt5 break_word"><%= textAreailizable act,:description %><br /> | |||
| <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <!--Attachment --> | |||
| <% elsif e.forge_act_type == "Attachment" %> | |||
| <div class="problem_main"> | |||
| <a class="problem_pic fl"><%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %></a> | |||
| <div class="problem_txt fl mt5 break_word"> | |||
| <a class="problem_name fl "> | |||
| <%= h(e.project) if @project.nil? || @project.id != e.project_id %> | |||
| <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %></a><span class="fl"> <%= l(:label_new_activity) %> :</span> | |||
| <%= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %></a><br /> | |||
| <p class="mt5 break_word"><%= textAreailizable act,:description %><br /> | |||
| <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %></p> | |||
| </div> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <% end %> | |||
| <% end %> | |||
| <% end %> | |||
| <%= paginate @events_pages, :left => 3, :right => 3 %> | |||
| @@ -1,16 +1,16 @@ | |||
| <%= form_tag( | |||
| {:controller => 'repositories', :action => 'diff', :id => project, | |||
| :repository_id => @repository.identifier_param, :path => to_path_param(path)}, | |||
| :method => :get | |||
| :method => :get | |||
| ) do %> | |||
| <table class="list changesets"> | |||
| <!--<thead><tr>--> | |||
| <!--<th>#</th>--> | |||
| <!--<th></th>--> | |||
| <!--<th></th>--> | |||
| <!--<th><%= l(:label_date) %></th>--> | |||
| <!--<th><%= l(:field_author) %></th>--> | |||
| <!--<th><%= l(:field_comments) %></th>--> | |||
| <!--<th>#</th>--> | |||
| <!--<th></th>--> | |||
| <!--<th></th>--> | |||
| <!--<th><%= l(:label_date) %></th>--> | |||
| <!--<th><%= l(:field_author) %></th>--> | |||
| <!--<th><%= l(:field_comments) %></th>--> | |||
| <!--</tr></thead>--> | |||
| <tbody> | |||
| @@ -24,7 +24,6 @@ | |||
| <strong class="str-truncated"> | |||
| <a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a> | |||
| </strong> | |||
| <div class="pull-right" title="修订号"> | |||
| <%= h truncate(changeset.short_id.to_s, :length => 20) %> | |||
| </div> | |||
| @@ -32,29 +31,13 @@ | |||
| </div> | |||
| </div> | |||
| <div class="commit-row-info"> | |||
| <% if !user_commit_rep(changeset.author_email).nil? %> | |||
| <a class="commit-author-link has_tooltip"> <span class="commit-author-name"> | |||
| <%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %> | |||
| <%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a> | |||
| 提交于 | |||
| <div class="committed_ago"> | |||
| <time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> | |||
| 前 | |||
| </time> | |||
| | |||
| </div> | |||
| <% else %> | |||
| <span class="commit-author-name"><%= changeset.author_email %></span> | |||
| 提交于 | |||
| <div class="committed_ago"> | |||
| <time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> | |||
| 前 | |||
| </time> | |||
| | |||
| </div> | |||
| <% end %> | |||
| <a class="commit-author-link has_tooltip"> <span class="commit-author-name"> | |||
| <%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %> | |||
| <%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a> | |||
| 提交于 | |||
| <div class="committed_ago"> | |||
| <time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time> | |||
| </div> | |||
| </div> | |||
| </li> | |||
| </ul> | |||
| @@ -67,7 +50,7 @@ | |||
| </p> | |||
| <ul class="wlist"> | |||
| <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true %> | |||
| <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%> | |||
| </ul> | |||
| <% end %> | |||
| @@ -22,16 +22,11 @@ | |||
| <% else %> | |||
| <%= render :partial => 'navigation' %> | |||
| <div class="fl c_grey02 mt5 mr5">克隆网址:</div> | |||
| <textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" ><%=@repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea> | |||
| <textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" placeholder="http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git"><%=@repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea> | |||
| <a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a> | |||
| <div class="fl mt5 ml15"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_zip"></span>ZIP</a> </div> | |||
| <!--<div class="fr mt5"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_fork"></span>Fork</a> <span href="javascript:void(0);" class="vl_btn_2 fb">0</span> </div>--> | |||
| <% unless User.current.id == @project.user_id %> | |||
| <div class="fr mt5"><%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn"%> | |||
| <% end %> | |||
| <%#= link_to "<span id='span'>My span </span>#{@user.profile.my_data}".html_safe, "#", class: 'button white' %> | |||
| <span href="javascript:void(0);" class="vl_btn_2 fb"><%= @project.forked_count.to_i %></span> </div> | |||
| <div class="fr mt5"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_fork"></span>Fork</a> <span href="javascript:void(0);" class="vl_btn_2 fb">0</span> </div> | |||
| <!--<div class="fr mt5"><a href="javascript:void(0);" class="vl_btn fb" onclick="zip()"><span class="vl_fork"></span><%= link_to "Fork", :controller => 'repositories', :action => 'forked' %></a> <span href="javascript:void(0);" class="vl_btn_2 fb">0</span> </div>--> | |||
| <div class="cl"></div> | |||
| <div class="recordBanner mt10"> | |||
| <% if @changesets && !@changesets.empty? %> | |||
| @@ -1,70 +1,70 @@ | |||
| <!-- 匿评作品列表,显示某一个作品的信息 --> | |||
| <ul class="hworkListRow" id="student_work_<%= student_work.id%>"> | |||
| <% is_my_work = student_work.user == User.current%> | |||
| <li class="hworkList340 width525"> | |||
| <ul> | |||
| <% if is_my_work%> | |||
| <li class="hworkPortrait mt15 mr10"> | |||
| <%= image_tag(url_to_avatar(student_work.user),width:"40", height: "40") %> | |||
| </li> | |||
| <li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>"> | |||
| <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> | |||
| <div> | |||
| <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%> | |||
| </div> | |||
| </li> | |||
| <li onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;" class="student_work_<%= student_work.id%>"> | |||
| <ul class="mt10 fl"> | |||
| <li class="hworkStName mr10 mt16" title="姓名"> | |||
| <%= student_work.user.show_name%> | |||
| </li> | |||
| <li class="hworkStID mt16" title="学号"> | |||
| <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <% else%> | |||
| <li class="hworkPortrait mt15 mr10"> | |||
| <%= image_tag(url_to_avatar(""),width:"40", height: "40") %> | |||
| </li> | |||
| <li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>"> | |||
| <div> | |||
| <%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%> | |||
| </div> | |||
| </li> | |||
| <li onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;" class="student_work_<%= student_work.id%>"> | |||
| <ul class="mt10 fl"> | |||
| <li class="hworkStName mr10 mt16" title="姓名"> | |||
| 匿名 | |||
| </li> | |||
| <li class="hworkStID mt16" title="学号"> | |||
| -- | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <% end%> | |||
| </ul> | |||
| </li> | |||
| <li class="hworkList130 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;"> | |||
| <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%> | |||
| <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %> | |||
| <span class="c_red">[迟交]</span> | |||
| <% end %> | |||
| </li> | |||
| <!-- 成绩 --> | |||
| <% my_score = student_work_score(student_work,User.current) %> | |||
| <li class="hworkList50 <%= my_score.nil? ? 'c_grey' : score_color(my_score.score)%> mr10"> | |||
| <%= my_score.nil? ? "--" : format("%.1f",my_score.score)%> | |||
| </li> | |||
| <li class="hworkTip" style="display: none" id="work_click_<%= student_work.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></li> | |||
| </ul> | |||
| <script type="text/javascript"> | |||
| $(".student_work_<%= student_work.id%>").mouseenter(function(){ | |||
| $("#work_click_<%= student_work.id%>").show(); | |||
| }).mouseleave(function(){ | |||
| $("#work_click_<%= student_work.id%>").hide(); | |||
| }).mouse; | |||
| </script> | |||
| <!-- 匿评作品列表,显示某一个作品的信息 --> | |||
| <ul class="hworkListRow" id="student_work_<%= student_work.id%>"> | |||
| <% is_my_work = student_work.user == User.current%> | |||
| <li class="hworkList340 width525"> | |||
| <ul> | |||
| <% if is_my_work%> | |||
| <li class="hworkPortrait mt15 mr10"> | |||
| <%= image_tag(url_to_avatar(student_work.user),width:"40", height: "40") %> | |||
| </li> | |||
| <li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>"> | |||
| <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> | |||
| <div> | |||
| <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%> | |||
| </div> | |||
| </li> | |||
| <li onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;" class="student_work_<%= student_work.id%>"> | |||
| <ul class="mt10 fl"> | |||
| <li class="hworkStName mr10 mt16" title="姓名"> | |||
| <%= student_work.user.show_name%> | |||
| </li> | |||
| <li class="hworkStID mt16" title="学号"> | |||
| <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <% else%> | |||
| <li class="hworkPortrait mt15 mr10"> | |||
| <%= image_tag(url_to_avatar(""),width:"40", height: "40") %> | |||
| </li> | |||
| <li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>"> | |||
| <div> | |||
| <%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%> | |||
| </div> | |||
| </li> | |||
| <li onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;" class="student_work_<%= student_work.id%>"> | |||
| <ul class="mt10 fl"> | |||
| <li class="hworkStName mr10 mt16" title="姓名"> | |||
| 匿名 | |||
| </li> | |||
| <li class="hworkStID mt16" title="学号"> | |||
| -- | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <% end%> | |||
| </ul> | |||
| </li> | |||
| <li class="hworkList130 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;"> | |||
| <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%> | |||
| <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %> | |||
| <span class="c_red">[迟交]</span> | |||
| <% end %> | |||
| </li> | |||
| <!-- 成绩 --> | |||
| <% my_score = student_work_score(student_work,User.current) %> | |||
| <li class="hworkList50 <%= my_score.nil? ? 'c_grey' : score_color(my_score.score)%> mr10"> | |||
| <%= my_score.nil? ? "--" : format("%.1f",my_score.score)%> | |||
| </li> | |||
| <li class="hworkTip" style="display: none" id="work_click_<%= student_work.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></li> | |||
| </ul> | |||
| <script type="text/javascript"> | |||
| $(".student_work_<%= student_work.id%>").mouseenter(function(){ | |||
| $("#work_click_<%= student_work.id%>").show(); | |||
| }).mouseleave(function(){ | |||
| $("#work_click_<%= student_work.id%>").hide(); | |||
| }).mouse; | |||
| </script> | |||
| @@ -89,11 +89,6 @@ | |||
| </li> | |||
| </ul> | |||
| <div id="revise_attachment"> | |||
| <%= render :partial => 'student_work/revise_attachment', :locals => {:work => work} %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= work.student_works_scores.empty? ? 'padding:0px;' : ''%>"> | |||
| <%student_work_scores.each do |student_score|%> | |||
| <div id="work_score_<%= student_score.id%>"> | |||
| @@ -104,26 +99,4 @@ | |||
| <!---ping_box end---> | |||
| <a href="javascript:void(0);" class="fr linkBlue mt5 mb5" onclick="$('#about_hwork_<%= work.id%>').html('');">收起</a> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function show_upload(){ | |||
| $("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>'); | |||
| showModal('ajax-modal', '452px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>"); | |||
| $('#ajax-modal').parent().css("top","40%").css("left","46%"); | |||
| $('#ajax-modal').parent().addClass("resourceUploadPopup"); | |||
| $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); | |||
| } | |||
| function submit_files(){ | |||
| $("#upload_form").submit(); | |||
| } | |||
| function closeModal(){ | |||
| hideModal($(".uploadBoxContainer")); | |||
| } | |||
| function disable_choose(){ | |||
| if ($("#attachments_fields .attachment").size() >= 1) { | |||
| $("#choose_revise_attach").attr("onclick","return false;").addClass(disable_link); | |||
| } | |||
| } | |||
| </script> | |||
| </div> | |||
| @@ -3,7 +3,7 @@ | |||
| <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> | |||
| <% end%> | |||
| <% else %> | |||
| <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity},:method => "post",:remote => true) do |f|%> | |||
| <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course},:method => "post",:remote => true) do |f|%> | |||
| <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> | |||
| <% end%> | |||
| <% end %> | |||
| @@ -41,18 +41,17 @@ | |||
| </li> | |||
| <li > | |||
| <span class="tit_fb"> 附件:</span> | |||
| <% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %> | |||
| <% if com_attachments.empty?%> | |||
| <% if work.attachments.empty?%> | |||
| <span style="color: #999999">尚未提交附件</span> | |||
| <% else%> | |||
| <div class="fl" style="width: 90%;"> | |||
| <%= render :partial => 'work_attachments_status', :locals => {:attachments => com_attachments, :status => @homework.homework_detail_manual.comment_status} %> | |||
| <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments, :status => @homework.homework_detail_manual.comment_status} %> | |||
| </div> | |||
| <% end%> | |||
| <div class="cl"></div> | |||
| </li> | |||
| <li > | |||
| <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%> | |||
| <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current )%> | |||
| <!-- 老师 || 开启匿评状态 && 不是当前用户自己的作品 --> | |||
| <div id="add_student_score_<%= work.id%>" class="mt10 evaluation"> | |||
| <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> | |||
| @@ -62,11 +61,6 @@ | |||
| </li> | |||
| </ul> | |||
| <div id="revise_attachment"> | |||
| <%= render :partial => 'student_work/revise_attachment', :locals => {:work => work} %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= work.student_works_scores.empty? ? 'padding:0px;' : ''%>"> | |||
| <%student_work_scores.each do |student_score|%> | |||
| <div id="work_score_<%= student_score.id%>"> | |||
| @@ -77,26 +71,4 @@ | |||
| <!---ping_box end---> | |||
| <a href="javascript:void(0);" class="fr linkBlue mt5 mb5" onclick="$('#about_hwork_<%= work.id%>').html('');">收起</a> | |||
| <div class="cl"></div> | |||
| </div> | |||
| <script type="text/javascript"> | |||
| function show_upload(){ | |||
| $("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>'); | |||
| showModal('ajax-modal', '452px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>"); | |||
| $('#ajax-modal').parent().css("top","40%").css("left","46%"); | |||
| $('#ajax-modal').parent().addClass("resourceUploadPopup"); | |||
| $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); | |||
| } | |||
| function submit_files(){ | |||
| $("#upload_form").submit(); | |||
| } | |||
| function closeModal(){ | |||
| hideModal($(".uploadBoxContainer")); | |||
| } | |||
| function disable_choose(){ | |||
| if ($("#attachments_fields .attachment").size() >= 1) { | |||
| $("#choose_revise_attach").attr("onclick","return false;").addClass(disable_link); | |||
| } | |||
| } | |||
| </script> | |||
| </div> | |||
| @@ -1,36 +1,36 @@ | |||
| <div class="fl"> | |||
| <span id="attachments_fields<%= work.id%>" xmlns="http://www.w3.org/1999/html"> | |||
| </span> | |||
| <div class="cl"></div> | |||
| <span class="add_attachment" style="font-weight:normal;"> | |||
| <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn mb0' %> | |||
| <%= file_field_tag 'attachments[dummy][file]', | |||
| :id => "_file#{work.id}", | |||
| :class => 'file_selector', | |||
| :multiple => true, | |||
| :onchange => "addInputFiles_board(this, '#{work.id}');", | |||
| :style => 'display:none', | |||
| :data => { | |||
| :max_file_size => Setting.attachment_max_size.to_i.kilobytes, | |||
| :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), | |||
| :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, | |||
| :upload_path => uploads_path(:format => 'js'), | |||
| :description_placeholder => l(:label_optional_description), | |||
| :field_is_public => l(:field_is_public), | |||
| :are_you_sure => l(:text_are_you_sure), | |||
| :file_count => l(:label_file_count), | |||
| :lebel_file_uploding => l(:lebel_file_uploding), | |||
| :delete_all_files => l(:text_are_you_sure_all), | |||
| :containerid => "#{work.id}" | |||
| } %> | |||
| <span id="upload_file_count<%= work.id%>"> | |||
| <%= l(:label_no_file_uploaded) %> | |||
| </span> | |||
| (<%= l(:label_max_size) %>: | |||
| <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) | |||
| </span> | |||
| <% content_for :header_tags do %> | |||
| <%= javascript_include_tag 'attachments' %> | |||
| <% end %> | |||
| </div> | |||
| <div class="fl"> | |||
| <span id="attachments_fields<%= work.id%>" xmlns="http://www.w3.org/1999/html"> | |||
| </span> | |||
| <div class="cl"></div> | |||
| <span class="add_attachment" style="font-weight:normal;"> | |||
| <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn mb0' %> | |||
| <%= file_field_tag 'attachments[dummy][file]', | |||
| :id => "_file#{work.id}", | |||
| :class => 'file_selector', | |||
| :multiple => true, | |||
| :onchange => "addInputFiles_board(this, '#{work.id}');", | |||
| :style => 'display:none', | |||
| :data => { | |||
| :max_file_size => Setting.attachment_max_size.to_i.kilobytes, | |||
| :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), | |||
| :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, | |||
| :upload_path => uploads_path(:format => 'js'), | |||
| :description_placeholder => l(:label_optional_description), | |||
| :field_is_public => l(:field_is_public), | |||
| :are_you_sure => l(:text_are_you_sure), | |||
| :file_count => l(:label_file_count), | |||
| :lebel_file_uploding => l(:lebel_file_uploding), | |||
| :delete_all_files => l(:text_are_you_sure_all), | |||
| :containerid => "#{work.id}" | |||
| } %> | |||
| <span id="upload_file_count<%= work.id%>"> | |||
| <%= l(:label_no_file_uploaded) %> | |||
| </span> | |||
| (<%= l(:label_max_size) %>: | |||
| <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) | |||
| </span> | |||
| <% content_for :header_tags do %> | |||
| <%= javascript_include_tag 'attachments' %> | |||
| <% end %> | |||
| </div> | |||
| @@ -1,52 +1,52 @@ | |||
| <div class="fl" style="padding-bottom:10px; width:720px;"> | |||
| <span class="c_dark f14 fb fl mr15"> | |||
| 作品 | |||
| <font class="f12 c_red"> | |||
| (<%= @student_work_count%>人已交) | |||
| </font> | |||
| <% if !@is_teacher && @stundet_works.empty?%> | |||
| <span class="f12 c_red">您尚未提交作品</span> | |||
| <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> | |||
| <span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span> | |||
| <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> | |||
| <span class="f12 c_red">您已提交,您还可以修改</span> | |||
| <% end %> | |||
| </span> | |||
| <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> | |||
| <div class="hworkSearchBox"> | |||
| <input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/> | |||
| <a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a> | |||
| </div> | |||
| <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> | |||
| <% end%> | |||
| <span class="fr c_grey"> <a href="javascript:void(0);" class="linkGrey2" id="homework_info_show" style="display: none">[ 显示作业信息 ]</a> </span> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="fl"> | |||
| <% if @is_evaluation && !@stundet_works.empty?%> | |||
| <%= render :partial => "evaluation_title"%> | |||
| <% else%> | |||
| <%= render :partial => "evaluation_un_title"%> | |||
| <% end%> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% @stundet_works.each do |student_work|%> | |||
| <% if @is_evaluation%> | |||
| <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> | |||
| <% else%> | |||
| <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> | |||
| <% end%> | |||
| <div class="cl"></div> | |||
| <div id="about_hwork_<%= student_work.id%>"> | |||
| <% if student_work.user == User.current && !@is_evaluation %> | |||
| <% if @homework.homework_type == 2%> | |||
| <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> | |||
| <% else %> | |||
| <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> | |||
| <% end %> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="fl" style="padding-bottom:10px; width:720px;"> | |||
| <span class="c_dark f14 fb fl mr15"> | |||
| 作品 | |||
| <font class="f12 c_red"> | |||
| (<%= @student_work_count%>人已交) | |||
| </font> | |||
| <% if !@is_teacher && @stundet_works.empty?%> | |||
| <span class="f12 c_red">您尚未提交作品</span> | |||
| <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> | |||
| <span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span> | |||
| <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> | |||
| <span class="f12 c_red">您已提交,您还可以修改</span> | |||
| <% end %> | |||
| </span> | |||
| <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> | |||
| <div class="hworkSearchBox"> | |||
| <input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/> | |||
| <a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a> | |||
| </div> | |||
| <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> | |||
| <% end%> | |||
| <span class="fr c_grey"> <a href="javascript:void(0);" class="linkGrey2" id="homework_info_show" style="display: none">[ 显示作业信息 ]</a> </span> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <div class="fl"> | |||
| <% if @is_evaluation && !@stundet_works.empty?%> | |||
| <%= render :partial => "evaluation_title"%> | |||
| <% else%> | |||
| <%= render :partial => "evaluation_un_title"%> | |||
| <% end%> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% @stundet_works.each do |student_work|%> | |||
| <% if @is_evaluation%> | |||
| <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> | |||
| <% else%> | |||
| <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> | |||
| <% end%> | |||
| <div class="cl"></div> | |||
| <div id="about_hwork_<%= student_work.id%>"> | |||
| <% if student_work.user == User.current && !@is_evaluation %> | |||
| <% if @homework.homework_type == 2%> | |||
| <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> | |||
| <% else %> | |||
| <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> | |||
| <% end %> | |||
| <% end %> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| @@ -19,10 +19,9 @@ | |||
| </p> | |||
| <div class="cl"></div> | |||
| <div class="ni_btn mt10"> | |||
| <a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" > | |||
| <a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px; margin-left: 55px;" > | |||
| 确 定 | |||
| </a> | |||
| <%= link_to("重试", retry_work_student_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -11,7 +11,7 @@ | |||
| showModal('ajax-modal', '500px'); | |||
| $('#ajax-modal').siblings().remove(); | |||
| $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + | |||
| "<a href='/student_work/"+ <%=@student_work.id%> +"/retry_work' class='upload_btn' data-remote='true'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); | |||
| $('#ajax-modal').parent().css("top","").css("left",""); | |||
| $('#ajax-modal').parent().addClass("anonymos"); | |||
| <% else %> | |||
| @@ -99,7 +99,7 @@ | |||
| </div> | |||
| <div class="mt5 fl"> | |||
| <a href="javascript:void(0);" class="RalationIcon fl mt3" onclick="show_project();">关联项目</a> | |||
| <a href="javascript:void(0);" class="RalationIcon fl mt3" onclick="show_project();">关联项目</a> | |||
| </div> | |||
| <div class="cl"></div> | |||
| @@ -111,9 +111,9 @@ | |||
| </div> | |||
| <div class="mt5"> | |||
| <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">提交</a> | |||
| <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">确定</a> | |||
| <span class="fr mr10 mt3">或</span> | |||
| <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%> | |||
| <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> | |||
| </div> | |||
| <div class="cl"></div> | |||
| <% end%> | |||
| @@ -1,6 +1,6 @@ | |||
| clickCanel(); | |||
| <% if @user_activity_id %> | |||
| $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@courae_activity}) %>"); | |||
| $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id}) %>"); | |||
| init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); | |||
| <% else %> | |||
| $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); | |||