diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index e9ec192f0..934f79cf7 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -28,25 +28,25 @@ mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/0604new root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/20161227data root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/0623newblank root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e diff --git a/app/assets/javascripts/homework_bank.js.coffee b/app/assets/javascripts/homework_bank.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/homework_bank.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/management.js.coffee b/app/assets/javascripts/management.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/management.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/managements.js.coffee b/app/assets/javascripts/managements.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/managements.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/homework_bank.css.scss b/app/assets/stylesheets/homework_bank.css.scss new file mode 100644 index 000000000..d8be9e5ef --- /dev/null +++ b/app/assets/stylesheets/homework_bank.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the HomeworkBank controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/management.css.scss b/app/assets/stylesheets/management.css.scss new file mode 100644 index 000000000..6d4f81abc --- /dev/null +++ b/app/assets/stylesheets/management.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the management controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/managements.css.scss b/app/assets/stylesheets/managements.css.scss new file mode 100644 index 000000000..00a467eed --- /dev/null +++ b/app/assets/stylesheets/managements.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the managements controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index f6d76e728..fb5639739 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -452,6 +452,16 @@ class AccountController < ApplicationController render :layout => 'base_edu_account' end + def apply_trail + apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization").first + if apply_action.blank? + ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization") + end + respond_to do |format| + format.js + end + end + def user_auth @user = User.current diskfile1 = disk_auth_filename('UserAuthentication', @user.id, 'ID') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3871b20a5..e0cbc2524 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,8 +45,8 @@ class ApplicationController < ActionController::Base before_filter :find_first_page before_filter :find_web_footer - before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization, :check_authentication - before_filter :user_agent + before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization + before_filter :user_agent rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token rescue_from ::Unauthorized, :with => :deny_access @@ -61,20 +61,18 @@ class ApplicationController < ActionController::Base end # 判断用户是否认证 - def check_authentication - return true -=begin - uthentication = AuthenticationsUsers.where(:user_id => User.current.id).first - user_account = User.current.user_extensions.try(:occupation) - if uthentication.blank? || user_account.blank? - redirect_to my_account_path - return - elsif User.current.authentications == 0 - redirect_to authentication_account_path - return - end -=end - end + # def check_authentication + # # return true + # if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载 + # return true + # end + # authentication = ApplyAction.where(:user_id => User.current.id, :status => 1).first + # user_identity = User.current.try(:user_extensions).try(:identity) + # if user_identity.blank? || authentication.blank? + # redirect_to my_account_path + # return + # end + # end def session_expiration if session[:user_id] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 50a7f4486..222138049 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -14,6 +14,7 @@ class CoursesController < ApplicationController before_filter :auth_login1, :only => [:show, :course_activity, :feedback] skip_before_filter :verify_authenticity_token, :only => [:update_position] + before_filter :check_authentication, :except => [:update_position] menu_item :overview menu_item :feedback, :only => :feedback menu_item :homework, :only => :homework @@ -851,17 +852,7 @@ class CoursesController < ApplicationController @teacher_count = @teachers.count @student_count = studentCount(@course) @no_group_count = @course.members.where(:course_group_id => 0).select{|m| m.roles.to_s.include?("Student")}.count - - @roles = Role.givable.all[3..5] - @members = @course.member_principals.includes(:roles, :principal).all.sort - - course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{@course.id}").map(&:organization_id) - if course_org_ids.empty? - @orgs_not_in_course = User.current.organizations - else - course_org_ids = "(" + course_org_ids.join(',') + ")" - @orgs_not_in_course = User.current.organizations.where("organizations.id not in #{course_org_ids}") - end + @apply_users = CourseMessage.where(:course_id => @course.id,:course_message_type => 'JoinCourseRequest', :status => 0) course_module = @course.course_modules if course_module.blank? diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 24223c25d..ed646354c 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -8,6 +8,7 @@ class ForumsController < ApplicationController before_filter :authenticate_user_edit, :only => [:edit, :update] before_filter :authenticate_user_destroy, :only => [:destroy] before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit] + before_filter :check_authentication helper :sort include SortHelper diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 3cc77b10c..3256c1f92 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -81,7 +81,7 @@ class GamesController < ApplicationController @had_passed_testsests_error_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == false}.count @had_passed_testsests_hidden_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == false}.count @had_passed_testsests_public_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == true}.count - @final_score = (@game.answer_open == 1 ? 0 : @game.final_score.to_i) + @final_score = (@game.answer_open? ? 0 : @game.final_score.to_i) @had_done = ((@myshixun.games.where(:status => 2).count == @myshixun.games.count && @game_challenge.position == @myshixun.games.count) ? 1 : 0) error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last logger.info("latest output id is #{error_position.id unless error_position.blank?}") @@ -225,7 +225,7 @@ class GamesController < ApplicationController @had_passed_testsests_error_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == false}.count @had_passed_testsests_hidden_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == false}.count @had_passed_testsests_public_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == true}.count - @final_score = (@game.answer_open == 1 ? 0 : @game.final_score.to_i) + @final_score = (@game.answer_open? ? 0 : @game.final_score.to_i) error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ') unless error_position.try(:out_put).blank? render :json => {test_sets: total_test_sets, @@ -253,6 +253,27 @@ class GamesController < ApplicationController render :json => {status: @game.status, output: "服务器网络异常", results: outputs, had_done: 0} end + # 获取等待的任务数 + # 如果没有等待任务页面上将不显示 + # msg: -1 不存在等待的任务 + # 如果该方法异常则直接返回0,跳过等待 + def waiting_info + begin + jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] + params = {:buildID => "#{@game.id}"} + uri = URI("#{jenkins_shixuns}/jenkins-exec/api/getWaitingTime") + res = uri_exec uri, params + if (res && res['code'] != 0) + raise("获取等待任务数异常") + end + task_count = res['msg'].to_i + task_count > 0 ? task_count : 0 + render :json => {task_count: task_count} + rescue + render :json => {task_count: 0} + end + end + # 自动推送下一个任务 def next_step render_403 if @game.status != 2 diff --git a/app/controllers/homework_bank_controller.rb b/app/controllers/homework_bank_controller.rb new file mode 100644 index 000000000..208def604 --- /dev/null +++ b/app/controllers/homework_bank_controller.rb @@ -0,0 +1,233 @@ +class HomeworkBankController < ApplicationController + before_filter :require_login, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :destroy_all, :choose_user_course, :send_h_bank_to_course] + before_filter :find_homework_bank, :only => [:show, :edit, :update, :destroy] + + def index + @order,@b_sort = params[:order] || "updated_at",params[:sort] || "desc" + @user = User.current + @r_sort = @b_sort == "desc" ? "asc" : "desc" + @search = params[:search] + if(params[:type].blank? || params[:type] == "1") #我的题库 + @homeworks = @user.homework_banks.where("name like ?", "%#{@search}%") + elsif params[:type] == "2" #公共题库 + @homeworks = HomeworkBank.where(:is_public => true).where("name like ?", "%#{@search}%") + end + if params[:property] + @property = params[:property].to_i + @homeworks = @homeworks.where(:homework_type => params[:property].to_i) + end + @homeworks = @homeworks.reorder("#{@order} #{@b_sort}") + @type = params[:type] ? params[:type] : '1' + @limit = 15 + @is_remote = true + @hw_count = @homeworks.count + @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 + @offset ||= @hw_pages.offset + @homeworks = paginateHelper @homeworks,15 + respond_to do |format| + format.js + format.html {render :layout => 'base_edu'} + end + end + + def show + @is_admin = User.current == @homework.user || User.current.admin? + respond_to do |format| + format.html {render :layout => 'base_edu'} + end + end + + def new + @homework_type = params[:homework_type].to_i + @homework = HomeworkBank.new + respond_to do |format| + format.html{render :layout => 'base_edu'} + end + end + + # 新建实训作业 + def shixuns + search = params[:search] + @homework = HomeworkBank.new + @shixuns = Shixun.where(:authentication => 1).where("name like ?", "%#{search}%") + @shixuns_count = @shixuns.count + @limit = 10 + @is_remote = true + @shixun_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1 + @offset ||= @shixun_pages.offset + @shixuns = paginateHelper @shixuns, @limit + respond_to do |format| + format.js + end + end + + def create + if params[:homework_bank] || params[:shixun_homework] + homework = HomeworkBank.new + if params[:shixun_homework] + shixun = Shixun.find(params[:shixun_homework]) + homework.name = shixun.name + homework.description = shixun.description + else + homework.name = params[:homework_bank][:name] + homework.description = params[:homework_bank][:description] + homework.reference_answer = params[:homework_bank][:reference_answer] + homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(homework) + end + homework.is_public = 0 + homework.quotes = 0 + homework.homework_type = params[:shixun_homework] ? 4 : (params[:homework_type].to_i || 1) + homework.user_id = User.current.id + homework.syllabus_id = params[:syllabus_id] if params[:syllabus_id] && params[:syllabus_id] != '0' + + #编程作业相关属性 + if homework.homework_type == 2 + homework.language = params[:language_type].to_i + + sample_inputs = params[:sample][:input] + if Array === sample_inputs + sample_inputs.each_with_index do |val, i| + homework.homework_bank_samples << HomeworkBankSample.new( + input: val, + output: params[:sample][:output][i] + ) + end + end + + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + homework.homework_bank_tests << HomeworkBankTest.new( + input: val, + output: params[:program][:output][i] + ) + end + end + end + + #分组作业 + if homework.homework_type == 3 + homework.min_num = params[:min_num].to_i + homework.max_num = params[:max_num].to_i + end + + if homework.save + if homework.homework_type == 4 + HomeworkBankShixun.create(:homework_bank_id => homework.id, :shixun_id => shixun.id) + end + redirect_to homework_bank_path(homework) + end + end + end + + def edit + @homework_type = @homework.homework_type + respond_to do |format| + format.html{render :layout => 'base_edu'} + end + end + + def update + if params[:homework_bank] + @homework.name = params[:homework_bank][:name] + @homework.description = params[:homework_bank][:description] + @homework.reference_answer = params[:homework_bank][:reference_answer] + @homework.syllabus_id = params[:syllabus_id] ? (params[:syllabus_id] == '0' ? nil : params[:syllabus_id].to_i) : nil + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) + + #编程作业相关属性 + if @homework.homework_type == 2 + @homework.language = params[:language_type].to_i if params[:language_type] + + @homework.homework_bank_samples.delete_all if params[:sample] + sample_inputs = params[:sample][:input] if params[:sample] + if Array === sample_inputs + sample_inputs.each_with_index do |val, i| + @homework.homework_bank_samples << HomeworkBankSample.new( + input: val, + output: params[:sample][:output][i] + ) + end + end + + @homework.homework_bank_tests.delete_all if params[:program] + inputs = params[:program][:input] if params[:program] + if Array === inputs + inputs.each_with_index do |val, i| + @homework.homework_bank_tests << HomeworkBankTest.new( + input: val, + output: params[:program][:output][i] + ) + end + end + end + + #分组作业 + if @homework.homework_type == 3 + @homework.min_num = params[:min_num].to_i if params[:min_num] + @homework.max_num = params[:max_num].to_i if params[:max_num] + end + + if @homework.save + redirect_to homework_bank_path(@homework) + end + end + end + + def destroy + @homework.homework_commons.update_all(:homework_bank_id => nil) + @homework.destroy + redirect_to homework_bank_index_path() + end + + def destroy_all + if params[:check_homework_bank] && !params[:check_homework_bank].blank? + params[:check_homework_bank].each do |hb_id| + homework = HomeworkBank.find hb_id + if homework && homework.user == User.current + HomeworkCommon.where(:homework_bank_id => homework.id).update_all(:homework_bank_id => nil) + homework.destroy + end + end + end + redirect_to homework_bank_index_path + end + + def choose_user_course + if !params[:search].nil? + search = "%#{params[:search].to_s.strip.downcase}%" + @courses = User.current.courses.where("is_delete = 0 and is_end = 0 and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select{ |course| User.current.has_teacher_role(course)} + else + @courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)} + end + @homework_ids = params[:check_homework_bank] if params[:check_homework_bank] + @search = params[:search] + respond_to do |format| + format.js + end + end + + def send_h_bank_to_course + course = Course.find params[:course_id] + if course + params[:homework_id].each do |homework_id| + homework = HomeworkBank.find homework_id + quote_homework_bank homework, course + end + end + end + + def set_public + @homework.update_attributes(:is_public => true) + redirect_to homework_bank_index_path() + end + + private + def find_homework_bank + @homework = HomeworkBank.find params[:id] + rescue ActiveRecord::RecordNotFound + render_404 + end +end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index b0e6995ec..9c0b2bebe 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -41,18 +41,12 @@ class HomeworkCommonController < ApplicationController case @order when '1' @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.created_at desc") - when '2' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and late_time > '#{Time.now}'").order("homework_commons.created_at desc") when '3' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}') - or (homework_detail_manuals.comment_status = 1 and end_time < '#{Time.now}' and allow_late = 0 and anonymous_comment = 0 and homework_detail_manuals.evaluation_start >= '#{Time.now}') - or (homework_detail_manuals.comment_status = 2 and late_time < '#{Time.now}' and anonymous_comment = 0 and homework_detail_manuals.evaluation_start >= '#{Time.now}')").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.created_at desc") when '4' @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.created_at desc") when '5' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}') - or (homework_detail_manuals.comment_status = 1 and end_time < '#{Time.now}' and (anonymous_comment = 1 or (anonymous_comment = 0 and homework_detail_manuals.evaluation_start < '#{Time.now}')) and archive_time >= '#{Time.now}') - or (homework_detail_manuals.comment_status = 2 and late_time < '#{Time.now}' and (anonymous_comment = 1 or (anonymous_comment = 0 and homework_detail_manuals.evaluation_start < '#{Time.now}')) and archive_time >= '#{Time.now}')").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.created_at desc") else @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.created_at desc") end @@ -60,7 +54,7 @@ class HomeworkCommonController < ApplicationController @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] - @homeworks = paginateHelper @homework_commons,10 + @homeworks = paginateHelper @homework_commons,15 #设置at已读 ids = @homeworks.inject([]) do |ids, homework| jids = homework.journals_for_messages.map(&:id) @@ -184,6 +178,8 @@ class HomeworkCommonController < ApplicationController if homework.homework_type != 4 && homework_detail_manual.comment_status == 1 create_works_list homework + elsif homework.homework_type == 4 + HomeworkCommonsShixuns.create(:homework_common_id => homework.id, :shixun_id => shixun.id) end if params[:quotes] && !params[:quotes].blank? @@ -214,7 +210,7 @@ class HomeworkCommonController < ApplicationController def publish_setting @homework.publish_time = params[:homework_publish_time] if params[:homework_publish_time] @homework.end_time = params[:homework_end_time] if params[:homework_end_time] - @homework.archive_time = params[:homework_archive_time] if params[:homework_end_time] + @homework.archive_time = params[:homework_archive_time] if params[:homework_archive_time] @homework.save @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) respond_to do |format| @@ -225,11 +221,11 @@ class HomeworkCommonController < ApplicationController def late_setting if params[:homework_allow_late] == '1' @homework.allow_late = true - @homework.late_time = params[:homework_late_time] + #@homework.late_time = params[:homework_late_time] @homework.late_penalty = params[:homework_late_penalty].to_i else @homework.allow_late = false - @homework.late_time = nil + #@homework.late_time = nil @homework.late_penalty = 0 end @homework.save @@ -238,32 +234,62 @@ class HomeworkCommonController < ApplicationController def anon_setting anonymous_comment = @homework.anonymous_comment - if params[:homework_anonymous_comment] - @homework.anonymous_comment = 0 - @homework_detail_manual.evaluation_start = params[:homework_evaluation_start] - @homework_detail_manual.evaluation_end = params[:homework_evaluation_end] - @homework_detail_manual.evaluation_num = params[:homework_evaluation_num] - @homework_detail_manual.absence_penalty = params[:homework_absence_penalty] + absence_penalty = @homework_detail_manual.absence_penalty + appeal_penalty = @homework_detail_manual.appeal_penalty + if @homework_detail_manual.comment_status < 3 + if params[:homework_anonymous_comment] + @homework.anonymous_comment = 0 + @homework_detail_manual.evaluation_start = params[:homework_evaluation_start] if params[:homework_evaluation_start] + @homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end] + @homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num] + @homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty] + else + @homework.anonymous_comment = 1 + @homework_detail_manual.evaluation_start = nil + @homework_detail_manual.evaluation_end = nil + @homework_detail_manual.evaluation_num = 0 + @homework_detail_manual.absence_penalty = 0 + end else - @homework.anonymous_comment = 1 - @homework_detail_manual.evaluation_start = nil - @homework_detail_manual.evaluation_end = nil - @homework_detail_manual.evaluation_num = 0 - @homework_detail_manual.absence_penalty = 0 + @homework_detail_manual.evaluation_end = params[:homework_evaluation_end] if params[:homework_evaluation_end] + @homework_detail_manual.evaluation_num = params[:homework_evaluation_num] if params[:homework_evaluation_num] + @homework_detail_manual.absence_penalty = params[:homework_absence_penalty] if params[:homework_absence_penalty] end if anonymous_comment != @homework.anonymous_comment @homework_detail_manual.te_proportion = 1 @homework_detail_manual.ta_proportion = 0 - @homework_detail_program.te_proportion = 0 if @homework_detail_program + @homework_detail_programing.ta_proportion = 0 if @homework_detail_programing end - if params[:homework_anonymous_appeal] - @homework.anonymous_appeal = 1 - @homework_detail_manual.appeal_time = params[:homework_appeal_time] - @homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] + if @homework_detail_manual.comment_status < 4 + if params[:homework_anonymous_appeal] + @homework.anonymous_appeal = 1 + @homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time] + @homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty] + else + @homework.anonymous_appeal = 0 + @homework_detail_manual.appeal_time = nil + @homework_detail_manual.appeal_penalty = 0 + end else - @homework.anonymous_appeal = 0 - @homework_detail_manual.appeal_time = nil - @homework_detail_manual.appeal_penalty = 0 + @homework_detail_manual.appeal_time = params[:homework_appeal_time] if params[:homework_appeal_time] + @homework_detail_manual.appeal_penalty = params[:homework_appeal_penalty] if params[:homework_appeal_penalty] + end + if absence_penalty != @homework_detail_manual.absence_penalty && @homework_detail_manual.comment_status >= 4 + all_dis_eva = StudentWorksEvaluationDistribution.where(:student_work_id => @homework.student_works.map(&:id)) + has_sw_count = all_dis_eva.select("distinct user_id").count + anon_count = all_dis_eva.count / has_sw_count + @homework.student_works.where("work_status != 0").each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).count - student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :reviewer_role => 3).count + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 + student_work.save + end + end + if appeal_penalty != @homework_detail_manual.appeal_penalty && @homework_detail_manual.comment_status >= 4 + @homework.student_works.each do |student_work| + appeal_penalty_count = student_work.user.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :appeal_status => 3).count + student_work.appeal_penalty = appeal_penalty_count > 0 ? appeal_penalty_count * @homework_detail_manual.absence_penalty : 0 + student_work.save + end end @homework.save @homework_detail_manual.save @@ -356,7 +382,7 @@ class HomeworkCommonController < ApplicationController def update if params[:homework_common] - is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description] + is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description] || @homework.reference_answer != params[:homework_common][:reference_answer] if params[:homework_type].to_i == 2 is_update = is_update || params[:language_type] != @homework.homework_detail_programing.language if !is_update && params[:sample] && params[:program] @@ -478,24 +504,25 @@ class HomeworkCommonController < ApplicationController end homework_bank = add_to_homework_bank_f @homework homework_bank.save + if @homework.homework_type == 4 + HomeworkBankShixun.create(:homework_bank_id => homework_bank.id, :shixun_id => @homework.homework_commons_shixuns.shixun_id) + end @homework.update_attributes(:homework_bank_id => homework_bank.id) elsif params[:type].to_i == 2 homework_bank = HomeworkBank.where(:id => @homework.homework_bank_id).first if homework_bank - homework_bank.update_attributes(:name => @homework.name, :description => @homework.description, :homework_type => @homework.homework_type) + homework_bank.update_attributes(:name => @homework.name, :description => @homework.description, :homework_type => @homework.homework_type, :reference_answer => @homework.reference_answer) if @homework.homework_type == 2 && @homework.homework_detail_programing homework_bank.update_attributes(:language => @homework.homework_detail_programing.language) homework_bank.homework_bank_tests.destroy_all @homework.homework_tests.each_with_index do |homework_test| homework_bank.homework_bank_tests << HomeworkBankTest.new( - test_type: 1, input: homework_test.input, output: homework_test.output ) end @homework.homework_samples.each_with_index do |homework_test| - homework_bank.homework_bank_tests << HomeworkBankTest.new( - test_type: 0, + homework_bank.homework_bank_samples << HomeworkBankSample.new( input: homework_test.input, output: homework_test.output ) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb new file mode 100644 index 000000000..4bac95052 --- /dev/null +++ b/app/controllers/managements_controller.rb @@ -0,0 +1,112 @@ +class ManagementsController < ApplicationController + before_filter :require_admin + layout 'base_management' + include ManagementsHelper + include SortHelper + include UsersHelper + + def users + @menu_type = 6 + sort_init 'login', 'asc' + sort_update %w(login firstname lastname mail admin created_on last_login_on) + + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 50}) + else + @limit = 50 #per_page_option + end + + @status = params[:status] || 1 + scope = User.logged.status(@status) + scope = User.like(params[:name]) if params[:name].present? + scope = scope.in_group(params[:group_id]) if params[:group_id].present? + + @user_count = scope.count + @user_pages = Paginator.new @user_count, @limit, params['page'] + @offset ||= @user_pages.offset + @users = scope.order(sort_clause).limit(@limit).offset(@offset).all + respond_to do |format| + format.html { + @groups = Group.all.sort + } + format.api + end + end + + def users_trial + @menu_type = 6 + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => 0).includes(:user) + end + + def trial_authorization + @menu_type = 9 + search = params[:search] + @status = trial_authorization_status(params[:status]) + # @status = (params[:status].blank? || params[:status] == "0") ? 0 : [1,2] + if search.blank? + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status).includes(:user) + else + user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'") + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status, :user_id => user_id).includes(:user) + end + end + + # params[:type] 1:拒绝 0:同意 + # authentication 会有一个初始值,不同的值代表不同的权限 + # REDO: 后面权限改了后,一并要改 + def trial_authorization_operation + apply_action = ApplyAction.find(params[:apply_id]) + type = params[:type] + search = params[:search] + if type == "0" + authentication_user = AuthenticationsUsers.where(:user_id => apply_action.user_id).first + if authentication_user.blank? + AuthenticationsUsers.create(:user_id => apply_action.user_id, :authentication_id => 1) + end + end + apply_action.update_attributes(:status => (params[:type] == "1" ? 2 : 1), :reason => params[:reject_reason], :dealer_id => User.current.id) + user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'") + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => 0, :user_id => user_id).includes(:user) + respond_to do |format| + format.js + end + end + + def index + + end + + # copy from admin + def identity_authentication + @menu_type = 9 + type = params[:type] || 0 # 存在type 就用type 没有就为 0 + user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{params[:name]}%'") + @unapproved_user = ApplyUserAuthentication.where(:status => type, :user_id => user_id).order("updated_at desc") + respond_to do |format| + format.html + format.js + end + end + + # 拒绝身份认证 + # copy from admin + def reject_authentication + apply_user = ApplyUserAuthentication.find(params[:apply_id]) + reason = apply_user.update_attributes(:status => 2, :remarks => params[:reject_reason]) + render :json => {success: reason} + end + + # 统一身份认证 + # copy from admin + def agree_authentication + apply_user = ApplyUserAuthentication.find(params[:apply_id]) + user = User.find(apply_user.user_id) + apply_user.update_attribute(:status, 1) + user.update_attribute(:authentication, true) + @unapproved_user = ApplyUserAuthentication.where(:status => 0).order("updated_at desc") + respond_to do |format| + format.js + end + end +end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index fe71494ad..b07fca70f 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -147,21 +147,35 @@ class MyController < ApplicationController end @user = User.current - # 基本资料不完善 @force为false, 完善 @force为true - @force = false - if params[:tip] - @force = true + # 认证 + ue = @user.user_extensions + @trail_authentication = ApplyAction.where(:user_id => User.current.id).first + @authentication = @user.authentication + if ue.identity.nil? + @require_auth = true else - user = UserExtensions.where(:user_id => User.current.id).first - if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? - @force = true - elsif user.identity == 3 && user.school_id.nil? - @force = true + if @trail_authentication.blank? + @require_trail_auth = true end end - - # 用户认证 - @auth = @user.authentication ? false : true + # @require_auth = true + # + # # 基本资料不完善 @force为false, 完善 @force为true + # @force = false + # # @authentication = @user.authentication + # @trail_authentication = AuthenticationsUsers.where(:user_id => User.current.id).first + # if params[:tip] + # @force = true + # else + # user = UserExtensions.where(:user_id => User.current.id).first + # if user.identity.nil? || user.school_id.nil? || User.current.lastname.nil? + # @force = false + # else + # @force = @trail_authentication.blank? ? false : true + # end + # end + # # 用户认证 + # @auth = @user.authentication ? false : true @s_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').first @d_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').first @@ -217,6 +231,7 @@ class MyController < ApplicationController @se.brief_introduction = params[:brief_introduction] if @user.save && @se.save + reward_grade(@user, @user.id, 'Account', 500) # 修改邮箱的时候同步修改到gitlab # if changed_mail || changed_login diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index d76494716..19fbd8fe0 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -3,6 +3,7 @@ class MyshixunsController < ApplicationController layout 'base_myshixun' skip_before_filter :verify_authenticity_token, :only => [:training_task_status] before_filter :require_login, :except => [:training_task_status] + before_filter :check_authentication, :except => [:training_task_status] before_filter :find_myshixun, :only => [:show, :myshixun_reset] include ApplicationHelper @@ -77,7 +78,10 @@ class MyshixunsController < ApplicationController if !resubmit.blank? game.update_attributes(:retry_status => 2, :resubmit_identifier => resubmit) else - game.update_attributes(:status => 2, :final_score => challenge.score, :end_time => Time.now) + game.update_attributes(:status => 2, :end_time => Time.now) + unless game.answer_open? # 如果没有查看答案,则获得该关卡得分 + game.update_attribute(:final_score, challenge.score) + end end else if !resubmit.blank? diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ff3f1c7d1..ea64d0397 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -929,10 +929,10 @@ class ProjectsController < ApplicationController end end - def uri_exec uri, params - res = Net::HTTP.post_form(uri, params).body - res = JSON.parse(res) - end + # def uri_exec uri, params + # # res = Net::HTTP.post_form(uri, params).body + # # res = JSON.parse(res) + # end # 开启实训项目,学生会fork一个项目并自动发送任务 def training_project_extend diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 505e73699..8fc561502 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -3,6 +3,7 @@ class ShixunsController < ApplicationController layout 'base_shixun' before_filter :require_login + before_filter :check_authentication before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search ] before_filter :shixun_view_allow, :only => [:show] before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 070107633..1a1af7166 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -363,12 +363,13 @@ class StudentWorkController < ApplicationController @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now).order("created_at desc") @all_homework_commons = @course.homework_commons.order("created_at desc") @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 3 && !@is_teacher #是不是匿评 + @is_evaluation = @homework.homework_detail_manual && (@homework.homework_detail_manual.comment_status == 3 || @homework.homework_detail_manual.comment_status == 4) && !@is_teacher #是不是匿评 @show_all = false # 0表示没有分组的学生,-1表示所有分组的学生 if @group - group_students = Member.where(:course_group_id => @group) + group_students = @course.members.where(:course_group_id => @group).joins("join users on members.user_id = users.id").select{|m| m.roles.to_s.include?("Student")} + if group_students.empty? student_in_group = '(-1)' else @@ -503,6 +504,7 @@ class StudentWorkController < ApplicationController @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 # 消息传过来的ID @message_student_work_id = params[:student_work_id] + @no_group_count = @course.members.where(:course_group_id => 0).select{|m| m.roles.to_s.include?("Student")}.count @left_nav_type = 3 @tab = params[:tab].to_i respond_to do |format| @@ -559,7 +561,7 @@ class StudentWorkController < ApplicationController student_work.homework_common_id = @homework.id student_work.user_id = User.current.id student_work.commit_time = Time.now - student_work.late_reason = params[:late_reason] if params[:late_reason] + #student_work.late_reason = params[:late_reason] if params[:late_reason] student_work.group_id = @homework.student_works.all_commit.select("distinct group_id").count + 1 student_work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(student_work) @@ -711,9 +713,10 @@ class StudentWorkController < ApplicationController appeal_message.update_all(:viewed => true) end + @is_focus = params[:is_focus] if params[:is_focus] @score = student_work_score @work,User.current @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - if @homework.homework_detail_manual.comment_status == 2 && !@is_teacher && @work.user != User.current + if (@homework.homework_detail_manual.comment_status == 3 || @homework.homework_detail_manual.comment_status == 4) && !@is_teacher && @work.user != User.current @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc") else @student_work_scores = student_work_score_record(@work) @@ -875,7 +878,10 @@ class StudentWorkController < ApplicationController @is_last = params[:is_last] == "true" @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 - render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2 + unless @is_teacher || @homework.homework_detail_manual.comment_status == 3 + render_403 + return + end @score = student_work_score @work,User.current #@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #@score.score = params[:score] if params[:score] @@ -967,8 +973,12 @@ class StudentWorkController < ApplicationController update_org_activity(@homework.class,@homework.id) if @work.save @work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first - @count = @homework.student_works.has_committed.count - @student_work_scores = student_work_score_record @work + if @homework.homework_detail_manual.comment_status == 3 && !@is_teacher && @work.user != User.current + @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc") + else + @student_work_scores = student_work_score_record(@work) + end + @count = @student_work_scores.count respond_to do |format| format.js end @@ -1360,10 +1370,7 @@ class StudentWorkController < ApplicationController CourseMessage.create(:user_id => student_work.homework_common.user_id, :course_id => student_work.homework_common.course_id, :viewed => false,:course_message_id=>attachment.container_id,:course_message_type=>'StudentWork',:status=>2) end @work.update_attributes(:re_commit => 1) - respond_to do |format| - format.js - end - @homework = @work.homework_common + redirect_to student_work_path(@work) end def new_student_work_project diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 7451a893c..23ad61f92 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -7,6 +7,7 @@ class SyllabusesController < ApplicationController include SyllabusesHelper include UsersHelper before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus, :syllabus_resources, :syllabus_homeworks] + before_filter :check_authentication before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :edit_syllabus_title, :update_base_info, :delete_syllabus, :delete_des, :members, :update_des, :edit_ref, :update_ref, :add_sy_member_alert, :search_not_sy_member, :syllabus_resources, :syllabus_homeworks, :send_homeworks_to_course, :choose_user_course, :send_resources_to_course, :send_r_and_h_to_course] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 54dd8c081..dc9b11aee 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -35,6 +35,8 @@ class UsersController < ApplicationController # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] + before_filter :check_authentication + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks, :unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :update_message_viewed, :anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks, @@ -43,7 +45,7 @@ class UsersController < ApplicationController :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community, - :user_shixuns] + :shixuns] before_filter :auth_user_extension, only: :show before_filter :show_system_message, :only => [:show] #before_filter :rest_user_score, only: :show @@ -654,10 +656,30 @@ class UsersController < ApplicationController end # 我发布的实训 - def shixuns_zone - @shixuns = Shixun.where(:user_id => User.current) + def shixuns + type = params[:type] + # 我发布的 + @shixuns = Shixun.where(:user_id => @user.id) + @shixuns_count = @shixuns.count + @limit = 10 + @shixun_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1 + @offset ||= @shixun_pages.offset + @shixuns = paginateHelper @shixuns, @limit + + # 我参入的 + ids = Shixun.find_by_sql("select id from shixun_members where role=2 and user_id=#{@user.id}") + ids2 = Shixun.find_by_sql("select id from shixuns where id in (select shixun_id from myshixuns where user_id = #{@user.id})") + ids = ids.map{|shixun| shixun.id} unless ids.blank? + ids2 = ids2.map{|shixun| shixun.id} unless ids2.blank? + id = ids + ids2 + id = id.uniq + @join_shixuns = Shixun.where(:id => id) + # @join_shixuns_count = @join_shixuns.count + # @join_shixuns_pages = Paginator.new @join_shixuns_count, @limit, params['page'] || 1 + # @join_shixuns_offset ||= @join_shixuns_pages.offset + # @join_shixuns = paginateHelper @join_shixuns, @limit respond_to do |format| - format.html{render :layout=>'base_users_new'} + format.html{render :layout=> 'base_edu'} end end @@ -721,11 +743,8 @@ class UsersController < ApplicationController c = Course.find(@msg.course_id) cs.send_wechat_join_class_notice apply_user,c,7,1 end - - end - respond_to do |format| - format.js end + redirect_to settings_course_path(@msg.course_id, :tab => 'member') end # 处理资源引用请求 @@ -1710,7 +1729,7 @@ class UsersController < ApplicationController # end # end @state = false - render :layout=>'new_base_user' + render :layout => 'edu_new_base_user' end #给某人留言 @@ -2107,15 +2126,24 @@ class UsersController < ApplicationController fan_query = @user.watcher_users; @user_fanlist_count = fan_query.count(); @user_fanlist = fan_query.order("#{Watcher.table_name}.id desc").limit(12); - @courses = @user.courses.visible.not_deleted + @courses = @user.courses.visible.not_deleted_not_end @courses_count = @courses.count - @courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc").limit(8) + @courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") + @limit = 8 + @is_remote = true + @courses_pages = Paginator.new @courses_count, @limit, params['page'] || 1 + @offset ||= @courses_pages.offset + @courses = paginateHelper @courses, @limit + if @user == User.current @shixuns = @user.shixuns else @shixuns = @user.shixuns.where(:authentication => 1) end @shixuns_count = @shixuns.count + @shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1 + @offset ||= @shixuns_pages.offset + @shixuns = paginateHelper @shixuns, @limit # if User.current == @user # # 点击小铃铛,更新点击时间 # update_onclick_time if params[:click_user_message] == 'true' diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index b5c8ce236..119c3c920 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -234,7 +234,14 @@ module ApiHelper updateAtValue = timeIntoFormat.to_s + "年" end updateAtValue + end + # 计算到结束还有多长时间 **天**小时**分 + def how_much_time time + result = "" + result = ((time - Time.now.to_i).to_i / (24*60*60)).to_s + " 天 " + result += (((time - Time.now.to_i).to_i % (24*60*60)) / (60*60)).to_s + " 小时 " + result += ((((time - Time.now.to_i).to_i % (24*60*60)) % (60*60)) / 60).to_s + " 分 " end #日期转换为时间 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 117962aca..e499a01ea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,6 +33,21 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter + # 判断用户是否认证 + def check_authentication + # return true + # if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载 + # return true + # end + authentication = ApplyAction.where(:user_id => User.current.id, :status => 1).first + user_identity = User.current.try(:user_extensions).try(:identity) + if user_identity.blank? || authentication.blank? + redirect_to my_account_path + return + end + end + + # 积分表中建立记录行为,有过奖励则不重复奖励 def reward_grade(user, container_id, container_type, score) grade = Grade.where(:user_id => user.id, :container_id => container_id, :container_type => container_type).first @@ -253,7 +268,7 @@ module ApplicationHelper res = JSON.parse(res) rescue => e logger.error("failed to create challenge by 'generatePipelineScriptForChallenge'! #{e}") - raise("实训云平台繁忙(繁忙等级:84") + raise("实训云平台繁忙(繁忙等级:84)") end end @@ -306,6 +321,10 @@ module ApplicationHelper style = 'edu-filter-btn-green' when '已结束' style = 'edu-filter-btn' + when '已开启补交' + style = 'edu-filter-btn-late' + when '未开启补交' + style = 'edu-filter-btn-no-late' end end @@ -337,51 +356,34 @@ module ApplicationHelper case ho_detail_manual.comment_status when 0 status = "挂起" - if homework_common.publish_time && homework_common.publish_time > Time.now - time = time_from_future(homework_common.publish_time).to_s + "后发布" - end when 1 - status = "提交中" if homework_common.end_time && homework_common.end_time >= Time.now - time = time_from_future(homework_common.end_time).to_s + "后结束" - elsif homework_common.anonymous_comment == 0 && ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now - status = "匿评中" - time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始" - elsif homework_common.archive_time && homework_common.archive_time >= Time.now - status = "评阅中" - time = time_from_future(homework_common.archive_time).to_s + "后结束" - end - when 2 - status = "补交中" - if homework_common.late_time && homework_common.late_time >= Time.now - time = time_from_future(homework_common.late_time).to_s + "后结束" - elsif homework_common.anonymous_comment == 0 && ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now - status = "匿评中" - time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始" - elsif homework_common.archive_time && homework_common.archive_time >= Time.now - status = "评阅中" - time = time_from_future(homework_common.archive_time).to_s + "后结束" + status = "提交中" + time = how_much_time(homework_common.end_time) end when 3 - status = "匿评中" if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now - time = time_from_future(ho_detail_manual.evaluation_end).to_s + "后结束" + status = "匿评中" + time = how_much_time(ho_detail_manual.evaluation_end) end when 4 - status = "申诉中" if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now - time = time_from_future(ho_detail_manual.appeal_time).to_s + "后结束" + status = "申诉中" + time = how_much_time(ho_detail_manual.appeal_time) end when 5 - status = "评阅中" if homework_common.archive_time && homework_common.archive_time > Time.now - time = time_from_future(homework_common.archive_time).to_s + "后结束" + status = "评阅中" + time = how_much_time(homework_common.archive_time) end when 6 status = "已结束" time = format_time homework_common.archive_time end end + if status == "" && homework_common.allow_late && homework_common.archive_time > Time.now + time = how_much_time homework_common.archive_time + end result[:status] = status result[:time] = time result @@ -1773,6 +1775,8 @@ module ApplicationHelper title << "酷得网 - 互联网教学实训平台" elsif @course title << (@course.name.nil? ? "智能课堂" : @course.name) + elsif params[:controller] == "homework_bank" + title << ("智能课堂") elsif params[:controller] == "courses" && params[:action] == "index" title << ("智能课堂") elsif @contest @@ -2806,6 +2810,20 @@ module ApplicationHelper end end + def identity_authentication_status user_id + apply = ApplyUserAuthentication.where(:user_id => user_id).first + case apply.try(:status) + when nil + "未认证" + when 0 + "等待认证审批" + when 1 + "认证已通过" + when 2 + "认证被拒绝" + end + end + def date_format_local(time) date = time.strftime("%Y年%m月%d日") end @@ -3554,10 +3572,10 @@ module ApplicationHelper if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey homepagePostSubmit',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' else - link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue' + link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue homepagePostSubmit' end elsif work.nil? && homework.end_time < Time.now - if homework.allow_late + if homework.allow_late && homework.homework_detail_manual.comment_status < 6 if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey homepagePostSubmit',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品' else @@ -4553,19 +4571,18 @@ end def add_to_homework_bank_f homework homework_bank = HomeworkBank.new(:name => homework.name, :description => homework.description, :user_id => homework.user_id, :homework_type => homework.homework_type, - :quotes => 1, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id) + :quotes => 1, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id, + :reference_answer => homework.reference_answer, :syllabus_id => homework.course.syllabus_id) if homework.homework_type == 2 && homework.homework_detail_programing homework_bank.language = homework.homework_detail_programing.language homework.homework_tests.each_with_index do |homework_test| homework_bank.homework_bank_tests << HomeworkBankTest.new( - test_type: 1, input: homework_test.input, output: homework_test.output ) end homework.homework_samples.each_with_index do |homework_test| - homework_bank.homework_bank_tests << HomeworkBankTest.new( - test_type: 0, + homework_bank.homework_bank_samples << HomeworkBankSample.new( input: homework_test.input, output: homework_test.output ) @@ -4848,3 +4865,75 @@ def set_final_score homework,student_work end end + +def quote_resource_bank resource, course + atta = Attachment.new(:filename => resource.filename, :disk_filename => resource.disk_filename, :filesize => resource.filesize, :digest => resource.digest, :downloads => 0, :is_publish => 0, + :author_id => User.current.id, :description => resource.description, :disk_directory => resource.disk_directory, :is_public => 0, :copy_from => resource.copy_from.nil? ? resource.id : resource.copy_from, + :quotes => 0, :resource_bank_id => resource.id, :created_on => Time.now, :content_type =>resource.content_type) + if course.attachments << atta + # 更新引用次数 + quotes = resource.quotes.to_i + 1 + resource.update_attribute(:quotes, quotes) + end +end + +def quote_homework_bank homework, course + new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 0, + :course_id => course.id, :teacher_priority => 1, :anonymous_comment => 1, :quotes => 0, :is_open => 0, :homework_bank_id => homework.id, :score_open => 1, + :anonymous_appeal => 0, :is_public => 0, :reference_answer => homework.reference_answer, :answer_public => 1, :allow_late => 1) + + new_homework.homework_detail_manual = HomeworkDetailManual.new + new_homework_detail_manual = new_homework.homework_detail_manual + new_homework_detail_manual.te_proportion = 1.0 + new_homework_detail_manual.ta_proportion = 0 + new_homework_detail_manual.comment_status = 0 + + new_homework_detail_manual.evaluation_num = 0 + new_homework_detail_manual.absence_penalty = 0 + + if new_homework.homework_type == 2 + new_homework.homework_detail_programing = HomeworkDetailPrograming.new + new_homework.homework_detail_programing.ta_proportion = 0 + new_homework.homework_detail_programing.language = homework.language + homework.homework_bank_tests.each_with_index do |homework_test| + new_homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) + end + homework.homework_bank_samples.each_with_index do |homework_test| + new_homework.homework_samples << HomeworkSample.new( + input: homework_test.input, + output: homework_test.output + ) + end + end + + if new_homework.homework_type == 3 + new_homework.homework_detail_group = HomeworkDetailGroup.new + new_homework.homework_detail_group.min_num = homework.min_num + new_homework.homework_detail_group.max_num = homework.max_num + new_homework.homework_detail_group.base_on_project = homework.base_on_project + end + + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.author_id = homework.user_id + att.copy_from = attachment.id + att.save + new_homework.attachments << att + end + + if new_homework.save + if new_homework.homework_type == 4 + HomeworkCommonsShixuns.create(:homework_common_id => new_homework.id, :shixun_id => homework.homework_bank_shixun.shixun_id) + end + new_homework_detail_manual.save if new_homework_detail_manual + new_homework.homework_detail_programing.save if new_homework.homework_detail_programing + new_homework.homework_detail_group.save if new_homework.homework_detail_group + homework.update_column(:quotes, homework.quotes+1) + end +end + diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 1e9adaf37..9d9415e0e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -90,7 +90,7 @@ module CoursesHelper #生成课程学生列表连接 def course_student_link student_num if User.current.allowed_to?(:as_teacher, @course) - link_to "#{student_num}", settings_course_path(@course, :tab => 'member', :role => 'as'), :class => 'mr5 link-color-blue', :id => 'teacher_number' + link_to "#{student_num}", settings_course_path(@course, :tab => 'member', :role => 'as'), :class => 'mr5 link-color-blue', :id => 'student_number' elsif (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) link_to "#{student_num}", course_member_path(@course, :role => 'as'), :class => 'mr5 link-color-blue', :id => "student_number" else @@ -101,9 +101,9 @@ module CoursesHelper # 生成分班列表连接 def course_group_link group_num if User.current.allowed_to?(:as_teacher, @course) - link_to "#{group_num}", settings_course_path(@course, :tab => 'member', :role => @course.course_groups.first.id), :class => 'mr5 link-color-blue', :id => 'teacher_number' + link_to "#{group_num}", settings_course_path(@course, :tab => 'member', :role => @course.course_groups.first.id), :class => 'mr5 link-color-blue', :id => 'group_number' elsif (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) - link_to "#{group_num}", course_member_path(@course, :role => @course.course_groups.first.id), :class => 'sy_cblue', :id => "student_number" + link_to "#{group_num}", course_member_path(@course, :role => @course.course_groups.first.id), :class => 'mr5 link-color-blue', :id => "group_number" else content_tag 'span',group_num, :class => 'sy_cblue' end diff --git a/app/helpers/homework_bank_helper.rb b/app/helpers/homework_bank_helper.rb new file mode 100644 index 000000000..fbb669ff3 --- /dev/null +++ b/app/helpers/homework_bank_helper.rb @@ -0,0 +1,2 @@ +module HomeworkBankHelper +end diff --git a/app/helpers/management_helper.rb b/app/helpers/management_helper.rb new file mode 100644 index 000000000..d07e930fe --- /dev/null +++ b/app/helpers/management_helper.rb @@ -0,0 +1,2 @@ +module ManagementHelper +end diff --git a/app/helpers/managements_helper.rb b/app/helpers/managements_helper.rb new file mode 100644 index 000000000..6c97b5512 --- /dev/null +++ b/app/helpers/managements_helper.rb @@ -0,0 +1,15 @@ +module ManagementsHelper + + def trial_authorization_status status + case status + when "0", nil + 0 + when "1" + 1 + when "2" + 2 + else + [1,2] + end + end +end diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index 56512afcf..9124a4f98 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -14,4 +14,5 @@ module OwnerTypeHelper CONTEST = 13 HOMEWORKREFERENCEANSWER = 14 STUDENTWORK = 15 + HOMEWORKBANK = 16 end \ No newline at end of file diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 61b4ff8cd..0416e72b7 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -100,7 +100,7 @@ module StudentWorkHelper if work.nil? && homework.end_time >= Time.now link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr' elsif work.nil? && homework.end_time < Time.now - if homework.allow_late + if homework.allow_late && homework.homework_detail_manual.comment_status < 6 link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr' end elsif work diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb index 70f865ef5..3cf56b047 100644 --- a/app/helpers/syllabuses_helper.rb +++ b/app/helpers/syllabuses_helper.rb @@ -131,60 +131,4 @@ module SyllabusesHelper content end - def quote_resource_bank resource, course - atta = Attachment.new(:filename => resource.filename, :disk_filename => resource.disk_filename, :filesize => resource.filesize, :digest => resource.digest, :downloads => 0, :is_publish => 0, - :author_id => User.current.id, :description => resource.description, :disk_directory => resource.disk_directory, :is_public => 0, :copy_from => resource.copy_from.nil? ? resource.id : resource.copy_from, - :quotes => 0, :resource_bank_id => resource.id, :created_on => Time.now, :content_type =>resource.content_type) - if course.attachments << atta - # 更新引用次数 - quotes = resource.quotes.to_i + 1 - resource.update_attribute(:quotes, quotes) - end - end - - def quote_homework_bank homework, course - new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 0, - :course_id => course.id, :teacher_priority => 1, :anonymous_comment => 1, :quotes => 0, :is_open => 0, - :homework_bank_id => homework.id, :score_open => 1, :anonymous_appeal => 0) - - new_homework.homework_detail_manual = HomeworkDetailManual.new - new_homework_detail_manual = new_homework.homework_detail_manual - new_homework_detail_manual.ta_proportion = new_homework.homework_type == 2 ? 0.4 : 1.0 - new_homework_detail_manual.comment_status = 0 - new_homework_detail_manual.evaluation_num = 3 - new_homework_detail_manual.absence_penalty = 0 - - if new_homework.homework_type == 2 - new_homework.homework_detail_programing = HomeworkDetailPrograming.new - new_homework.homework_detail_programing.ta_proportion = 0.6 - new_homework.homework_detail_programing.language = homework.language - homework.homework_bank_tests.each_with_index do |homework_test| - if homework_test.test_type - new_homework.homework_tests << HomeworkTest.new( - input: homework_test.input, - output: homework_test.output - ) - else - new_homework.homework_samples << HomeworkSample.new( - input: homework_test.input, - output: homework_test.output - ) - end - end - end - - if new_homework.homework_type == 3 - new_homework.homework_detail_group = HomeworkDetailGroup.new - new_homework.homework_detail_group.min_num = homework.min_num - new_homework.homework_detail_group.max_num = homework.max_num - new_homework.homework_detail_group.base_on_project = homework.base_on_project - end - - if new_homework.save - new_homework_detail_manual.save if new_homework_detail_manual - new_homework.homework_detail_programing.save if new_homework.homework_detail_programing - new_homework.homework_detail_group.save if new_homework.homework_detail_group - homework.update_column(:quotes, homework.quotes+1) - end - end end diff --git a/app/models/apply_action.rb b/app/models/apply_action.rb new file mode 100644 index 000000000..a940ada38 --- /dev/null +++ b/app/models/apply_action.rb @@ -0,0 +1,6 @@ +# status:0 审核中 1 同意 2 拒绝 +class ApplyAction < ActiveRecord::Base + attr_accessible :container_id, :container_type, :dealer_id, :reason, :user_id, :status + + belongs_to :user +end diff --git a/app/models/course.rb b/app/models/course.rb index f2172f419..96e7f2606 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -109,7 +109,7 @@ class Course < ActiveRecord::Base acts_as_customizable scope :not_deleted, lambda{where(is_delete: 0)} - scope :not_deleted_not_end, lambda{where(is_delete: 0, is_end: 1)} + scope :not_deleted_not_end, lambda{where(is_delete: 0, is_end: 0)} scope :not_deleted_but_is_end, lambda{where(is_end: 1, is_delete: 0)} scope :all_course scope :active, lambda { where(:status => STATUS_ACTIVE) } diff --git a/app/models/homework_bank.rb b/app/models/homework_bank.rb index 0f89c74d9..6cd699bbd 100644 --- a/app/models/homework_bank.rb +++ b/app/models/homework_bank.rb @@ -2,7 +2,11 @@ class HomeworkBank < ActiveRecord::Base # attr_accessible :title, :body belongs_to :user - has_many :homework_bank_tests + belongs_to :syllabus + has_many :homework_bank_tests, :dependent => :destroy + has_many :homework_bank_samples, :dependent => :destroy + has_many :homework_commons + has_one :homework_bank_shixun acts_as_attachable def language_name diff --git a/app/models/homework_bank_sample.rb b/app/models/homework_bank_sample.rb new file mode 100644 index 000000000..7b64f93a9 --- /dev/null +++ b/app/models/homework_bank_sample.rb @@ -0,0 +1,4 @@ +class HomeworkBankSample < ActiveRecord::Base + belongs_to :homework_bank + attr_accessible :input, :output, :homework_bank_id +end diff --git a/app/models/homework_bank_shixun.rb b/app/models/homework_bank_shixun.rb new file mode 100644 index 000000000..3bec23fcd --- /dev/null +++ b/app/models/homework_bank_shixun.rb @@ -0,0 +1,5 @@ +class HomeworkBankShixun < ActiveRecord::Base + belongs_to :homework_bank + belongs_to :shixun + attr_accessible :homework_bank_id, :shixun_id +end diff --git a/app/models/shixun.rb b/app/models/shixun.rb index ab18f7410..cbc995895 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,6 +1,7 @@ # status 控制实训的状态,0:未开启;1: 已开启(TPM); 2:已认证 -# 繁忙等级参数:80发布实训失败,返回code为-1;81:实训开启的时候fork失败;83:job创建失败;84:jenkins系统异常,post数据不成功 +# 繁忙等级参数:80发布实训失败,返回code为-1;81:实训开启的时候fork失败;83:j ;84:jenkins系统异常,post数据不成功 # 85:challenge创建的时候Jenkins处理异常;86:实训评测失败,jenkins返回错误结果; 87:版本库删除异常;88:点击评测失败,没返回数据;89:重置链接jenkins返回失败 +# 116:challenge创建关卡的时候返回结果错误 class Shixun < ActiveRecord::Base attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :myshixun_count, :propaedeutics diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 80d24ba5a..42af92576 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -20,6 +20,7 @@ class Syllabus < ActiveRecord::Base belongs_to :user has_many :courses + has_many :homework_banks has_many :reference_materials, :dependent => :destroy has_many :syllabus_update_records, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 8b0361a2a..676e57835 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -200,6 +200,9 @@ class User < Principal ##### has_many :shares ,:dependent => :destroy + ### + has_many :apply_actions, :dependent => :destroy + has_one :user_wechat has_one :sso diff --git a/app/views/account/_has_authentication.html.erb b/app/views/account/_has_authentication.html.erb index 4244df0c5..f42f6ca6b 100644 --- a/app/views/account/_has_authentication.html.erb +++ b/app/views/account/_has_authentication.html.erb @@ -5,7 +5,7 @@ 已认证 <% end %> -<% if !@user.authentication && @apply_user_auth && @apply_user_auth.status == 0 %> +<% if false %> <%= render :partial => "welcome/one_btn_mask_pop", :locals => { :tip1 => "更多功能,需要经过管理员的授权审核", diff --git a/app/views/account/apply_trail.js.erb b/app/views/account/apply_trail.js.erb new file mode 100644 index 000000000..0b921b7c3 --- /dev/null +++ b/app/views/account/apply_trail.js.erb @@ -0,0 +1 @@ +$("body").append('<%= j( render :partial => 'welcome/one_btn_mask_pop', :locals => {:btn => "确定", :tip1 => "申请成功,我们将在一个工作日内完成审核", :url => "javascript:void(0);"}) %>'); \ No newline at end of file diff --git a/app/views/account/avatar.html.erb b/app/views/account/avatar.html.erb index b159f1122..c4cc39be3 100644 --- a/app/views/account/avatar.html.erb +++ b/app/views/account/avatar.html.erb @@ -141,11 +141,10 @@ if (o.status !=0 ){ console.log(o.message); } else { - long_notice_box("上传成功"); - window.location.reload(); + notice_box_redirect('<%= avatar_account_path() %>' ,"上传成功"); } } else { - long_notice_box("上传出错"); + notice_box("上传出错"); } }, diff --git a/app/views/account/lost_password.html.erb b/app/views/account/lost_password.html.erb index d94f41c44..308d150f9 100644 --- a/app/views/account/lost_password.html.erb +++ b/app/views/account/lost_password.html.erb @@ -3,8 +3,8 @@

找回密码

<%= link_to '首页', home_path %> - | - <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> + + <%#= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %>

diff --git a/app/views/account/user_join.html.erb b/app/views/account/user_join.html.erb index 9f4dc8e44..8ee3c2c98 100644 --- a/app/views/account/user_join.html.erb +++ b/app/views/account/user_join.html.erb @@ -76,7 +76,7 @@
-

+
<% end %>
diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb index 6d3264a22..958c32124 100644 --- a/app/views/blog_comments/quote.js.erb +++ b/app/views/blog_comments/quote.js.erb @@ -1,8 +1,9 @@ -if($("#reply_message_<%= @blogComment.id%>").length > 0) { +if($("#reply_message_<%= @blogComment.id%>").html() == "") { + $(".reply_to_message").html(""); $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'blog_comments/simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:course_id=>@course_id}) %>"); $(function(){ sd_create_editor_from_data(<%= @blogComment.id%>,null,"100%", "<%=@blogComment.class.to_s%>"); }); -}else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { - $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

"); +}else { + $("#reply_message_<%= @reply.id%>").html(""); } \ No newline at end of file diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 6d3fb5f56..bfbf1c82a 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -24,7 +24,7 @@ <% end %> <% if User.current.manager_of_shixun?(@shixun) %> -

+

<% unless challenge.position < 2 %> <% end %> diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index be105c45b..841c5a950 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -28,7 +28,11 @@ toolbarIcons : function() { // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "image", "code", "code-block", "|", "table", "watch", "clear"] + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + toolbarCustomIcons : { + testIcon : "

", + testIcon1 : "
" }, //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 saveHTMLToTextarea : true, @@ -50,7 +54,11 @@ toolbarIcons : function() { // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "image", "code", "code-block", "|", "table", "watch", "clear"] + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + toolbarCustomIcons : { + testIcon : "
", + testIcon1 : "
" }, //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 saveHTMLToTextarea : true, @@ -61,7 +69,6 @@ imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url }); - }); @@ -108,6 +115,12 @@ <%= select_tag :evaluation_way, options_for_select([["输入输出", 1]]), :name => 'challenge[evaluation_way]', :class => " fl", :style => "height: 40px; width:200px;" %> 请选择自动检测学员是否完成本任务的评测标准 +
  • <% if params[:action] == "edit" && @challenge.test_sets.count > 0 %> @@ -154,7 +167,7 @@ <% end %>
  • - +
    <% if params[:action] == "edit" && @challenge_tags.count > 0 %> <% @challenge_tags.each do |tag| %> @@ -309,6 +322,44 @@ }); }); + + window.onload = function(){ + $("#challenge_task_pass [type=\"latex\"]").bind("click", function(){ + taskpass_editormd.cm.replaceSelection("```latex"); + taskpass_editormd.cm.replaceSelection("\n"); + taskpass_editormd.cm.replaceSelection("\n"); + taskpass_editormd.cm.replaceSelection("```"); + var __Cursor = taskpass_editormd.cm.getDoc().getCursor(); + taskpass_editormd.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#challenge_answer [type=\"latex\"]").bind("click", function(){ + taskanswer_editormd.cm.replaceSelection("```latex"); + taskanswer_editormd.cm.replaceSelection("\n"); + taskanswer_editormd.cm.replaceSelection("\n"); + taskanswer_editormd.cm.replaceSelection("```"); + var __Cursor = taskanswer_editormd.cm.getDoc().getCursor(); + taskanswer_editormd.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#challenge_task_pass [type=\"inline\"]").bind("click", function(){ + taskpass_editormd.cm.replaceSelection("$$$$"); + var __Cursor = taskpass_editormd.cm.getDoc().getCursor(); + taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2); + taskpass_editormd.cm.focus(); + }); + + $("#challenge_answer [type=\"inline\"]").bind("click", function(){ + taskanswer_editormd.cm.replaceSelection("$$$$"); + var __Cursor = taskanswer_editormd.cm.getDoc().getCursor(); + taskanswer_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2); + taskanswer_editormd.cm.focus(); + }); + $("[type=\"inline\"]").attr("title", "行内公式"); + $("[type=\"latex\"]").attr("title", "多行公式"); + + } + // 设置textarea的宽度到140以后出现滚动条 var test_set_inputs = document.getElementsByName("test_set[input][]"); var test_set_outputs = document.getElementsByName("test_set[output][]"); diff --git a/app/views/challenges/index.html.erb b/app/views/challenges/index.html.erb index 66aac37e8..2591ec020 100644 --- a/app/views/challenges/index.html.erb +++ b/app/views/challenges/index.html.erb @@ -1,4 +1,4 @@ -<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min' %> +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> <%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js', '/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js'%>
    @@ -10,11 +11,8 @@ \ No newline at end of file diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index e16bb9f42..2e7fb1d0c 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -81,7 +81,7 @@
    • 公开测试:/
    • 隐藏测试:/
    • -
    • 经验值:+
    • +
    • 经验值:+
    @@ -115,6 +115,7 @@ } ); $("#game_test_set_results").html(html); + $("#blacktab_nav_1").trigger("click"); }); // 公开的测试集允许展开与隐藏 function toggle_test_case(t_case, id){ @@ -130,4 +131,13 @@ $("#test_case_"+id).toggle(); } } + function g_new(o){return document.getElementById(o);} + function HoverLi(n){ + for(var i=1;i<=2;i++){ + g_new('blacktab_nav_'+i).className='blacktab_nomal'; + g_new('blacktab_con_'+i).className='undis'; + } + g_new('blacktab_con_'+n).className='dis'; + g_new('blacktab_nav_'+n).className='blacktab_hover'; + } \ No newline at end of file diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 720bad0cd..bf3c22ad7 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -28,7 +28,7 @@
    -
    +
    @@ -37,7 +37,7 @@
    -
    +
    diff --git a/app/views/games/minus_score.js.erb b/app/views/games/minus_score.js.erb index e538521ec..f3954a75e 100644 --- a/app/views/games/minus_score.js.erb +++ b/app/views/games/minus_score.js.erb @@ -1,5 +1,6 @@ $("#myshixun_top").html('<%= escape_javascript(render :partial => 'myshixuns/myshixun_top') %>'); $("#tab_con_3").html('<%= j (render :partial => 'games/acquire_answer') %>'); +$("#experience_value").html("+ 0"); $("#tab_nav_1").removeClass('tab_hover'); $("#tab_nav_2").removeClass('tab_hover'); $("#tab_nav_3").addClass('tab_hover'); diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 8c0c8ba8d..d096af2dc 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/javascript-hint" %> +<%= javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/javascript-hint", "/codemirror/addon/selection/active-line", "/codemirror/addon/lint/javascript-lint", "/codemirror/addon/lint/css-lint", "/codemirror/addon/lint/lint", "/codemirror/addon/lint/json-lint", "/editormd/lib/codemirror/addon/lint/css-lint" %> <%= stylesheet_link_tag "/codemirror/lib/codemirror" %> <%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> <%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js', diff --git a/app/views/homework_bank/_homework_bank_list.html.erb b/app/views/homework_bank/_homework_bank_list.html.erb new file mode 100644 index 000000000..5e9dba874 --- /dev/null +++ b/app/views/homework_bank/_homework_bank_list.html.erb @@ -0,0 +1,84 @@ +
    +
    + + +
    +
    +

    <%= @hw_count %>个搜索结果

    + <%= link_to '引用次数排序', homework_bank_index_path(:type => @type, :order => "quotes", :search => @search, :sort => @r_sort, :property=>@property), :class => "fr mr15 #{@order == 'quotes' ? 'color-blue' : ''}", :remote => true %> + | + <%= link_to '更新时间排序', homework_bank_index_path(:type => @type, :order => "updated_at", :search => @search, :sort => @r_sort, :property=>@property), :class => "fr #{@order == 'updated_at' ? 'color-blue' : ''}", :remote => true %> +
    +
    +

    + <%= link_to '全部', homework_bank_index_path(:type => @type), :class => 'edu-filter-cir-grey mr5 active', :id => 'homework_bank_pro_0', :remote => true %> + <%= link_to '编程', homework_bank_index_path(:type => @type, :property => 2), :class => 'edu-filter-cir-grey mr5', :id => 'homework_bank_pro_2', :remote => true %> + <%= link_to '普通', homework_bank_index_path(:type => @type, :property => 1), :class => 'edu-filter-cir-grey mr5', :id => 'homework_bank_pro_1', :remote => true %> + <%= link_to '分组', homework_bank_index_path(:type => @type, :property => 3), :class => 'edu-filter-cir-grey mr5', :id => 'homework_bank_pro_3', :remote => true %> + <%= link_to '实训', homework_bank_index_path(:type => @type, :property => 4), :class => 'edu-filter-cir-grey mr5', :id => 'homework_bank_pro_4', :remote => true %> + <%#= link_to '试卷', homework_bank_path(:type => @type, :property => 5), :class => 'edu-filter-cir-grey mr5', :remote => true %> +

    + 新建 +
    +
    +
    + <% if @hw_count != 0 %> + <%= form_tag(choose_user_course_homework_bank_index_path(), :id => 'hb_search_course_h_form', :remote => true, :method => 'post') do %> + <% @homeworks.each do |homework| %> +
    +
    + + + <%= link_to homework.name, homework_bank_path(homework.id), :class => 'edu-class-inner-list fl ml25', :target => '_blank' %> + <% unless homework.is_public %> + + <% end %> +
    +

    + 更新于<%= time_from_now homework.updated_at %> + <%= homework.quotes %> 次引用 + <%= StudentWork.where(:is_delete => 0, :work_status => [1, 2, 3], :homework_common_id => homework.homework_commons.map(&:id)).count %> 次答题 + <% if homework.syllabus_id && homework.syllabus.major_level %> + <% syllabus = homework.syllabus %> + + <%= syllabus.syllabus_major_level %> - <%= syllabus.syllabus_discipline_category %> - <%= syllabus.syllabus_first_level_discipline %> - <%= syllabus.title %> + + <% end %> +

    +
    +
    + +
      +
    • <%= link_to '预览', homework_bank_path(homework), :target => '_blank' %>
    • +
    • <%= link_to '发送', choose_user_course_homework_bank_index_path(:check_homework_bank => ["#{homework.id}"]), :remote => true %>
    • + <% if @type.to_i == 1 %> +
    • 删除
    • + <% end %> +
    +
    +
    + <% end %> + <% end %> + <% else %> + <%= render :partial => 'welcome/no_data' %> + <% end %> +
    + +
      + + +
      + 发送 + <% if @type.to_i == 1 %> + 删除 + <% end %> + +
      +
      +
        + <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true%> +
      +
      +
      +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/_hw_search_course_list.html.erb b/app/views/homework_bank/_hw_search_course_list.html.erb new file mode 100644 index 000000000..7c00061d9 --- /dev/null +++ b/app/views/homework_bank/_hw_search_course_list.html.erb @@ -0,0 +1,12 @@ +<% if @courses.count > 0 %> + <% @courses.each do |course| %> +
  • + +
  • + <% end %> +<% else %> + +<% end %> diff --git a/app/views/homework_bank/_new_common_homework.html.erb b/app/views/homework_bank/_new_common_homework.html.erb new file mode 100644 index 000000000..2f82919a8 --- /dev/null +++ b/app/views/homework_bank/_new_common_homework.html.erb @@ -0,0 +1,77 @@ +
    +

    <%= edit_mode ? '编辑' : '新建' %>普通作业

    +
    +
    + + 有3 处问题导致无法保存 + +
    +
    +
    +
    +
      + +
    • + + <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@homework.syllabus_id), {:id=>"new_syllabus_id", :class=>"fl task-height-40 task-form-30"} %> +
      +
      + + +

      课程列表中没有?<%= link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'color-blue' %>

      +
      +
      +
      +
    • +
    • + + +
    • +
    • + + <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> + + <%= f.kindeditor :description, :editor_id => 'homework_description_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_content', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @homework} %> +
    • + +
    • + + + <%= f.kindeditor :reference_answer, :editor_id => 'homework_ref_answer_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_ref_answer', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + 保存 + <% if edit_mode %> + <%= link_to '取消', homework_bank_path(@homework), :class => 'task-btn fr mr10' %> + <% else %> + <%= link_to '取消', homework_bank_index_path(), :class => 'task-btn fr mr10' %> + <% end %> +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/_new_group_homework.html.erb b/app/views/homework_bank/_new_group_homework.html.erb new file mode 100644 index 000000000..7e3a4523f --- /dev/null +++ b/app/views/homework_bank/_new_group_homework.html.erb @@ -0,0 +1,93 @@ +<% not_allow_select = edit_mode && @homework.student_works.has_committed.count != 0 %> + +
    +

    <%= edit_mode ? '编辑' : '新建' %>分组作业

    +
    +
    + + 有3 处问题导致无法保存 + +
    +
    +
    +
    +
      + +
    • + + <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@homework.syllabus_id), {:id=>"new_syllabus_id", :class=>"fl task-height-40 task-form-30"} %> +
      +
      + + +

      课程列表中没有?<%= link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'color-blue' %>

      +
      +
      +
      +
    • +
    • + + +
    • +
    • + + <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> + + <%= f.kindeditor :description, :editor_id => 'homework_description_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_content', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @homework} %> +
    • +
    • + +
        +
      • + 每组最小人数 + + 每组最大人数 + + + 已有学生提交作品,只能扩大分组范围,原分组人数为<%= @homework.min_num %>-<%= @homework.max_num %>人 + +
      • + 注:任一成员都可以提交作品,提交作品时需要关联同组成员,组内成员作品共享。 +
      +
    • +
    • + + + <%= f.kindeditor :reference_answer, :editor_id => 'homework_ref_answer_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_ref_answer', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + 保存 + <% if edit_mode %> + <%= link_to '取消', homework_bank_path(@homework), :class => 'task-btn fr mr10' %> + <% else %> + <%= link_to '取消', homework_bank_index_path(), :class => 'task-btn fr mr10' %> + <% end %> +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/_new_program_homework.html.erb b/app/views/homework_bank/_new_program_homework.html.erb new file mode 100644 index 000000000..c6f6ad623 --- /dev/null +++ b/app/views/homework_bank/_new_program_homework.html.erb @@ -0,0 +1,170 @@ +
    +

    <%= edit_mode ? '编辑' : '新建' %>编程作业

    +
    +
    + + 有3 处问题导致无法保存 + +
    +
    +
    +
    +
      + +
    • + + <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@homework.syllabus_id), {:id=>"new_syllabus_id", :class=>"fl task-height-40 task-form-30"} %> +
      +
      + + +

      课程列表中没有?<%= link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'color-blue' %>

      +
      +
      +
      +
    • +
    • + + +
    • +
    • + + <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> + + <%= f.kindeditor :description, :editor_id => 'homework_description_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_content', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @homework} %> +
    • +
    • + +
        + <% if edit_mode && @homework.homework_bank_samples.count > 0 %> + <% @homework.homework_bank_samples.each_with_index do |sample, index| %> +
      • +

        + 样例<%= index + 1 %> + + <% if index != 0 %> + + <% else %> + 温馨提示:请至少输入一组样例供学生参考。 + <% end %> +

        + + +
      • + <% end %> + <% else %> +
      • +

        + 样例1 + + 温馨提示:请至少输入一组样例供学生参考。 +

        + + +
      • + <% end %> +
      +
    • +
    • + +
        +
      • +

        + + 温馨提示:您可以在发布后,通过"模拟答题"进行标准代码的检测。 +

        +
      • + <% if edit_mode %> + <% @homework.homework_bank_tests.each_with_index do |test, index| %> +
      • +

        + 测试<%= index + 1 %> + + <% if index != 0 %> + + <% end %> +

        + + +
      • + <% end %> + <% else %> +
      • +

        + 测试1 + +

        + + +
      • + <% end %> +
      +
    • +
    • + + + <%= f.kindeditor :reference_answer, :editor_id => 'homework_ref_answer_editor', + :owner_id => @homework.nil? ? 0: @homework.id, + :owner_type => OwnerTypeHelper::HOMEWORKBANK, + :width => '89.7%', + :height => 200, + :minHeight=>200, + :class => 'talk_text fl', + :input_html => { :id => 'homework_ref_answer', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
    • +
    • + 保存 + <% if edit_mode %> + <%= link_to '取消', homework_bank_path(@homework), :class => 'task-btn fr mr10' %> + <% else %> + <%= link_to '取消', homework_bank_index_path(), :class => 'task-btn fr mr10' %> + <% end %> +
    • +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/views/homework_bank/_send_homework_bank.html.erb b/app/views/homework_bank/_send_homework_bank.html.erb new file mode 100644 index 000000000..5f7926f5d --- /dev/null +++ b/app/views/homework_bank/_send_homework_bank.html.erb @@ -0,0 +1,34 @@ +
    +
    +

    发送题库

    + +
    +
    +
    +
    + + 选择的题将会发送到指定班级 +
    +
    + + +
    + <%= form_tag(send_h_bank_to_course_homework_bank_index_path(), :id => 'send_hb_to_course_form', :remote => true, :method => 'post') do %> +
    + <% @homework_ids.each do |id| %> + + <% end %> +
      + <%= render :partial => 'homework_bank/hw_search_course_list' %> +
    +
    + <% end %> +
    + + 确定 + 取消 +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/_shixuns.html.erb b/app/views/homework_bank/_shixuns.html.erb new file mode 100644 index 000000000..1d6fba616 --- /dev/null +++ b/app/views/homework_bank/_shixuns.html.erb @@ -0,0 +1,52 @@ +
    +
    +

    选择实训

    + +
    +
    + <%= labelled_form_for @homework, :url =>{:controller=> 'homework_bank', :action => 'shixuns'}, :id => 'shixun_search_form', :method => "get", :remote => true do |f| %> +
    +
    + + +
    +
    + <% end %> + <%= labelled_form_for @homework, :url =>{:controller=> 'homework_bank', :action => 'create'}, :html => {:id => 'shixun_homework_bank_new'}, :method => "post" do |f| %> + + + + + + + + + 请至少选中一个实训 + + <% @shixuns.each do |shixun| %> + + + + + + <% end %> + +
    实训名称导师姓名学员数
    + + <%= link_to shixun.name, shixun_path(shixun), :class => "edu-info-dark task-hide fl" %> + <%= link_to shixun.owner.try(:show_name), user_path(shixun.owner), :class => "edu-txt-w140 task-hide" %><%= shixun.myshixuns.count %>
    + <% end %> +
    +
    + 选择 + 取消 +
    +
    +
      + <%= pagination_links_full @shixun_pages, @shixuns_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/choose_user_course.js.erb b/app/views/homework_bank/choose_user_course.js.erb new file mode 100644 index 000000000..678680b27 --- /dev/null +++ b/app/views/homework_bank/choose_user_course.js.erb @@ -0,0 +1,6 @@ +<% if params[:is_observe].nil? %> +var htmlvalue = "<%= escape_javascript(render :partial => 'homework_bank/send_homework_bank') %>"; +pop_box_new(htmlvalue, 452, 463); +<% else %> +$("#search_course_list").html("<%= escape_javascript(render :partial => 'homework_bank/hw_search_course_list') %>"); +<% end %> diff --git a/app/views/homework_bank/edit.html.erb b/app/views/homework_bank/edit.html.erb new file mode 100644 index 000000000..3249f77d4 --- /dev/null +++ b/app/views/homework_bank/edit.html.erb @@ -0,0 +1,18 @@ +<% content_for :header_tags do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> +
    +

    + + <%= link_to User.current.show_name, user_path(User.current) %> > <%= link_to '智能课堂', courses_path() %> > <%= link_to '我的题库', homework_bank_index_path() %> > 编辑 +

    + <%= form_for @homework, :html => {:id => 'homework_common_submit_form'} do |f| %> + <% if @homework_type == 1 %> + <%= render :partial => 'new_common_homework', :locals => {:f => f, :edit_mode => true} %> + <% elsif @homework_type == 2 %> + <%= render :partial => 'new_program_homework', :locals => {:f => f, :edit_mode => true} %> + <% elsif @homework_type == 3 %> + <%= render :partial => 'new_group_homework', :locals => {:f => f, :edit_mode => true} %> + <% end %> + <% end %> +
    \ No newline at end of file diff --git a/app/views/homework_bank/index.html.erb b/app/views/homework_bank/index.html.erb new file mode 100644 index 000000000..19b25fd40 --- /dev/null +++ b/app/views/homework_bank/index.html.erb @@ -0,0 +1,33 @@ + + +
    +

    <%= link_to User.current.show_name, user_path(User.current) %> > <%= link_to '智能课堂', courses_path() %> > 题库

    +
    +
    +
    + +
    +
    + <%= render :partial => 'homework_bank/homework_bank_list' %> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_bank/index.js.erb b/app/views/homework_bank/index.js.erb new file mode 100644 index 000000000..4aad8261b --- /dev/null +++ b/app/views/homework_bank/index.js.erb @@ -0,0 +1,20 @@ +$("#edu-tab-con-1").html("<%= j(render :partial => 'homework_bank/homework_bank_list') %>"); +<% if params[:property] %> +$(".edu-filter-cir-grey").removeClass("active"); +<% case params[:property].to_i %> +<% when 1 %> + $("#homework_bank_pro_1").addClass("active"); +<% when 2 %> + $("#homework_bank_pro_2").addClass("active"); +<% when 3 %> + $("#homework_bank_pro_3").addClass("active"); +<% when 4 %> + $("#homework_bank_pro_4").addClass("active"); +<% else %> + $("#homework_bank_pro_0").addClass("active"); +<% end %> +<% end %> +if(<%= params[:type] == '2' %>){ + $("#edu-tab-nav-1").removeClass("edu-new-tab-hover"); + $("#edu-tab-nav-2").addClass("edu-new-tab-hover"); +} \ No newline at end of file diff --git a/app/views/homework_bank/new.html.erb b/app/views/homework_bank/new.html.erb new file mode 100644 index 000000000..614a36255 --- /dev/null +++ b/app/views/homework_bank/new.html.erb @@ -0,0 +1,18 @@ +<% content_for :header_tags do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> +
    +

    + + <%= link_to User.current.show_name, user_path(User.current) %> > <%= link_to '智能课堂', courses_path() %> > <%= link_to '我的题库', homework_bank_index_path() %> > 新建 +

    + <%= labelled_form_for @homework, :url =>{:controller=>'homework_bank',:action => 'create'}, :html => {:id => 'homework_common_submit_form'}, :method => "post" do |f| %> + <% if @homework_type == 1 %> + <%= render :partial => 'new_common_homework', :locals => {:f => f, :edit_mode => false} %> + <% elsif @homework_type == 2 %> + <%= render :partial => 'new_program_homework', :locals => {:f => f, :edit_mode => false} %> + <% elsif @homework_type == 3 %> + <%= render :partial => 'new_group_homework', :locals => {:f => f, :edit_mode => false} %> + <% end %> + <% end %> +
    \ No newline at end of file diff --git a/app/views/homework_bank/send_h_bank_to_course.js.erb b/app/views/homework_bank/send_h_bank_to_course.js.erb new file mode 100644 index 000000000..cd9b51b7b --- /dev/null +++ b/app/views/homework_bank/send_h_bank_to_course.js.erb @@ -0,0 +1 @@ +yes_notice_box("已发送到目标班级的作业列表
    但需要您设置发布和截止时间,以激活相应作业,谢谢!"); \ No newline at end of file diff --git a/app/views/homework_bank/shixuns.js.erb b/app/views/homework_bank/shixuns.js.erb new file mode 100644 index 000000000..873e31a14 --- /dev/null +++ b/app/views/homework_bank/shixuns.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'homework_bank/shixuns') %>"; +pop_box_new(htmlvalue, 680, 454); \ No newline at end of file diff --git a/app/views/homework_bank/show.html.erb b/app/views/homework_bank/show.html.erb new file mode 100644 index 000000000..0d7f55496 --- /dev/null +++ b/app/views/homework_bank/show.html.erb @@ -0,0 +1,177 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> + <%= javascript_include_tag "resizeable_table" %> + <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> +<% end %> + + + +
    +

    + + <%= link_to User.current.show_name, user_path(User.current) %> > <%= link_to '智能课堂', courses_path() %> > <%= @homework.user == User.current ? link_to('我的题库', homework_bank_index_path()) : link_to('公共题库', homework_bank_index_path(:type => 2)) %>

    +
    +

    + <% unless @homework.is_public %> + + <% end %> + <%= @homework.name %> +

    + <%= link_to '返回', @homework.user == User.current ? homework_bank_index_path() : homework_bank_index_path(:type => 2), :class => 'fr font-12 mr15 mt3 link-color-grey' %> +
    +
    +
    +
    + +
    +
    +
    + <% if @is_admin %> +
    + +
      + <% if @homework.homework_type != 4 %> +
    • + <%= link_to l(:button_edit), edit_homework_bank_path(@homework) %> +
    • + <% end %> +
    • + <%= link_to '发送', choose_user_course_homework_bank_index_path(:check_homework_bank => ["#{@homework.id}"]), :remote => true %> +
    • + <% unless @homework.is_public %> +
    • + 设为公开 +
    • + <% end %> +
    • + 删除 +
    • +
    +
    + <% elsif @homework.is_public %> +
  • + <%= link_to '发送', choose_user_course_homework_bank_index_path(:check_homework_bank => ["#{@homework.id}"]), :remote => true %> +
  • + <% end %> +
    +
    + <%= @homework.description.html_safe %> +
    +
    +
      + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @homework} %> +
    + <% if @homework.homework_type == 3 %> +
    +
    +

    分组要求

    +
    +
    +

    分组人数: <%= @homework.min_num %> - <%= @homework.max_num %> 人

    + 注:任一成员都可以提交作品,提交作品时需要关联同组成员,组内成员作品共享。 +
    +
    + <% end %> + + <% if @homework.homework_type == 2 %> + <% samples = @homework.homework_bank_samples %> + <% unless samples.empty? %> +
    +
    +

    输入输出样例:<%= samples.count %> 组

    +
    +
    + <% samples.each_with_index do |sample, index| %> +
    +
      +
    • + + 样例<%= index + 1 %> +
    • +
    • + +
      +
      <%=sample.input.blank? ? " " : sample.input %>
      +
      +
    • +
    • + +
      +
      <%=sample.output.blank? ? " " : sample.output %>
      +
      +
    • +
    +
    + <% end %> +
    +
    + <% end %> + + <%# if @is_teacher %> +
    +
    +

    测试集:<%=@homework.homework_bank_tests.count %> 组

    +
    +
    + + + + + + + + + + <% @homework.homework_bank_tests.each_with_index do |test, i| %> + + + + + + <% end %> + +
    序号测试集输入测试集输出
    <%=i+1 %> +
    <%=test.input.blank? ? " " : test.input %>
    +
    +
    <%=test.output.blank? ? " " : test.output %>
    +
    +
    +
    + <% end %> + <%# end %> +
    +
    +
    +
    + <% unless @homework.reference_answer.blank? %> + <%= @homework.reference_answer.html_safe %> + <% else %> + +

    暂未设置参考答案 ~

    + <% end %> +
    +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/homework_common/_edit_anon_setting.html.erb b/app/views/homework_common/_edit_anon_setting.html.erb index 226f97d16..72e38656f 100644 --- a/app/views/homework_common/_edit_anon_setting.html.erb +++ b/app/views/homework_common/_edit_anon_setting.html.erb @@ -9,7 +9,7 @@ - @@ -143,7 +147,7 @@

    - + @@ -156,6 +160,6 @@

    - + \ No newline at end of file diff --git a/app/views/homework_common/_shixuns.html.erb b/app/views/homework_common/_shixuns.html.erb index a568b5cbb..b8ae7b673 100644 --- a/app/views/homework_common/_shixuns.html.erb +++ b/app/views/homework_common/_shixuns.html.erb @@ -1,14 +1,14 @@
    -
    -

    选择实训

    - +
    +

    选择实训

    +
    -
    - <%= labelled_form_for @homework, :url =>{:controller=> 'homework_common', :action => 'shixuns', :course => @course.id}, :method => "get", :remote => true do |f| %> +
    + <%= labelled_form_for @homework, :url =>{:controller=> 'homework_common', :action => 'shixuns', :course => @course.id}, :id => 'shixun_search_form', :method => "get", :remote => true do |f| %>
    - - + +
    <% end %> @@ -37,9 +37,9 @@ <% end %>
    -
    - 取消 - 选择 +
      diff --git a/app/views/homework_common/_show_anon_setting.html.erb b/app/views/homework_common/_show_anon_setting.html.erb index 85038c3b4..45ee57f59 100644 --- a/app/views/homework_common/_show_anon_setting.html.erb +++ b/app/views/homework_common/_show_anon_setting.html.erb @@ -9,7 +9,7 @@
      • - > + >
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/views/homework_common/_show_late_setting.html.erb b/app/views/homework_common/_show_late_setting.html.erb index 0f1bcf206..81f2e9997 100644 --- a/app/views/homework_common/_show_late_setting.html.erb +++ b/app/views/homework_common/_show_late_setting.html.erb @@ -8,33 +8,38 @@
    • - - - > - - - - > - - + + > + + > +
    -
      -
    • - - -
    • +
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/views/homework_common/_show_public_setting.html.erb b/app/views/homework_common/_show_public_setting.html.erb index 693714e05..c97cbc054 100644 --- a/app/views/homework_common/_show_public_setting.html.erb +++ b/app/views/homework_common/_show_public_setting.html.erb @@ -1,3 +1,12 @@ +

    公开设置

    <% if @is_teacher %> @@ -10,25 +19,38 @@ <% if @homework.homework_type != 4 %>
  • - > + > (选中则在作业结束时间之后对班级学生公开所有作品,否则作品不公开)
  • <% end %>
  • - > + > (选中则在作业结束时间之后对班级学生公开作品成绩,否则成绩不公开)
  • <% if @homework.homework_type != 4 %>
  • - > + > (选中则在作业结束时间之后对班级学生公开作业答案,否则答案不公开)
  • <% end %>
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/views/homework_common/_show_publish_setting.html.erb b/app/views/homework_common/_show_publish_setting.html.erb index 3d9cecc15..20fa0cf81 100644 --- a/app/views/homework_common/_show_publish_setting.html.erb +++ b/app/views/homework_common/_show_publish_setting.html.erb @@ -37,4 +37,52 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/homework_common/_show_score_setting.html.erb b/app/views/homework_common/_show_score_setting.html.erb index 1d826e1f5..65784dd87 100644 --- a/app/views/homework_common/_show_score_setting.html.erb +++ b/app/views/homework_common/_show_score_setting.html.erb @@ -57,18 +57,14 @@ - +
  • - +
  • <% if @homework.homework_type == 2 %> @@ -76,9 +72,7 @@ - +
  • @@ -126,4 +120,12 @@
  • - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/homework_common/anon_setting.js.erb b/app/views/homework_common/anon_setting.js.erb index 40c18ca51..4d08101be 100644 --- a/app/views/homework_common/anon_setting.js.erb +++ b/app/views/homework_common/anon_setting.js.erb @@ -1,4 +1,23 @@ $("#show_anon_setting").html("<%= j(render :partial => 'show_anon_setting') %>").show(); $("#show_score_setting").html("<%= j(render :partial => 'show_score_setting') %>"); $("#edit_score_setting").html("<%= j(render :partial => 'edit_score_setting') %>"); -$("#edit_anon_setting").html("<%= j(render :partial => 'edit_anon_setting') %>").hide(); \ No newline at end of file +$("#edit_anon_setting").html("<%= j(render :partial => 'edit_anon_setting') %>").hide(); + +$("input[name='homework_evaluation_start']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false +}); +$("input[name='homework_evaluation_end']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false +}); +$("input[name='homework_appeal_time']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false +}); \ No newline at end of file diff --git a/app/views/homework_common/publish_setting.js.erb b/app/views/homework_common/publish_setting.js.erb index d135fa68b..36290611b 100644 --- a/app/views/homework_common/publish_setting.js.erb +++ b/app/views/homework_common/publish_setting.js.erb @@ -5,4 +5,44 @@ $("#homework_late_setting").html('
    <%= j(render :part $("#homework_anon_setting").html('
    <%= j(render :partial => 'show_anon_setting') %>
    <%= j(render :partial => 'edit_anon_setting') %>
    '); $("#homework_score_setting").html('
    <%= j(render :partial => 'show_score_setting') %>
    <%= j(render :partial => 'edit_score_setting') %>
    '); $("#homework_public_setting").html('
    <%= j(render :partial => 'show_public_setting') %>
    <%= j(render :partial => 'edit_public_setting') %>
    '); -<% end %> \ No newline at end of file +<% end %> +$("input[name='homework_publish_time']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false, + onSelectDate:function() { + $("#reset_publish_time").show(); + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1)))); + } + }, + onSelectTime:function() { + $("#reset_publish_time").show(); + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1)))); + } + } +}); + +$("input[name='homework_end_time']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false, + onSelectDate:function() { + $("#reset_end_time").show(); + }, + onSelectTime:function() { + $("#reset_end_time").show(); + } +}); + +$("input[name='homework_archive_time']").datetimepicker({ + allowBlank:true, + lang:'ch', + format:'Y-m-d H:i', + validateOnBlur:false +}); \ No newline at end of file diff --git a/app/views/homework_common/setting.html.erb b/app/views/homework_common/setting.html.erb index 30343a4ac..fb4d1467b 100644 --- a/app/views/homework_common/setting.html.erb +++ b/app/views/homework_common/setting.html.erb @@ -120,97 +120,4 @@
    <% end %> - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 93190e9b9..aeee200fc 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -3,8 +3,8 @@
    diff --git a/app/views/layouts/_logined_force_header.html.erb b/app/views/layouts/_logined_force_header.html.erb index ef565db0b..f955846e7 100644 --- a/app/views/layouts/_logined_force_header.html.erb +++ b/app/views/layouts/_logined_force_header.html.erb @@ -37,7 +37,7 @@
  • 我的主页
  • 我的课程
  • -
  • 我的实训
  • +
  • 我的实训
  • 我的留言
  • 修改资料
  • diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 34dd02306..bb085f106 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -21,7 +21,7 @@
  • <%= link_to "智能课堂", courses_path, :class => "new-nav-a", :target => "_blank" %>
  • <%= link_to "项目实训", shixuns_path, :class => "new-nav-a", :target => "_blank" %>
  • -
  • <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "new-nav-a", :target=>"_blank" %>
  • +
    @@ -33,11 +33,11 @@
    - +
    + + + + + +
    +
    + <% is_current_user = User.current.logged? && User.current == @user %> + <% if User.current.logged? %> + <%= render :partial => 'layouts/logined_header' %> + <% else%> + <%= render :partial => 'layouts/unlogin_header' %> + <% end%> +
    + +
    +
    +
    +
    + <%= yield %> +
    +
    + +
    + <%= render :partial => 'layouts/footer' %> +
    + + + + +
    + + + \ No newline at end of file diff --git a/app/views/layouts/login_bigdata.html.erb b/app/views/layouts/login_bigdata.html.erb index a95815758..401baa020 100644 --- a/app/views/layouts/login_bigdata.html.erb +++ b/app/views/layouts/login_bigdata.html.erb @@ -24,8 +24,8 @@

    <%= params[:action] == "user_join" ? "注册" : "登录" %>

    <%= link_to '首页', home_path %> - | - <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> + + <%#= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %>

    <% end %> diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 91ca49038..1bd24ce86 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -77,198 +77,200 @@
    -
    -
    -
    - <% if User.current.logged? && User.current == @user %> + <% if params[:action] != "user_newfeedback" %> +
    +
    +
    + <% if User.current.logged? && User.current == @user %> <%= link_to image_tag(url_to_avatar(@user),width:"238", height: "200", :id => 'nh_source_tx'), my_clear_user_avatar_temp_path, :remote => true %> - <% else %> + <% else %> <%=image_tag(url_to_avatar(@user),width:"238", height: "200", :id=>'nh_source_tx') %> - <% end %> -
    -
    -

    - <%= link_to @user.show_name, user_path(@user), :class => "mb5 fontGrey3" %> - <% if @user.user_extensions && @user.user_extensions.identity %> - (<%= get_user_roll @user %>) - <% end%> - <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> - - <% end %> -

    -

    <%= @user.login %>

    -

    - <% if !@user.user_extensions.school_id.blank? %> - <%= @user.user_extensions.school.name %> - <% end %> -

    - -
    -
    - <% if User.current.logged?%> - <% if User.current == @user %> - <%= link_to '个人主页', homepage_user_path(@user), :class => "home-big-btn-grey", :target => '_blank' %> - <% else %> - <% if(@user.watched_by?(User.current)) %> - <%= link_to "取消关注", - watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id), - :class => "home-btn-grey fl mr12", - :method => "delete", - :remote => "true", - :title => "取消关注" %> - <% else %> - <%= link_to "添加关注", - watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id), - :class => "home-btn-grey fl mr12", - :method => "post", - :remote => "true", - :title => "添加关注" %> - <% end %> - <% if @user.base_homepage.nil? %> - TA的主页 - <% else %> - <%= link_to "TA的主页", homepage_user_path(@user.login), :class => 'home-btn-grey fl', :target => '_blank' %> - <% end %> - <% end %> <% end %>
    -
    - <% if is_current_user %> - <% if hidden_unproject_infos && user_course_count > 0 %> -
    -

    - <%= link_to "课程社区", user_course_community_path(User.current), :class => "fl" , :target => "_blank", :style => "color:#666" %> -

    - <%# if hidden_unproject_infos %> -
      -
    • - <%= link_to user_course_count > 0 ? "课程#{user_course_count}".html_safe : "课程", - user_course_community_path(User.current), :id => "user_course_list", :target => "_blank" %> -
    • - <% if user_manage_homework_count > 0 %> -
    • - <%= link_to user_manage_homework_count > 0 ? "我发布的作业#{user_manage_homework_count}".html_safe : "我发布的作业", - user_manage_homeworks_user_path(@user), :target => "_blank" %> -
    • - <% end %> - <% if user_receive_homework_count > 0 %> -
    • - <%= link_to "我收到的作业#{user_receive_homework_count}".html_safe, - user_receive_homeworks_user_path(@user), :target => "_blank" %> -
    • - <% end %> -
    • - <%= link_to "题库", user_homeworks_user_path(User.current), :target => "_blank", :class => "fl", :style => "color:#666" %> -
    • -
    • - <%= link_to "资源库", user_resource_user_path(User.current, :type => 1), :target => "_blank", :class => "fl", :style => "color:#666" %> -
    • -
    - <%# end %> -
    - <% end %> - <% if user_project_count > 0%> -
    -

    - <%= link_to "项目社区", user_project_community_path(User.current), :class => "fl", :target => "_blank", :style => "color:#666" %> -

    -
      -
    • - <%= link_to user_project_count > 0 ? "项目#{user_project_count}".html_safe : "项目", - user_project_community_path(User.current), :id => 'user_project_list', :target => "_blank" %> -
    • - <% if issues_author_is_self_count > 0 %> -
    • - <%= link_to issues_author_is_self_count > 0 ? "我发布的issue#{issues_author_is_self_count}".html_safe : "我发布的issue", - user_manage_issues_user_path(@user), :target => "_blank" %> -
    • - <% end %> - <% if issues_assigned_is_self_count > 0 %> -
    • - <%= link_to issues_assigned_is_self_count > 0 ? "我收到的issue#{issues_assigned_is_self_count}".html_safe : "我收到的issue", - user_receive_issues_user_path(@user), :target => "_blank" %> -
    • - <% end %> -
    -
    - <% end %> - <% if hidden_unproject_infos && user_contest_count > 0 %> -
    -

    - <%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%> -

    -
      -
    • - <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count}".html_safe : "竞赛", - user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %> -
    • -
    - <%# end %> -
    - <% end %> - <% else %> -
    -

    Ta在确实 - <%= time_tag(@user.created_on).html_safe %> -

    -
      - <% if hidden_unproject_infos && user_course_count > 0 %> -
    • - <%= link_to user_course_count > 0 ? "课程#{user_course_count}".html_safe : "课程", - user_course_community_path(@user), :id => "user_course_list", :class => "fl", :target => "_blank" %> -
    • - <% end %> - <% if user_project_count > 0 %> -
    • - <%= link_to user_project_count > 0 ? "项目#{user_project_count}".html_safe : "项目", - user_project_community_path(@user), :id => 'user_project_list', :class => "fl", :target => "_blank" %> -
    • - <% end %> - <% if hidden_unproject_infos && user_contest_count > 0 %> -
    • - <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count}".html_safe : "竞赛", - user_contest_community_path(@user), :id => 'user_contest_list', :class => "fl", :target => "_blank" %> -
    • - <% end %> -
    +
    +

    + <%= link_to @user.show_name, user_path(@user), :class => "mb5 fontGrey3" %> + <% if @user.user_extensions && @user.user_extensions.identity %> + (<%= get_user_roll @user %>) + <% end%> + <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> + + <% end %> +

    +

    <%= @user.login %>

    +

    + <% if !@user.user_extensions.school_id.blank? %> + <%= @user.user_extensions.school.name %> + <% end %> +

    + +
      +
    • + 博客 + <%= @user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count %> +
    • +
    • + 关注 + <%= User.watched_by(@user).count %> +
    • +
    • + 粉丝 + <%= @user.watcher_users.count %> +
    • +
    +
    + <% if User.current.logged?%> + <% if User.current == @user %> + <%= link_to '个人主页', homepage_user_path(@user), :class => "home-big-btn-grey", :target => '_blank' %> + <% else %> + <% if(@user.watched_by?(User.current)) %> + <%= link_to "取消关注", + watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id), + :class => "home-btn-grey fl mr12", + :method => "delete", + :remote => "true", + :title => "取消关注" %> + <% else %> + <%= link_to "添加关注", + watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id), + :class => "home-btn-grey fl mr12", + :method => "post", + :remote => "true", + :title => "添加关注" %> + <% end %> + <% if @user.base_homepage.nil? %> + TA的主页 + <% else %> + <%= link_to "TA的主页", homepage_user_path(@user.login), :class => 'home-btn-grey fl', :target => '_blank' %> + <% end %> + <% end %> + <% end %>
    - <% end %> -
    -
      -
    • - <%= link_to "留言", feedback_path(@user, :host=> Setting.host_user)%> -
    • -
    -
    +
    + <% if is_current_user %> + <% if hidden_unproject_infos && user_course_count > 0 %> +
    +

    + <%= link_to "课程社区", user_course_community_path(User.current), :class => "fl" , :target => "_blank", :style => "color:#666" %> +

    + <%# if hidden_unproject_infos %> +
      +
    • + <%= link_to user_course_count > 0 ? "课程#{user_course_count}".html_safe : "课程", + user_course_community_path(User.current), :id => "user_course_list", :target => "_blank" %> +
    • + <% if user_manage_homework_count > 0 %> +
    • + <%= link_to user_manage_homework_count > 0 ? "我发布的作业#{user_manage_homework_count}".html_safe : "我发布的作业", + user_manage_homeworks_user_path(@user), :target => "_blank" %> +
    • + <% end %> + <% if user_receive_homework_count > 0 %> +
    • + <%= link_to "我收到的作业#{user_receive_homework_count}".html_safe, + user_receive_homeworks_user_path(@user), :target => "_blank" %> +
    • + <% end %> +
    • + <%= link_to "题库", user_homeworks_user_path(User.current), :target => "_blank", :class => "fl", :style => "color:#666" %> +
    • +
    • + <%= link_to "资源库", user_resource_user_path(User.current, :type => 1), :target => "_blank", :class => "fl", :style => "color:#666" %> +
    • +
    + <%# end %> +
    + <% end %> + <% if user_project_count > 0%> +
    +

    + <%= link_to "项目社区", user_project_community_path(User.current), :class => "fl", :target => "_blank", :style => "color:#666" %> +

    +
      +
    • + <%= link_to user_project_count > 0 ? "项目#{user_project_count}".html_safe : "项目", + user_project_community_path(User.current), :id => 'user_project_list', :target => "_blank" %> +
    • + <% if issues_author_is_self_count > 0 %> +
    • + <%= link_to issues_author_is_self_count > 0 ? "我发布的issue#{issues_author_is_self_count}".html_safe : "我发布的issue", + user_manage_issues_user_path(@user), :target => "_blank" %> +
    • + <% end %> + <% if issues_assigned_is_self_count > 0 %> +
    • + <%= link_to issues_assigned_is_self_count > 0 ? "我收到的issue#{issues_assigned_is_self_count}".html_safe : "我收到的issue", + user_receive_issues_user_path(@user), :target => "_blank" %> +
    • + <% end %> +
    +
    + <% end %> + <% if hidden_unproject_infos && user_contest_count > 0 %> +
    +

    + <%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%> +

    +
      +
    • + <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count}".html_safe : "竞赛", + user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %> +
    • +
    + <%# end %> +
    + <% end %> + <% else %> +
    +

    Ta在确实 + <%= time_tag(@user.created_on).html_safe %> +

    +
      + <% if hidden_unproject_infos && user_course_count > 0 %> +
    • + <%= link_to user_course_count > 0 ? "课程#{user_course_count}".html_safe : "课程", + user_course_community_path(@user), :id => "user_course_list", :class => "fl", :target => "_blank" %> +
    • + <% end %> + <% if user_project_count > 0 %> +
    • + <%= link_to user_project_count > 0 ? "项目#{user_project_count}".html_safe : "项目", + user_project_community_path(@user), :id => 'user_project_list', :class => "fl", :target => "_blank" %> +
    • + <% end %> + <% if hidden_unproject_infos && user_contest_count > 0 %> +
    • + <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count}".html_safe : "竞赛", + user_contest_community_path(@user), :id => 'user_contest_list', :class => "fl", :target => "_blank" %> +
    • + <% end %> +
    +
    + <% end %> +
    +
      +
    • + <%= link_to "留言", feedback_path(@user, :host=> Setting.host_user)%> +
    • +
    +
    - <%# 更新访问数,刷新的时候更新访问次数 %> - <% update_visiti_count @user %> -
    -
      - <% unless @user.user_extensions.location.blank? %> -
    • - <%= @user.user_extensions.location %>-<%= @user.user_extensions.location_city %> -
    • - <% end %> -
    • <%= @user.created_on.strftime('%Y-%m-%d') %>开始使用
    • -
    • <%= @user.visits.to_i %>次访问(自2016年5月)
    • -
    + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @user %> +
    +
      + <% unless @user.user_extensions.location.blank? %> +
    • + <%= @user.user_extensions.location %>-<%= @user.user_extensions.location_city %> +
    • + <% end %> +
    • <%= @user.created_on.strftime('%Y-%m-%d') %>开始使用
    • +
    • <%= @user.visits.to_i %>次访问(自2016年5月)
    • +
    +
    -
    +<% end %>
    <%= yield %>
    diff --git a/app/views/managements/_authentication_list.html.erb b/app/views/managements/_authentication_list.html.erb new file mode 100644 index 000000000..ec79c9bd5 --- /dev/null +++ b/app/views/managements/_authentication_list.html.erb @@ -0,0 +1,47 @@ +<% unless @unapproved_user.blank? %> + <% @unapproved_user.each do |apply_user| %> + <% user = User.find(apply_user.user_id) %> +
    + + <%= image_tag(url_to_avatar(user), :class => "fl with10 edu-ad-user", :alt => "头像", :width => "50", :height => "50" ) %> + +
    +
      +
    • + <%= user.show_name %> + <%= time_from_now(apply_user.updated_at) %> + 拒绝 + 同意 +
    • +
    • + <% if !user.user_extensions.school_id.blank? && user.user_extensions.school %> + <%= user.user_extensions.school.name %><%= user.user_extensions.department ? ' - '+user.user_extensions.department.name.to_s : '' %> + <% end %> + <% if user.user_extensions && user.user_extensions.identity %> + <%= get_user_roll user %> + <% if user.user_extensions.identity == 1 && user.user_extensions.try(:student_id) %> + <%= user.user_extensions.try(:student_id) %> + <% end %> + <% end %> +
    • +
    • + <%= image_tag(url_to_auth_img(user.id, 'PRO'), :width => 200, :height => 150, :class => 'edu-renzheng-img fl mr20') %> + <%= image_tag(url_to_auth_img(user.id, 'ID'), :width => 200, :height => 150, :class => 'edu-renzheng-img fl mr20') %> +
    • +
      +
    • + + +
    • +
    • + 确定 + 取消 +
    • +
      +
    +
    +
    + <% end %> +<% else %> + <%= render :partial => "welcome/no_data" %> +<% end %> diff --git a/app/views/managements/_trial_authorization_list.html.erb b/app/views/managements/_trial_authorization_list.html.erb new file mode 100644 index 000000000..d7c384b11 --- /dev/null +++ b/app/views/managements/_trial_authorization_list.html.erb @@ -0,0 +1,57 @@ +<% unless @authorizations.blank? %> + <% @authorizations.each do |authorization| %> + <% user = authorization.user %> +
    + + <%= image_tag(url_to_avatar(user), :class => "fl with10 edu-ad-user", :alt => "头像", :width => "50", :height => "50" ) %> + +
    +
      +
    • + <%= user.try(:show_name) %> + <%= time_from_now(authorization.updated_at) %> + 拒绝 + 同意 +
    • +
    • + <% if !user.try(:user_extensions).school_id.blank? && user.try(:user_extensions).try(:school) %> + <%= user.try(:user_extensions).school.name %><%= user.try(:user_extensions).department ? ' - '+user.try(:user_extensions).department.name.to_s : '' %> + <% end %> + <% if user.try(:user_extensions) && user.try(:user_extensions).identity %> + <%= get_user_roll user %> + <% if user.try(:user_extensions).identity == 1 && user.try(:user_extensions).try(:student_id) %> + <%= user.try(:user_extensions).try(:student_id) %> + <% end %> + <% end %> + <%= identity_authentication_status(User.current.id) %> +
    • +
      +
    • + + +
    • +
    • + 确定 + 取消 +
    • +
      +
    +
    +
    + <% end %> +<% else %> + <%= render :partial => "welcome/no_data" %> +<% end %> + + \ No newline at end of file diff --git a/app/views/managements/_trial_authorization_passed_list.html.erb b/app/views/managements/_trial_authorization_passed_list.html.erb new file mode 100644 index 000000000..94c6d76f9 --- /dev/null +++ b/app/views/managements/_trial_authorization_passed_list.html.erb @@ -0,0 +1,34 @@ +<% unless @authorizations.blank? %> + <% @authorizations.each do |authorization| %> + <% user = authorization.user %> +
    + + <%= image_tag(url_to_avatar(user), :class => "fl with10 edu-ad-user", :alt => "头像", :width => "50", :height => "50" ) %> + +
    +
      +
    • + <%= user.try(:show_name) %> + <%= time_from_now(authorization.updated_at) %> + <%= authorization.status == 1 ? "已同意" : "已拒绝" %> +
    • +
    • + <% if !user.try(:user_extensions).school_id.blank? && user.try(:user_extensions).try(:school) %> + <%= user.try(:user_extensions).school.name %><%= user.try(:user_extensions).department ? ' - '+user.try(:user_extensions).department.name.to_s : '' %> + <% end %> + <% if user.try(:user_extensions) && user.try(:user_extensions).identity %> + <%= get_user_roll user %> + <% if user.try(:user_extensions).identity == 1 && user.try(:user_extensions).try(:student_id) %> + <%= user.try(:user_extensions).try(:student_id) %> + <% end %> + <% end %> + <%= identity_authentication_status(User.current.id) %> +
    • +
    • 原因:<%= authorization.reason.blank? ? "空" : authorization.reason %>
    • +
    +
    +
    + <% end %> +<% else %> + <%= render :partial => "welcome/no_data" %> +<% end %> diff --git a/app/views/managements/_users_authorization_list.html.erb b/app/views/managements/_users_authorization_list.html.erb new file mode 100644 index 000000000..33db6f123 --- /dev/null +++ b/app/views/managements/_users_authorization_list.html.erb @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + <% @authorizations.each do |authorization| %> + <% user = authorization.user %> + + + + + + + + + + + + <% end %> + + +
     真实姓名职业学号认证单位子单位试用状态授权时间
    + + + + <%= link_to user.try(:show_name), user_path(user), :class => "edu-txt-w100 task-hide2" %> + <%= user.identity %><%= user.try(:user_extensions).try(:student_id).blank? ? "--" : user.try(:user_extensions).try(:student_id) %><%= identity_authentication_status(user.id) %><%= user.try(:user_extensions).try(:school).name.blank? ? "--" : user.try(:user_extensions).try(:school) %><%= user.try(:user_extensions).department ? user.try(:user_extensions).try(:department).try(:name).to_s : '--' %><%= authorization.status == 0 ? "未授权" : (authorization.status == 1 ? "已授权" : "已拒绝") %><%= format_time(authorization.created_at) %>
    \ No newline at end of file diff --git a/app/views/managements/agree_authentication.js.erb b/app/views/managements/agree_authentication.js.erb new file mode 100644 index 000000000..ab9d4277d --- /dev/null +++ b/app/views/managements/agree_authentication.js.erb @@ -0,0 +1 @@ +$("#authentication_list").html("<%= j( render :partial => "authentication_list" ) %>"); \ No newline at end of file diff --git a/app/views/managements/identity_authentication.html.erb b/app/views/managements/identity_authentication.html.erb new file mode 100644 index 000000000..e1b8318e4 --- /dev/null +++ b/app/views/managements/identity_authentication.html.erb @@ -0,0 +1,135 @@ +
    +
    +

    身份认证

    +
    +
    +
    +
      +
    • + <%= link_to "待审批", {:controller => "managements", :action => "identity_authentication", :type => [0]}, :class => "tab_type", :remote => true %> + +
    • +
    • + <%= link_to "已审批", {:controller => "managements", :action => "identity_authentication", :type => [1,2]}, :class => "tab_type", :remote => true %> + +
    • +
    +
    +
    +
    +
    + + +
    +
    +
    + <%= render :partial => "admin/authentication_list" %> +
    +
    +
    + +
    +
    +

    + 全部 + 同意 + 拒绝 +

    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/app/views/managements/identity_authentication.js.erb b/app/views/managements/identity_authentication.js.erb new file mode 100644 index 000000000..a8bd6caf8 --- /dev/null +++ b/app/views/managements/identity_authentication.js.erb @@ -0,0 +1,30 @@ +var nTabIcon_1 = $("#edu-tab-con-1"); +var nTabIcon_2 = $("#edu-tab-con-2"); +var nTabNav_1 = $("#edu-tab-nav-1"); +var nTabNav_2 = $("#edu-tab-nav-2"); +var nAudit = $("#audit_all_authentication").parent(); + +<% if params[:type] == "0" %> +$("#authentication_list").html("<%= j( render :partial => "admin/authentication_list" ) %>"); +nTabNav_1.addClass("edu-tab-hover"); +nTabNav_2.removeClass("edu-tab-hover"); +nTabIcon_1.show(); +nTabIcon_2.hide(); +<% else %> +$("#audit_authentication_list").html("<%= j( render :partial => "admin/audit_authentication_list" ) %>"); +nTabNav_1.removeClass("edu-tab-hover"); +nTabNav_2.addClass("edu-tab-hover"); +nTabIcon_1.hide(); +nTabIcon_2.show(); +/* -------------------------- 未审批(全部、同意、拒绝点击时动态样式) ------------------------------ */ +if(<%= params[:type] == "1" %>){ + nAudit.find(".active").removeClass("active"); + $("#audit_agree_authentication").addClass("active"); +}else if(<%= params[:type] == "2" %>){ + nAudit.find(".active").removeClass("active"); + $("#audit_reject_authentication").addClass("active"); +}else{ + nAudit.find(".active").removeClass("active"); + $("#audit_all_authentication").addClass("active"); +} +<% end %> \ No newline at end of file diff --git a/app/views/managements/index.html.erb b/app/views/managements/index.html.erb new file mode 100644 index 000000000..65b6c4e30 --- /dev/null +++ b/app/views/managements/index.html.erb @@ -0,0 +1 @@ +<%= render :partial => "welcome/no_data" %> \ No newline at end of file diff --git a/app/views/managements/trial_authorization.html.erb b/app/views/managements/trial_authorization.html.erb new file mode 100644 index 000000000..ddd3e74c6 --- /dev/null +++ b/app/views/managements/trial_authorization.html.erb @@ -0,0 +1,138 @@ +
    +
    +

    试用授权

    +
    +
    +
    +
      +
    • + <%= link_to "待审批", {:controller => "managements", :action => "trial_authorization", :status => "0"}, :class => "tab_type", :remote => true %> + +
    • +
    • + <%= link_to "已审批", {:controller => "managements", :action => "trial_authorization", :status => [1,2]}, :class => "tab_type", :remote => true %> + +
    • +
    +
    +
    +
    +
    + + +
    +
    +
    + <%= render :partial => "managements/trial_authorization_list"%> +
    +
    +
    + +
    +
    +

    + 全部 + 同意 + 拒绝 +

    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/app/views/managements/trial_authorization.js.erb b/app/views/managements/trial_authorization.js.erb new file mode 100644 index 000000000..5de72a691 --- /dev/null +++ b/app/views/managements/trial_authorization.js.erb @@ -0,0 +1,30 @@ +var nTabIcon_1 = $("#edu-tab-con-1"); +var nTabIcon_2 = $("#edu-tab-con-2"); +var nTabNav_1 = $("#edu-tab-nav-1"); +var nTabNav_2 = $("#edu-tab-nav-2"); +var nAudit = $("#audit_all_authentication").parent(); + +<% if @status == 0 %> +$("#authentication_list").html("<%= j( render :partial => "managements/trial_authorization_list" ) %>"); +nTabNav_1.addClass("edu-tab-hover"); +nTabNav_2.removeClass("edu-tab-hover"); +nTabIcon_1.show(); +nTabIcon_2.hide(); +<% else %> +$("#audit_authentication_list").html("<%= j( render :partial => "managements/trial_authorization_passed_list" ) %>"); +nTabNav_1.removeClass("edu-tab-hover"); +nTabNav_2.addClass("edu-tab-hover"); +nTabIcon_1.hide(); +nTabIcon_2.show(); +/* -------------------------- 未审批(全部、同意、拒绝点击时动态样式) ------------------------------ */ +if(<%= @status == 1 %>){ + nAudit.find(".active").removeClass("active"); + $("#audit_agree_authentication").addClass("active"); +}else if(<%= @status == 2 %>){ + nAudit.find(".active").removeClass("active"); + $("#audit_reject_authentication").addClass("active"); +}else{ + nAudit.find(".active").removeClass("active"); + $("#audit_all_authentication").addClass("active"); +} +<% end %> \ No newline at end of file diff --git a/app/views/managements/trial_authorization_operation.js.erb b/app/views/managements/trial_authorization_operation.js.erb new file mode 100644 index 000000000..edc52166a --- /dev/null +++ b/app/views/managements/trial_authorization_operation.js.erb @@ -0,0 +1 @@ +$("#authentication_list").html("<%= j( render :partial => "managements/trial_authorization_list" ) %>"); diff --git a/app/views/managements/users.html.erb b/app/views/managements/users.html.erb new file mode 100644 index 000000000..fb3252fd6 --- /dev/null +++ b/app/views/managements/users.html.erb @@ -0,0 +1,62 @@ +
    +
    +

    全部状态

    +
      +
    • 活动的(53888)
    • +
    • 未激活(4800)
    • +
    • 已锁定(200)
    • +
    +
    +
    +

    真实姓名搜索

    +
      +
    • 邮箱地址搜索
    • +
    • 手机号码搜索
    • +
    +
    +
    + + 搜索 + 清除 +
    + 新建用户 +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ID真实姓名邮件地址手机号码单位创建于最后登录操作
    m12345678欧阳莎莎欧阳莎莎欧阳莎莎欧阳莎莎12345678123456781234567890@test.com12345678901国防科学技术大学国防科学技术大学国防科学技术大学2017-05-01 10:062017-05-01 10:06锁定删除
    m12345678欧阳莎1234567810@test.com12345678901国防科学技术大学国防科学技术大学国防科学技术大学2017-05-01 10:062017-05-01 10:06锁定删除
    +
    \ No newline at end of file diff --git a/app/views/managements/users_trial.html.erb b/app/views/managements/users_trial.html.erb new file mode 100644 index 000000000..9faf20f78 --- /dev/null +++ b/app/views/managements/users_trial.html.erb @@ -0,0 +1,65 @@ +
    +
    +

    认证情况

    +
      +
    • 已认证
    • +
    • 未认证
    • +
    • 处理中
    • +
    • 被拒绝
    • +
    +
    +
    +

    试用授权情况

    +
      +
    • 已授权
    • +
    • 未授权
    • +
    • 处理中
    • +
    • 被拒绝
    • +
    +
    +
    +

    全部单位

    +
      +
    • 全部单位
    • + +
    +
    +
    +

    子单位

    +
      +
    • 子单位
    • +
    +
    +
    +

    真实姓名搜索

    +
      +
    • 邮箱地址搜索
    • +
    • 手机号码搜索
    • +
    +
    +
    + + 搜索 + 清除 +
    +
    +
    + <% if @authorizations.blank? %> + <%= render :partial => "welcome/no_data" %> + <% else %> +
    + + + + + + + + 授权试用 + 取消试用 +
    +
    + <%= render :partial => "users_authorization_list" %> +
    + <% end %> +
    \ No newline at end of file diff --git a/app/views/memos/_memo_all_replies.html.erb b/app/views/memos/_memo_all_replies.html.erb index 9d6726ef1..0d2934dc5 100644 --- a/app/views/memos/_memo_all_replies.html.erb +++ b/app/views/memos/_memo_all_replies.html.erb @@ -61,7 +61,7 @@
    -

    +
    diff --git a/app/views/memos/quote.js.erb b/app/views/memos/quote.js.erb index bd1d2f047..563973bed 100644 --- a/app/views/memos/quote.js.erb +++ b/app/views/memos/quote.js.erb @@ -1,5 +1,6 @@ -if($("#reply_message_<%= @memo.id%>").length > 0) { +if($("#reply_message_<%= @memo.id%>").html() == "") { + $(".reply_to_message").html(""); $("#reply_message_<%= @memo.id%>").replaceWith("<%= escape_javascript(render :partial => 'memos/reply_message', :locals => {:reply => @memo}) %>"); -}else if($("#reply_to_message_<%= @memo.id%>").length >0) { - $("#reply_to_message_<%= @memo.id%>").replaceWith("

    "); +}else { + $("#reply_message_<%= @memo.id%>").html(""); } \ No newline at end of file diff --git a/app/views/messages/_contest_show_replies.html.erb b/app/views/messages/_contest_show_replies.html.erb index b9c179ff2..3a841a2f8 100644 --- a/app/views/messages/_contest_show_replies.html.erb +++ b/app/views/messages/_contest_show_replies.html.erb @@ -44,7 +44,7 @@
    -

    +
    diff --git a/app/views/messages/_course_show_replies.html.erb b/app/views/messages/_course_show_replies.html.erb index 3ea86596f..2f662fd02 100644 --- a/app/views/messages/_course_show_replies.html.erb +++ b/app/views/messages/_course_show_replies.html.erb @@ -44,7 +44,7 @@
    -

    +
    diff --git a/app/views/messages/_org_show_replies.html.erb b/app/views/messages/_org_show_replies.html.erb index 9b63c80ed..15a84934f 100644 --- a/app/views/messages/_org_show_replies.html.erb +++ b/app/views/messages/_org_show_replies.html.erb @@ -43,7 +43,7 @@
    -

    +
    diff --git a/app/views/messages/_project_show_replies.html.erb b/app/views/messages/_project_show_replies.html.erb index 637fade8a..ebca39ace 100644 --- a/app/views/messages/_project_show_replies.html.erb +++ b/app/views/messages/_project_show_replies.html.erb @@ -44,7 +44,7 @@
    -

    +
    diff --git a/app/views/messages/quote.js.erb b/app/views/messages/quote.js.erb index aa429201d..47bd77351 100644 --- a/app/views/messages/quote.js.erb +++ b/app/views/messages/quote.js.erb @@ -1,8 +1,9 @@ -if($("#reply_message_<%= @message.id%>").length > 0) { +if($("#reply_message_<%= @message.id%>").html() == "") { + $(".reply_to_message").html(""); <% if params[:is_project] %> - $("#reply_message_<%= @message.id%>").replaceWith("<%= escape_javascript(render :partial => 'messages/project_rereply_message', :locals => {:reply => @message}) %>"); + $("#reply_message_<%= @message.id%>").html("<%= escape_javascript(render :partial => 'messages/project_rereply_message', :locals => {:reply => @message}) %>"); <% else %> - $("#reply_message_<%= @message.id%>").replaceWith("<%= escape_javascript(render :partial => 'reply_message', :locals => {:reply => @message}) %>"); + $("#reply_message_<%= @message.id%>").html("<%= escape_javascript(render :partial => 'reply_message', :locals => {:reply => @message}) %>"); <% end %> $(function(){ @@ -10,6 +11,6 @@ if($("#reply_message_<%= @message.id%>").length > 0) { $('#quote_quote').val("<%#= raw escape_javascript(@temp.content.html_safe) %>");*/ sd_create_editor_from_data(<%= @message.id%>,null,"100%", "<%=@message.class.to_s%>"); }); -}else if($("#reply_to_message_<%= @message.id%>").length >0) { - $("#reply_to_message_<%= @message.id%>").replaceWith("

    "); +}else { + $("#reply_message_<%= @message.id%>").html(""); } \ No newline at end of file diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index cb28f7e1a..f0b652d8a 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -1,3 +1,24 @@ +<% if @require_auth %> + <%= render :partial => "welcome/guidance_mask" %> +<% else %> + <% if @require_trail_auth %> + <%= render :partial => 'welcome/two_btn_mask_pop', + :locals => {:btn1 => "试用申请", :btn2 => "身份认证", + :tip1 => "更多功能,需要经过管理员的授权审核", + :tip2 => "建议先提交身份认证,再进行试用申请", + :url1 => "#{apply_trail_account_path}", + :url2 => "#{authentication_account_path}" + } + %> + <% elsif @trail_authentication.status == 0 %> + <%= render :partial => 'welcome/one_btn_mask_pop', + :locals => {:btn => "知道了", + :tip1 => "平台正在核准您的身份信息,请等待。谢谢您的关注!", + :url => "javascript:void(0);" + } + %> + <% end %> +<% end %>
    @@ -181,14 +202,18 @@ 已认证 <% else %> - - - 未认证 - - - - 认证中 - + <% apply_auth = ApplyUserAuthentication.where(:user_id => @user.id).last %> + <% if apply_auth && apply_auth.status == 0 %> + + + 认证中 + + <% else %> + + + 未认证 + + <% end %> <% end %>

    @@ -245,20 +270,7 @@ <% title = "" %> <% language = "" %> <% end %> -<% if @force %> - <%= render :partial => "welcome/guidance_mask" %> -<% elsif @auth %> - <%= render :partial => 'welcome/two_btn_mask_pop', - :locals => { - :btn1 => "试用申请", - :btn2 => "身份认证", - :tip1 => "更多功能,需要经过管理员的授权审核", - :tip2 => "建议先提交身份认证,再进行试用申请", - :url1 => "javascript:void(0);", - :url2 => "#{authentication_account_path}" - } - %> -<% end %> + \ No newline at end of file diff --git a/app/views/shixuns/_search.html.erb b/app/views/shixuns/_search.html.erb index b31aaf021..dc862256a 100644 --- a/app/views/shixuns/_search.html.erb +++ b/app/views/shixuns/_search.html.erb @@ -1,7 +1,7 @@ <%= form_tag url_for(search_shixuns_path(:status => @status, :type => @type, :order => @order)), :remote => true, :method => :post, :id => 'add_collaborators_form', :onsubmit => "submitFn(this, event);", :class => "fl ml15" do |f| %>
    - +
    diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index d12907da4..56f47caf4 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -64,7 +64,11 @@ toolbarIcons : function() { // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "image", "code", "code-block", "|", "table", "watch", "clear"] + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + toolbarCustomIcons : { + testIcon : "
    ", + testIcon1 : "
    " }, //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 saveHTMLToTextarea : true, @@ -87,7 +91,11 @@ toolbarIcons : function() { // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "image", "code", "code-block", "|", "table", "watch", "clear"] + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + toolbarCustomIcons : { + testIcon : "
    ", + testIcon1 : "
    " }, //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 saveHTMLToTextarea : true, @@ -99,4 +107,41 @@ imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url }); + + window.onload = function(){ + $("#setting_introduction [type=\"latex\"]").bind("click", function(){ + setting_editormd.cm.replaceSelection("```latex"); + setting_editormd.cm.replaceSelection("\n"); + setting_editormd.cm.replaceSelection("\n"); + setting_editormd.cm.replaceSelection("```"); + var __Cursor = setting_editormd.cm.getDoc().getCursor(); + setting_editormd.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#setting_propaedeutics [type=\"latex\"]").bind("click", function(){ + p_editormd.cm.replaceSelection("```latex"); + p_editormd.cm.replaceSelection("\n"); + p_editormd.cm.replaceSelection("\n"); + p_editormd.cm.replaceSelection("```"); + var __Cursor = p_editormd.cm.getDoc().getCursor(); + p_editormd.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#setting_introduction [type=\"inline\"]").bind("click", function(){ + setting_editormd.cm.replaceSelection("$$$$"); + var __Cursor = setting_editormd.cm.getDoc().getCursor(); + setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2); + setting_editormd.cm.focus(); + }); + + $("#setting_propaedeutics [type=\"inline\"]").bind("click", function(){ + p_editormd.cm.replaceSelection("$$$$"); + var __Cursor = p_editormd.cm.getDoc().getCursor(); + p_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2); + p_editormd.cm.focus(); + }); + $("[type=\"inline\"]").attr("title", "行内公式"); + $("[type=\"latex\"]").attr("title", "多行公式"); + + } diff --git a/app/views/shixuns/_shixun_list.html.erb b/app/views/shixuns/_shixun_list.html.erb index 07426e41c..ff3fa32de 100644 --- a/app/views/shixuns/_shixun_list.html.erb +++ b/app/views/shixuns/_shixun_list.html.erb @@ -4,14 +4,14 @@
    <% else %> <% @shixuns.each do |shixun| %> -
    -
    +
    +

    - <%= link_to shixun.name, shixun_path(shixun), :target => "_blank" %> + <%= link_to shixun.name, "javascrip:void(0);" %>

    - <%= link_to image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像"), user_path(shixun.owner), :target => "_blank" %> - <%= link_to shixun.owner.try(:show_name), user_path(shixun.owner), :class => "task-index-name task-hide fl", :target => "_blank" %> + <%= link_to image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像"), "javascrip:void(0);" %> + <%= link_to shixun.owner.try(:show_name), "javascrip:void(0);" , :class => "task-index-name task-hide fl", :target => "_blank" %>
    <%= shixun.language == "JDBC" ? "Java/SQL" : shixun.language %> @@ -33,4 +33,9 @@
    <% end %> - + diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index 2ce091dfe..01f23f459 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -6,7 +6,7 @@ /

    <%= @shixun.name %>

    <% if allow_shixun_exec(@shixun) %> - <% if User.current.id == @shixun.user_id %> + <% if User.current.manager_of_shixun?(@shixun) %> <% if @shixun.status == 1 %> <%= link_to "重新发布", publish_shixun_path(@shixun, :type => "retry"), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :remote => true %> <% else %> diff --git a/app/views/shixuns/autocompletion.html.erb b/app/views/shixuns/autocompletion.html.erb index 80dedc144..0e92bdde3 100644 --- a/app/views/shixuns/autocompletion.html.erb +++ b/app/views/shixuns/autocompletion.html.erb @@ -1,5 +1,11 @@ -<%= javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/javascript-hint" %> -<%= stylesheet_link_tag "/codemirror/lib/codemirror", "/codemirror/addon/hint/show-hint", "/codemirror/doc/docs" %> +<%= javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/anyword-hint", "/codemirror/addon/edit/matchbrackets", "/codemirror/addon/hint/javascript-hint" %> +<%= stylesheet_link_tag "/codemirror/lib/codemirror", "/codemirror/addon/hint/show-hint", "/codemirror/doc/docs", "/codemirror/addon/lint/lint" %> +