diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 3fea82bff..b7a764999 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -109,7 +109,9 @@ class AccountController < ApplicationController if User.current.anonymous? redirect_to signin_path else + UserActions.create(:action_id => User.current.id, :action_type => "Logout", :user_id => User.current.id) logout_user + # 记录用户登出行为 redirect_to signin_path end # display the logout form @@ -816,6 +818,8 @@ class AccountController < ApplicationController call_hook(:controller_account_success_authentication_after, {:user => user }) code = /\d*/ + # 记录用户登录行为 + UserActions.create(:action_id => User.current.id, :action_type => "Login", :user_id => User.current.id) #根据home_url生产正则表达式 eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != '' diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 97d193fbd..87c7a22cd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -44,30 +44,29 @@ class CoursesController < ApplicationController @user = User.current @search = params[:search].nil? ? '' : params[:search] @select = params[:select].nil? ? '' : params[:select] - @is_end = params[:is_end].nil? ? 0 : params[:is_end].to_i # 是否归档 @is_over = params[:is_over] # 是否是新建课程页面跳转的查看归档 - @syllabuses_num = Course.where("is_end = #{@is_end} and is_delete = 0").count + @syllabuses_num = Course.where("is_end = 0 and is_delete = 0").count #@syllabus_count = all_syllabuses.count # 我创建的课堂 create_syllabuses = Course.where(:tea_id => @user.id) # 我参与的课堂 join_syllabuses = @user.courses.where("is_delete = 0 and tea_id != #{@user.id}") - @join_syllabuses_count = join_syllabuses.where(:is_end => @is_end, :is_delete => 0).count - @create_syllabuses_count = create_syllabuses.where(:is_end => @is_end, :is_delete => 0).count + @join_syllabuses_count = join_syllabuses.where(:is_end => 0, :is_delete => 0).count + @create_syllabuses_count = create_syllabuses.where(:is_end => 0, :is_delete => 0).count # 页面筛选的课程 if @select == "create" - @syllabuses = create_syllabuses.where("is_end = #{@is_end} and is_delete = 0 and name like '%#{@search}%'") + @syllabuses = create_syllabuses.where("is_end = 0 and is_delete = 0 and name like '%#{@search}%'") elsif @select == "join" - @syllabuses = join_syllabuses.where("is_end = #{@is_end} and is_delete = 0 and tea_id != #{@user.id} and name like '%#{@search}%'") + @syllabuses = join_syllabuses.where("is_end = 0 and is_delete = 0 and tea_id != #{@user.id} and name like '%#{@search}%'") elsif @select == "end" # 归档的课堂 - end_syllabuses = Course.where("is_end = #{@is_end} and name like '%#{@search}%'") + end_syllabuses = Course.where("is_end = 1 and name like '%#{@search}%'") @syllabuses = end_syllabuses else # 全部课堂 - all_syllabuses = Course.where("is_end = #{@is_end} and is_delete = 0 and name like '%#{@search}%'") + all_syllabuses = Course.where("is_end = 0 and is_delete = 0 and name like '%#{@search}%'") @syllabuses = all_syllabuses end @@ -1849,9 +1848,9 @@ class CoursesController < ApplicationController #sheet1.row(0).default_format = blue #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) sheet1[0,0] = "课程编号" - sheet1[0,1] = course.syllabus.id + sheet1[0,1] = course.course_list_id sheet1[1,0] = "课程名称" - sheet1[1,1] = course.syllabus.title + sheet1[1,1] = course.course_list_name sheet1[2,0] = "班级编号" sheet1[2,1] = course.id sheet1[3,0] = "班级名称" @@ -1902,9 +1901,9 @@ class CoursesController < ApplicationController homeworks.each_with_index do |home, i| sheet = book.create_worksheet :name => "第#{i+1}次作业" sheet[0,0] = "课程编号" - sheet[0,1] = course.syllabus.id + sheet[0,1] = course.course_list_id sheet[1,0] = "课程名称" - sheet[1,1] = course.syllabus.title + sheet[1,1] = course.course_list_name sheet[2,0] = "班级编号" sheet[2,1] = course.id sheet[3,0] = "班级名称" diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 5a8dce761..75ba90e1b 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -600,7 +600,7 @@ class FilesController < ApplicationController attachment.save resource_bank = ResourceBank.create(:course_id => @course.id, :attachment_id => attachment.id, :filename => attachment.filename, :disk_filename => attachment.disk_filename, :filesize => attachment.filesize, :digest => attachment.digest, :downloads => 0, :user_id => attachment.author_id, :description => attachment.description, :disk_directory => attachment.disk_directory, :is_public => attachment.is_public, :copy_from => attachment.copy_from, - :quotes => 1, :applicable_syllabus => @course.syllabus.title, :major_level => @course.syllabus.major_level, :discipline_category_id => @course.syllabus.discipline_category_id, :first_level_discipline_id => @course.syllabus.first_level_discipline_id, :content_type => attachment.content_type) + :quotes => 1, :applicable_syllabus => @course.course_list_name, :content_type => attachment.content_type) attachment.update_column('resource_bank_id', resource_bank.id) end end diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 3031dccbc..660596a56 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -3,7 +3,7 @@ class GamesController < ApplicationController layout "base_myshixun" skip_before_filter :verify_authenticity_token, :only => [:file_update] before_filter :find_myshixun, :only => [:index] - before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :get_waiting_time, + before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time, :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice] before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show] before_filter :allowd_manager @@ -94,7 +94,7 @@ class GamesController < ApplicationController @language = @game_challenge.shixun.language 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?}") - @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ').to_json unless error_position.try(:out_put).blank? + @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ').to_json unless error_position.try(:out_put).blank? logger.info(@latest_output) respond_to do |format| @@ -163,7 +163,7 @@ class GamesController < ApplicationController raise("实训云平台繁忙(繁忙等级:94)") end render :json => {:result => "success", :onRun => res['onRun'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :resubmit => resubmit } - #render :json => {:result => "success", :onRun => 1, :waitNum => 12, :waitingTime => 546 } + #render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 } rescue Exception => e render :json => {:result => "failed"} end @@ -278,6 +278,7 @@ class GamesController < ApplicationController @final_score = ((@game.answer_open? || shixun.status <= 1) ? 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? + logger.info("@compile_success###################{@compile_success}") @language = game_challenge.shixun.language render :json => {test_sets: total_test_sets, test_sets_count: @test_sets_count, @@ -293,7 +294,9 @@ class GamesController < ApplicationController had_done: had_done, language: @language, score: score, - tag_count: tag_count} + tag_count: tag_count, + position: game_challenge.position + } end # 选择题评测(选择题不需要重新评测) @@ -343,7 +346,7 @@ class GamesController < ApplicationController if @game.outputs.blank? Output.create(:game_id => @game.id, :actual_output => user_answer, :result => correct) end - render :json => {correct: correct, had_done: had_done, :grade => User.where(:id => User.current.id).first.grade, score: score, tag_count: tag_count} + render :json => {correct: correct, had_done: had_done, :grade => User.where(:id => User.current.id).first.grade, score: score, tag_count: tag_count, position: @game_challenge.position} end @@ -391,6 +394,13 @@ class GamesController < ApplicationController end end + def prev_step + prev_game = @game.prev_game + respond_to do |format| + format.js{ redirect_to myshixun_game_path(prev_game, :myshixun_id => @myshixun)} + end + end + # 获取答案,第一次查看需扣掉该关卡的积分 # 如果已看过,下次可以免费查看 # viewed 1: 直接查看 2:弹框提示将要扣除积分,确定后显示内容 3:弹框提示分数不够 @@ -504,10 +514,11 @@ class GamesController < ApplicationController unless test_sets.blank? test_sets.each do |test_set| output = Output.where(:game_id => @game.id, :test_set_position => test_set.position).first - actual_output = (output.try(:actual_output).gsub(/\n/, '
').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) + actual_output = (output.try(:actual_output).gsub(/\n/, '
').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) result = output.try(:result) + compile_success = (actual_output.blank? || !actual_output.match(/error/).blank?) ? 0 : 1 public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :input => test_set.input, - :actual_output => actual_output, :output => test_set.output} + :actual_output => actual_output, :output => test_set.output, :compile_success => compile_success} logger.info("1111#################################{public_result.to_json}") test_result << public_result.to_json end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 315a69d9d..4019e1110 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -5,6 +5,7 @@ class HomeworkCommonController < ApplicationController layout "base_courses" include StudentWorkHelper + include ApplicationHelper before_filter :find_course, :only => [:index,:new,:create] before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set, :set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works, @@ -332,6 +333,15 @@ class HomeworkCommonController < ApplicationController end if @homework.homework_type == 4 + if @homework_detail_manual.answer_open_evaluation != params[:answer_open_evaluation].to_i + @homework_detail_manual.answer_open_evaluation = params[:answer_open_evaluation].to_i + if @homework.end_time < Time.now + @homework.student_works.each do |student_work| + set_shixun_final_score @homework, student_work, @homework_detail_manual.answer_open_evaluation + student_work.save + end + end + end @homework.score_open = params[:homework_score_open] ? 1 : 0 else @homework.work_public = params[:homework_work_public] ? 1 : 0 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 0e05db265..448868c08 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -109,16 +109,18 @@ class MyshixunsController < ApplicationController resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) jenkins_testsets = jsonTestDetails['msg'] + compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? logger.info(outPut) + logger.info("##################"+ compile_success) game = Game.find(game_id) challenge = game.challenge unless jenkins_testsets.blank? jenkins_testsets.each do |j_test_set| actual_output = tran_base64_decode64(j_test_set['output']) game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], - :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index) - + :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i) + logger.info("compile_success:"+ compile_success) # output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first # logger.info("#############{outPut}") # if output.nil? diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5fa93690f..9f16575b8 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -381,19 +381,31 @@ class ShixunsController < ApplicationController redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun) return end - repository = @shixun.repository ActiveRecord::Base.transaction do begin - @g = Gitlab.client + shixun_tomcat = Redmine::Configuration['shixun_tomcat'] + code = down_generate_identifier("myshixun") + myshixun = Myshixun.create!(:shixun_id => @shixun.id, :user_id => User.current.id, :identifier => code) + # fork版本库,如果用户没有同步,则先同步用户 + g = Gitlab.client if User.current.gid.nil? s = Trustie::Gitlab::Sync.new s.sync_user(User.current) end - gshixun = @g.fork(@shixun.gpid, User.current.gid) - logger.info("#############gshixun is #{gshixun}") - if !gshixun.id.nil? - # 防止fork多次的问题 - myshixun = copy_myshixun(@shixun, gshixun) + gshixun = g.fork(@shixun.gpid, User.current.gid) + if !gshixun.try(:id).blank? + myshixun.update_column(:gpid, gshixun.id) if myshixun.try(:gpid).blank? # 为了防止多次fork + rep = Repository.create!(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2) + rep.update_column(:type, "Repository::Gitlab") + rep_url = Base64.urlsafe_encode64(git_shixun_url_ip @shixun, "educoder") # 注意:educoder为默认给实训创建版本库的用户,如果换成别的用户,名字要相应的修改 + uri = "#{shixun_tomcat}/bridge/game/openGameInstance" + params = {tpiID: "#{myshixun.id}", tpmID: "#{@shixun.id}", instanceGitURL:rep_url, operationEnvironment:"#{@shixun.try(:language)}"} + logger.info("openGameInstance params is #{params}") + res = uri_exec uri, params + if (res && res['code'].to_i != 0) + raise("实训云平台繁忙(繁忙等级:83)") + end + # 其它操作 challenges = @shixun.challenges # 之所以增加user_id是为了方便统计查询性能 challenges.each_with_index do |challenge, index| @@ -420,7 +432,7 @@ class ShixunsController < ApplicationController rescue Exception => e flash[:error] = e.message logger.info("failed to exec shixun: current task id is #{e}") - @g.delete_project(gshixun.id) if !gshixun.id.nil? + g.delete_project(gshixun.id) if !gshixun.id.nil? redirect_to shixun_challenges_path(@shixun) raise ActiveRecord::Rollback end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d9ab8c00..dc1efc6fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -267,6 +267,26 @@ module ApplicationHelper end end + # 已通过的关卡数 返回int类型(包含查看参考答案的) + def had_passed_changllenge_num shixun, user + myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => user.id).first + if myshixun.nil? + 0 + else + myshixun.games.select{|game| game.status == 2}.count + end + end + + # 已通过的关卡数 返回int类型(未查看参考答案) + def had_passed_no_ans_changllenge_num shixun, user + myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => user.id).first + if myshixun.nil? + 0 + else + myshixun.games.select{|game| game.status == 2 && game.answer_open == 0}.count + end + end + # TPI状态 :已通关、未通关、未开启 def my_shixun_status shixun, user status = "" @@ -4875,8 +4895,8 @@ end def add_to_homework_bank_f homework homework_bank = HomeworkBank.new(:name => homework.name, :description => homework.description, :user_id => User.current.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, - :reference_answer => homework.reference_answer, :syllabus_id => homework.course.syllabus_id) + :quotes => 1, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.course_list_name, :homework_common_id => homework.id, + :reference_answer => homework.reference_answer, :course_list_id => homework.course.course_list_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| @@ -5061,13 +5081,13 @@ def visable_course_homework course, type=0 if type != 0 homework_num = course.homework_commons.where(:homework_type => type).count else - homework_num = course.homework_commons.count + homework_num = course.homework_commons.where(:homework_type => [1, 4]).count end else if type != 0 homework_num = course.homework_commons.where(:homework_type => type).where("publish_time <= '#{Time.now}'").count else - homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count + homework_num = course.homework_commons.where("homework_type in '(1, 4)' and publish_time <= '#{Time.now}'").count end end homework_num @@ -5198,6 +5218,17 @@ def set_final_score homework,student_work end end +# 实训作业的评分 +def set_shixun_final_score homework, student_work, answer_open_evaluation + unless student_work.work_status == 0 + shixun = homework.homework_commons_shixuns.shixun + passed_count = answer_open_evaluation ? had_passed_changllenge_num(shixun, student_work.user) : had_passed_no_ans_changllenge_num(shixun, student_work.user) + final_score =(passed_count.to_f / shixun.challenges.count) * 100 + student_work.final_score = format("%.2f",final_score.to_f) + score = student_work.final_score - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + 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, diff --git a/app/models/challenge.rb b/app/models/challenge.rb index db15195a1..dcc50dd43 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -34,6 +34,11 @@ class Challenge < ActiveRecord::Base Challenge.where(:position => (self.position + 1), :shixun_id => self.shixun).first end + def prev_challenge + render_404 if self.position == 1 + Challenge.where(:position => (self.position - 1), :shixun_id => self.shixun).first + end + def last_challenge render_404 if self.position < 2 position = self.position - 1 diff --git a/app/models/game.rb b/app/models/game.rb index 03d1d58ae..9485f2a15 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -46,6 +46,14 @@ class Game < ActiveRecord::Base return game end + def prev_game + challenge = self.challenge + prev_challenge_id = challenge.prev_challenge + game = Game.where(:myshixun_id => self.myshixun_id, :challenge_id => prev_challenge_id).first + render_404 if game.nil? + return game + end + # 获取game最新的一条输出结果 def latest_output outputs = Output.where(:game_id => self.id).order("created_at desc") diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 961aabc9d..49b9d9fb2 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -126,7 +126,7 @@ class HomeworkCommon < ActiveRecord::Base count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count if count == 0 ws = WechatService.new - name = self.course.syllabus.nil? ? self.course.name : self.course.syllabus.title+" • "+self.course.name + name = self.course.course_list.nil? ? self.course.name : self.course.course_list_name+" • "+self.course.name ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}", name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。") end end diff --git a/app/models/homework_detail_manual.rb b/app/models/homework_detail_manual.rb index de289b54f..ffdeda060 100644 --- a/app/models/homework_detail_manual.rb +++ b/app/models/homework_detail_manual.rb @@ -1,7 +1,7 @@ #手动评分作业表 #comment_status: 0:挂起, 1:提交,2:补交(去掉),3:匿评中,4:申诉中,5:评阅中,6:已结束 class HomeworkDetailManual < ActiveRecord::Base - attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id, :no_anon_penalty + attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id, :no_anon_penalty, :answer_open_evaluation belongs_to :homework_common end diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index cf0579655..3986aedd1 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -1,6 +1,6 @@ # status 1:完成实训 class Myshixun < ActiveRecord::Base - attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier + attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier, :shixun_id # has_many :users, :through => :myshixun_members has_many :myshixun_members, :dependent => :destroy has_one :repository, :dependent => :destroy @@ -32,7 +32,7 @@ class Myshixun < ActiveRecord::Base time = 0 self.games.each do |game| if game.status == 2 - time += (game.end_time -game.open_time).to_i > 0 ? (game.end_time -game.open_time).to_i : 0 + time += (game.end_time.to_i - game.open_time.to_i) > 0 ? (game.end_time.to_i - game.open_time.to_i) : 0 end end time diff --git a/app/models/output.rb b/app/models/output.rb index 6c833b091..4ce462eff 100644 --- a/app/models/output.rb +++ b/app/models/output.rb @@ -1,6 +1,7 @@ class Output < ActiveRecord::Base # attr_accessible :title, :body # actual_output 编程题:实际输出, 选择题: 用户提交的答案(如: 014 对应用户选择为A B E) + # compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错! default_scope :order => 'query_index desc' belongs_to :game diff --git a/app/models/repository.rb b/app/models/repository.rb index 672696c27..a1be972e5 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -56,7 +56,10 @@ class Repository < ActiveRecord::Base 'path_encoding', 'log_encoding', 'is_default', - 'type' + 'type', + 'myshixun_id', + 'shixun_id', + 'project_id' safe_attributes 'url', :if => lambda {|repository, user| repository.new_record?} diff --git a/app/models/student_work.rb b/app/models/student_work.rb index cc800cbb6..8d5cad339 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -13,7 +13,7 @@ class StudentWork < ActiveRecord::Base # course's message has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :attachments, :dependent => :destroy - has_one :myshixun + belongs_to :myshixun scope :has_committed, lambda{where("work_status != 0 and work_status != 3")} scope :all_commit, lambda{where("work_status != 0")} @@ -51,7 +51,7 @@ class StudentWork < ActiveRecord::Base #成绩计算 def set_final_score homework,student_work - if homework && homework.homework_detail_manual + if homework && homework.homework_type != 4 && homework.homework_detail_manual if homework.homework_type != 2 #非编程作业 if homework.teacher_priority == 1 #教师优先 if student_work.teacher_score diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 33c90383c..745f0e938 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -584,7 +584,7 @@ class CoursesService type = "review_class_member" end - name = course.syllabus.nil? ? course.name : course.syllabus.title+" • "+course.name + name = course.course_list.nil? ? course.name : course.course_list_name+" • "+course.name ws = WechatService.new ws.class_notice user.id, type, course.id, title,name, user.show_name, format_time(Time.now), content, remark,uid @@ -689,7 +689,7 @@ class CoursesService rolename = role_ids.include?("7") ? "助教" : "教师" content = current_user.show_name + "申请以"+rolename+"身份加入班级,等待您的审批。" - name = course.syllabus.nil? ? course.name : course.syllabus.title+" • "+course.name + name = course.course_list.nil? ? course.name : course.course_list_name+" • "+course.name ws = WechatService.new ws.class_notice tea_user.id, "review_class_member", course.id, "班级成员审批通知。", name, tea_user.show_name, format_time(Time.now), content, "点击查看申请详情。",current_user.id end diff --git a/app/views/challenges/_edit_evaluating.html.erb b/app/views/challenges/_edit_evaluating.html.erb index bbc795b3a..f7190a85e 100644 --- a/app/views/challenges/_edit_evaluating.html.erb +++ b/app/views/challenges/_edit_evaluating.html.erb @@ -35,9 +35,7 @@
  • 测试集<%= index + 1 %> - <% if test.is_public? %> - - <% else %> + <% unless test.is_public? %> <% end %>

    @@ -62,5 +60,14 @@ $("#edit_task_pass").click(function(){ $("#evaluating_edit").show(); $("#evaluating_show").hide(); + // 设置textarea的宽度到140以后出现滚动条 + var test_set_inputs = document.getElementsByName("test_set[input][]"); + var test_set_outputs = document.getElementsByName("test_set[output][]"); + if (test_set_inputs.length == test_set_outputs.length) { + for (var i = 0; i < test_set_inputs.length; i++) { + autoTextarea(test_set_inputs[i], 0, 140); + autoTextarea(test_set_outputs[i], 0, 140); + } + } }) \ No newline at end of file diff --git a/app/views/challenges/_evaluating_form.html.erb b/app/views/challenges/_evaluating_form.html.erb index 80ad18a7c..197860477 100644 --- a/app/views/challenges/_evaluating_form.html.erb +++ b/app/views/challenges/_evaluating_form.html.erb @@ -157,15 +157,6 @@ }); }); - // 设置textarea的宽度到140以后出现滚动条 - var test_set_inputs = document.getElementsByName("test_set[input][]"); - var test_set_outputs = document.getElementsByName("test_set[output][]"); - if (test_set_inputs.length == test_set_outputs.length) { - for (var i = 0; i < test_set_inputs.length; i++) { - autoTextarea(test_set_inputs[i], 0, 140); - autoTextarea(test_set_outputs[i], 0, 140); - } - } // 判断测试集是否锁定, 0未锁定,1锁定 function test_set_whether_lock(){ var lock = document.getElementsByName("test_set[lock][]"); diff --git a/app/views/challenges/edit.html.erb b/app/views/challenges/edit.html.erb index 1fb2c7480..69c247478 100644 --- a/app/views/challenges/edit.html.erb +++ b/app/views/challenges/edit.html.erb @@ -58,9 +58,11 @@
  • "> 参考答案
  • - + <% unless @challenge.ready_knowledge.blank? %> +
  • "> + 背景知识 +
  • + <% end %>
  • "> 评分设置
  • @@ -79,8 +81,8 @@ <%= render :partial => "edit_scoring" %> <% elsif @tab == 5 %> <%= render :partial => "edit_skill" %> - <%# elsif @tab == 6 %> - <%#= render :partial => "edit_propaedeutics" %> + <% elsif @tab == 6 %> + <%= render :partial => "edit_propaedeutics" %> <% end %> diff --git a/app/views/courses/_course_index_search.html.erb b/app/views/courses/_course_index_search.html.erb index 3c07cd79c..7a8c2bdce 100644 --- a/app/views/courses/_course_index_search.html.erb +++ b/app/views/courses/_course_index_search.html.erb @@ -1,33 +1,17 @@ -
    +
    - +
    \ No newline at end of file diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 49dd1a06e..4036e3af8 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -13,10 +13,10 @@
    - @is_end,:search => @search) %>" id="courses_index_syllabuses_1" class="course_filtrate fl course_filtrate_bg" data-tab="all" data-remote="true">全部课堂 - @is_end, :search => @search) %>" id="courses_index_syllabuses_2" class="course_filtrate fl" data-tab="create" data-remote="true">我管理的 - @is_end, :search => @search) %>" id="courses_index_syllabuses_3" class="course_filtrate fl" data-tab="join" data-remote="true">我参与的 - 1) %>" id="courses_index_syllabuses_4" class="course_filtrate fl" data-tab="end" data-remote="true">查看归档 + @search) %>" id="courses_index_syllabuses_1" class="edu-filter-cir-grey mr20 active fl" data-tab="all" data-remote="true">全部课堂 + @search) %>" id="courses_index_syllabuses_2" class="edu-filter-cir-grey mr20 fl" data-tab="create" data-remote="true">我管理的 + @search) %>" id="courses_index_syllabuses_3" class="edu-filter-cir-grey mr20 fl" data-tab="join" data-remote="true">我参与的 + " id="courses_index_syllabuses_4" class="edu-filter-cir-grey fl" data-tab="end" data-remote="true">查看归档 diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index c1bd54ac9..845f54feb 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -1,5 +1,5 @@ - + <% if @st == 0 %>
    "> 加载上次通过的代码 @@ -12,6 +12,12 @@ 评测 <% end %>
    +
    + <% if @game.challenge.position > 1 %> + <%= link_to "上一关 ", {:controller => 'games', :action => "prev_step", :id => @game, :myshixun_id => @myshixun}, + :class => "shixun-task-btn task-btn-blue mr15 mt8", :id => "prev_step", :remote => true %> + <% end %> +
    <% if @game.status == 1 %> 评测中.. @@ -72,15 +78,6 @@ $("#time-consuming").html("耗时:" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "); } - /* -----------------下一关增加loading效果--------------------- */ - $("#next_step").live("click", function(){ - if($("#next_step").attr("href") != "javascript:void(0);"){ - nNext = $("#code_estimate"); - html = "下一关"; - nNext.html(html); - } - }); - // 选择题提交评测 // answer 选择的答案 function choice_submmit(){ @@ -163,7 +160,11 @@ $("#code_estimate").html("下一关"); } else if($("#exit_shixun").length > 0){ $("#code_estimate").html("退出实训"); - }$(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面 + } + if($("#prev_step").length > 0){ + $("#prev_step_area").html("上一关"); + } + $(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面 // 保存版本库代码 var fileUpdateUrl = $("#current_repository_path").html(); $.ajax({ @@ -221,7 +222,8 @@ data.had_passed_testsests_public_count, data.final_score, data.latest_output, - data.language + data.language, + data.compile_success ); $("#blacktab_nav_1").trigger("click"); if(data.status == 2){ @@ -251,6 +253,9 @@ } var html = "评测"; $("#code_test").html(html); // 恢复评测 + if(data.position > 1){ + $("#prev_step_area").html("上一关") + } var codeEstimate = $("#code_estimate").children("a").html(); if(codeEstimate == undefined){ return; diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 14b5af39f..f651c1fec 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -21,7 +21,7 @@ \ No newline at end of file diff --git a/app/views/messages/_common_reply_box.html.erb b/app/views/messages/_common_reply_box.html.erb index 947f6892b..f770a3de0 100644 --- a/app/views/messages/_common_reply_box.html.erb +++ b/app/views/messages/_common_reply_box.html.erb @@ -59,7 +59,7 @@
    <% end %>
    - <% end %>‘ + <% end %>
    <%= comment.content_detail.html_safe %>
    diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index a6583fef3..d162ee613 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -316,27 +316,11 @@ $(".lesson_item").scrollTop(0); $(".shou_up").hide(); $(".geng_down").show(); - }) - //点击搜索图标,显示搜索框 - $(".search_icon").click(function(){ - console.log($("#shixun_index_search_form").serialize()); - if($(".searchCon").is(":visible")){ - $.ajax({ - url: '/shixuns/search', - type: 'post', - data: $("#shixun_index_search_form").serialize(), - remote: true, - success: function(data){ - } - }); - } else{ - $(".searchCon").show(); - } - }) + }); }); $(".searchCon").on("keydown", "input[name='search']", function(event){ - var target, code, tag; + var code; if (!event) { event = window.event; //针对ie浏览器 code = event.keyCode; @@ -352,34 +336,26 @@ //搜索实训 function search_shixun(){ - console.log($("#shixun_index_search_form").serialize()); - if($(".searchCon").is(":visible")){ - $.ajax({ - url: '/shixuns/search', - type: 'post', - data: $("#shixun_index_search_form").serialize(), - remote: true, - success: function(data){ - } - }); - } else{ - $(".searchCon").show(); - } + $.ajax({ + url: '/shixuns/search', + type: 'post', + data: $("#shixun_index_search_form").serialize(), + remote: true, + success: function(data){ + } + }); } //关闭搜索框 function colse_searchbox(){ - $('.searchCon').hide(); - if($('.searchinput').val().trim() != ""){ - $('.searchinput').val(''); - $.ajax({ - url: '/shixuns/search', - type: 'post', - data: $("#shixun_index_search_form").serialize(), - remote: true, - success: function(data){ - } - }); - } + $('.searchinput').val(''); + $.ajax({ + url: '/shixuns/search', + type: 'post', + data: $("#shixun_index_search_form").serialize(), + remote: true, + success: function(data){ + } + }); } // 新建实训 diff --git a/app/views/shixuns/propaedeutics.html.erb b/app/views/shixuns/propaedeutics.html.erb index d07951cc9..fd53b5546 100644 --- a/app/views/shixuns/propaedeutics.html.erb +++ b/app/views/shixuns/propaedeutics.html.erb @@ -10,7 +10,7 @@

    背景知识

    - <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>
    diff --git a/app/views/student_work/_evaluation_un_shixun_work.html.erb b/app/views/student_work/_evaluation_un_shixun_work.html.erb index 9423f400c..974d6698a 100644 --- a/app/views/student_work/_evaluation_un_shixun_work.html.erb +++ b/app/views/student_work/_evaluation_un_shixun_work.html.erb @@ -13,12 +13,12 @@ <%= student_work.work_status == 0 ? '--' : format_time(student_work.updated_at) %> - <%= student_work.work_status == 0 ? '--' : had_passed_changllenge_count(shixun, student_work.user).to_s+"/"+shixun.challenges.count.to_s %> + <%= student_work.work_status == 0 ? '--' : had_passed_changllenge_num(shixun, student_work.user).to_s+"/"+shixun.challenges.count.to_s %> <% if student_work.work_status != 0 %> <% end %> diff --git a/app/views/student_work/_shixun_work_show.html.erb b/app/views/student_work/_shixun_work_show.html.erb index 961683f78..a5d8c4d3d 100644 --- a/app/views/student_work/_shixun_work_show.html.erb +++ b/app/views/student_work/_shixun_work_show.html.erb @@ -22,8 +22,8 @@
  • 通关时间: <%= @myshixun.try(:status) == 1 ? (format_time @myshixun.done_time) : '- -' %>
    • -
    • 通关情况:<%= had_passed_changllenge_count(@shixun, @work.user).to_s+" / "+@shixun.challenges.count.to_s %>
    • -
    • 总耗时:<%=had_passed_changllenge_count(@shixun, @work.user) > 0 ? game_spend_time(total_spend_time @myshixun) : '- -' %>
    • +
    • 通关情况:<%= had_passed_changllenge_num(@shixun, @work.user).to_s+" / "+@shixun.challenges.count.to_s %>
    • +
    • 总耗时:<%=had_passed_changllenge_num(@shixun, @work.user) > 0 ? game_spend_time(@myshixun.total_spend_time) : '- -' %>
    @@ -41,7 +41,7 @@ 第<%= index + 1 %>关 - <%= game.status == 2 ? game_spend_time((game.end_time - game.open_time).to_i) : '- -' %> + <%= game.status == 2 ? game_spend_time(game.end_time.to_i - game.open_time.to_i) : '- -' %> <%= game.status == 2 ? game.final_score : '- -' %> <% end %> diff --git a/app/views/subjects/show.html.erb b/app/views/subjects/show.html.erb index dba8bf235..bcf04f61c 100644 --- a/app/views/subjects/show.html.erb +++ b/app/views/subjects/show.html.erb @@ -21,7 +21,7 @@

    第<%= s_index + 1 %>章  <%= stage.name %> - <% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %> + <% if User.current.manager_of_subject?(@subject) %> <% else %> @@ -74,7 +74,7 @@ <% if is_modify.blank? %> <%= link_to "模拟实战", shixun_exec_shixun_path(shixun), :class => "task-btn task-btn-green ", :style=>"display: none", :id => "shixun_operation", :target => "_blank" %> <% else %> - + <% end %> <% end %> <% end %> @@ -93,7 +93,7 @@ <% end %>

    - <% if @subject.status == 0 && User.current.manager_of_subject?(@subject) %> + <% if User.current.manager_of_subject?(@subject) %>
    <% if @stages.count == 0 %> <%= form_for('', :url => {:controller => 'stages', :action => 'create', :subject => @subject.id}, :method => "post", :html => {:id => 'new_stage_form'}) do |f| %> diff --git a/app/views/syllabuses/index.html.erb b/app/views/syllabuses/index.html.erb index ecb82bfd1..f87bbdc4b 100644 --- a/app/views/syllabuses/index.html.erb +++ b/app/views/syllabuses/index.html.erb @@ -10,10 +10,10 @@ <%=link_to "全部", syllabuses_path(:tab => 1), :class => "tab_type", :remote => true %>
  • - <%=link_to "我的发布", syllabuses_path(:tab => 2), :class => "tab_type", :remote => true %> + <%=link_to "我管理的", syllabuses_path(:tab => 2), :class => "tab_type", :remote => true %>
  • - <%=link_to "我的参与", syllabuses_path(:tab => 3), :class => "tab_type", :remote => true %> + <%=link_to "我参与的", syllabuses_path(:tab => 3), :class => "tab_type", :remote => true %>
  • diff --git a/app/views/users/_myshixuns_list.html.erb b/app/views/users/_myshixuns_list.html.erb index ad0da9cc1..e6d5890b0 100644 --- a/app/views/users/_myshixuns_list.html.erb +++ b/app/views/users/_myshixuns_list.html.erb @@ -5,7 +5,7 @@ <% @shixuns.each do |shixun| %>
    - <%= shixun.name %> + <%= shixun.name %>

    <%= shixun.language %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 3e9289d05..b3ffa379e 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -97,6 +97,7 @@

    + <% update_visiti_count @user %> <% if current_user %>
    @@ -105,7 +106,6 @@

    - <% update_visiti_count @user %> <%= @user.visits.to_i %> 次访问

    diff --git a/config/routes.rb b/config/routes.rb index bc1a8e856..7a9413b83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -140,6 +140,7 @@ RedmineApp::Application.routes.draw do match 'game_build', :via => [:get, :post] match 'get_waiting_time', :via => [:get, :post] match 'next_step', :via => [:get, :post] + match 'prev_step', :via => [:get, :post] match 'reset_original_code', :via => [:get, :post] match 'reset_new_code', :via => [:get, :post] get 'entry' diff --git a/db/migrate/20170907025441_add_compile_success_to_outputs.rb b/db/migrate/20170907025441_add_compile_success_to_outputs.rb new file mode 100644 index 000000000..ce0436c36 --- /dev/null +++ b/db/migrate/20170907025441_add_compile_success_to_outputs.rb @@ -0,0 +1,5 @@ +class AddCompileSuccessToOutputs < ActiveRecord::Migration + def change + add_column :outputs, :compile_success, :integer, :default => 1 + end +end diff --git a/db/migrate/20170907061723_modify_compile_success_to_outputs.rb b/db/migrate/20170907061723_modify_compile_success_to_outputs.rb new file mode 100644 index 000000000..c694d324a --- /dev/null +++ b/db/migrate/20170907061723_modify_compile_success_to_outputs.rb @@ -0,0 +1,13 @@ +class ModifyCompileSuccessToOutputs < ActiveRecord::Migration + def up + error_output = Output.find_by_sql("SELECT * FROM `outputs` where actual_output like '%error%'") + unless error_output.blank? + error_output.each do |e| + e.update_column(:compile_success, 0) + end + end + end + + def down + end +end diff --git a/db/migrate/20170908020109_add_answer_open_evaluation_to_homework_detail_manuals.rb b/db/migrate/20170908020109_add_answer_open_evaluation_to_homework_detail_manuals.rb new file mode 100644 index 000000000..a82ccd762 --- /dev/null +++ b/db/migrate/20170908020109_add_answer_open_evaluation_to_homework_detail_manuals.rb @@ -0,0 +1,5 @@ +class AddAnswerOpenEvaluationToHomeworkDetailManuals < ActiveRecord::Migration + def change + add_column :homework_detail_manuals, :answer_open_evaluation, :boolean, :default => false + end +end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index f55491879..36cff6723 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -2,6 +2,22 @@ namespace :homework_publishtime do desc "start publish homework and end homework" + def had_passed_changllenge_num_rake myshixun + if myshixun.nil? + 0 + else + myshixun.games.select{|game| game.status == 2}.count + end + end + + def had_passed_no_ans_changllenge_num_rake myshixun + if myshixun.nil? + 0 + else + myshixun.games.select{|game| game.status == 2 && game.answer_open == 0}.count + end + end + task :publish => :environment do Rails.logger.info("log--------------------------------homework_publish start") homework_commons = HomeworkCommon.includes(:homework_detail_manual).where("publish_time <= '#{Time.now}' and homework_detail_manuals.comment_status = 0") @@ -43,13 +59,20 @@ namespace :homework_publishtime do end task :end => :environment do - # Rails.logger.info("log--------------------------------homework_publish_end start") - # homework_commons = HomeworkCommon.includes(:homework_detail_manual).where("end_time <= '#{Time.now}' and allow_late = 1 and homework_detail_manuals.comment_status = 1") - # homework_commons.each do |homework| - # homework_detail_manual = homework.homework_detail_manual - # homework_detail_manual.update_column('comment_status', 2) - # end - # Rails.logger.info("log--------------------------------homework_publish_end end") + Rails.logger.info("log--------------------------------homework_publish_end start") + homework_commons = HomeworkCommon.includes(:homework_detail_manual).where("homework_type = 4 and end_time <= '#{Time.now}' and homework_detail_manuals.comment_status = 1") + homework_commons.each do |homework| + homework.homework_detail_manual.update_column("comment_status", 2) + shixun = homework.homework_commons_shixuns.shixun + homework.student_works.where("work_status != 0").each do |student_work| + passed_count = homework.homework_detail_manual.answer_open_evaluation ? had_passed_changllenge_num_rake(student_work.myshixun) : had_passed_no_ans_changllenge_num_rake(student_work.myshixun) + final_score =(passed_count.to_f / shixun.challenges.count) * 100 + student_work.update_column("final_score", format("%.2f",final_score.to_f)) + score = final_score - student_work.late_penalty + student_work.update_column("work_score", format("%.2f",(score < 0 ? 0 : score).to_f)) + end + end + Rails.logger.info("log--------------------------------homework_publish_end end") end task :archive => :environment do @@ -58,6 +81,17 @@ namespace :homework_publishtime do homework_commons.each do |homework| homework_detail_manual = homework.homework_detail_manual homework_detail_manual.update_column('comment_status', 6) + if homework.homework_type == 4 + shixun = homework.homework_commons_shixuns.shixun + homework.student_works.where("work_status != 0").each do |student_work| + passed_count = homework.homework_detail_manual.answer_open_evaluation ? had_passed_changllenge_num_rake(student_work.myshixun) : had_passed_no_ans_changllenge_num_rake(student_work.myshixun) + final_score =(passed_count.to_f / shixun.challenges.count) * 100 + student_work.final_score = format("%.2f",final_score.to_f) + score = student_work.final_score - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + student_work.save + end + end end Rails.logger.info("log--------------------------------homework_archive end") end diff --git a/public/javascripts/edu/application.js b/public/javascripts/edu/application.js index 7cb44a635..617a103e2 100644 --- a/public/javascripts/edu/application.js +++ b/public/javascripts/edu/application.js @@ -1220,7 +1220,7 @@ function search_course_ajax(str){ if($(".course_list_ul").find("li").length>5){ $(".course_list_ul").css("overflow-y","scroll"); } else{ - $(".course_list_ul").css("overflow-y","auto"); + $(".course_list_ul").css("overflow-y","hidden"); } } else{ $(".course_list_ul").hide(); diff --git a/public/javascripts/edu/base_edu.js b/public/javascripts/edu/base_edu.js index 1ebf1970d..48ea8ac4b 100644 --- a/public/javascripts/edu/base_edu.js +++ b/public/javascripts/edu/base_edu.js @@ -180,7 +180,27 @@ $(function(){ allowBlank:true, lang:'ch', format:'Y-m-d H:i', - validateOnBlur:false + validateOnBlur:false, + onSelectDate:function() { + if($.trim($("input[name='homework_end_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14)))); + } + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/"))); + $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1)))); + } + }, + onSelectTime:function() { + if($.trim($("input[name='homework_end_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14)))); + } + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_end_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({ diff --git a/public/javascripts/edu/course.js b/public/javascripts/edu/course.js index 407cea3a3..db3dba311 100644 --- a/public/javascripts/edu/course.js +++ b/public/javascripts/edu/course.js @@ -133,58 +133,32 @@ $(function() { } }); - -// var changeColor = function(c){ -// if(c.find(".blue").css("display") == "none") { -// c.find(".blue").show(); -// c.find(".grey").hide(); -// c.find("input").attr("checked", "checked"); -// -// } else { -// c.find(".blue").hide(); -// c.find(".grey").show(); -// c.find("input").removeAttr("checked"); -// -// } -// }; -// $(".open-select").click(function() { -// changeColor($(this)); -// if($("#allselect").find("input").is(':checked')) { -// //console.log(1); -// $(".member .student .newstudent .open-select").find("input").attr("checked", "checked"); -// $(".member .student .newstudent .open-select").find(".blue").show(); -// $(".member .student .newstudent .open-select").find(".grey").hide(); -// } -// var $length = $(".member .student .newstudent .open-select input").length; -// var flag = true; -// for(i = 0; i < $length; i++) { -// var $b = $(".member .student .newstudent .open-select input").eq(i); -// if(! $b.is(':checked')) { -// //console.log(1) -// flag = false; -// break; -// } -// if(flag) { -// $("#allselect").find("input").attr("checked", "checked"); -// $("#allselect").find(".blue").show(); -// $("#allselect").find(".grey").hide(); -// } -// } -// }); -// var RadioButton = function(b,c){ -// $(b).find(".grey").show(); -// $(b).find(".blue").hide(); -// $(b).find("input").removeAttr("checked"); -// changeColor(c); -// }; -// $(".single-choice1").click(function(){ -// -// RadioButton(".single-choice1",$(this)); -// }); -// $(".single-choice2").click(function(){ -// -// RadioButton(".single-choice2",$(this)); -// }); + // 课堂设置 + $("#edit_course_list").on('input', function(e){ + throttle(search_course_list, window, e); + }); + $("#edit_course_list").on('click', function (e) { + if ($("#edit_course_list").val().trim() != '') { //如果已经有id了。肯定存在,不用去找了。 + event.stopPropagation(); + return; + } else{ + event.stopPropagation(); + search_course_ajax(''); + } + }); + $("#edit_course_list").on('blur', function(e){ + if($("#edit_course_name").val() == ""){ + $("#edit_course_name").val($("#edit_course_list").val()); + } else{ + if($("#edit_course_name").val().indexOf(course_list_name) == 0){ + $("#edit_course_name").val($("#edit_course_name").val().replace(course_list_name, $("#edit_course_list").val())); + } else{ + $("#edit_course_name").val($("#edit_course_list").val() + $("#edit_course_name").val()); + } + } + course_list_name = $("#edit_course_list").val(); + regex_course_name('edit'); + }); }); function add_new_group(id){ diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index c000ceba9..d9b011ad7 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -110,6 +110,14 @@ $(function(){ }); // end + // 上一关增加loading效果 + $("#prev_step").live("click", function(){ + nNext = $("#prev_step_area"); + html = "上一关"; + nNext.html(html); + }); + // end + }); // 查看参考答案 @@ -327,6 +335,7 @@ function setupAjaxIndicatorBase() { || settings.url.match(/game_status/) || settings.url.match(/refresh_game_list/) || settings.url.match(/next_step/) + || settings.url.match(/prev_step/) || settings.url.match(/open_webssh/) || settings.url.match(/repository/) )){ @@ -368,7 +377,6 @@ function code_evaluation(test_sets, /** * Created by wang on 2017/8/9. */ - var $EffectDisplay , $b, $TestResult, $d, $e, $f, $g, $h, $EvaluationInformation , $n; // 第一块 效果显示 $EffectDisplay = "

    "; @@ -380,6 +388,7 @@ function code_evaluation(test_sets, "" + "" + + "
    " + "
    " + "
    "; @@ -428,13 +437,13 @@ function code_evaluation(test_sets, "
  • " + "
    " + " 预期输出:" + - "

    " + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
    ").replace(/ /g, "") ) + "

    " + + "

    " + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
    ").replace(/\t/g, "        ").replace(/ /g, "") ) + "

    " + "
    " + "
  • " + "
  • " + "
    " + "实际输出:" + - "

    " + (test_sets[i].actual_output == null ? "空" : test_sets[i].actual_output.replace(/\r\n/g, "
    ").replace(/ /g, "")) + "

    " + + "

    " + (test_sets[i].actual_output == null ? "空" : (test_sets[i].compile_success == "1" ? test_sets[i].actual_output.replace(/\r\n/g, "
    ").replace(/ /g, "") : test_sets[i].actual_output.replace(/\r\n/g, "
    "))) + "

    " + "
    " + "
  • " + "" + diff --git a/public/stylesheets/css/edu-class.css b/public/stylesheets/css/edu-class.css index b0e812ead..918155ade 100644 --- a/public/stylesheets/css/edu-class.css +++ b/public/stylesheets/css/edu-class.css @@ -120,7 +120,6 @@ a:hover.edu-class-right-add{ background-color: rgba(0, 0, 0, 0.4);} .edu-reference-ma-block{height: 40px; margin: 30px auto; text-align: center; font-size: 16px; color: #9a9a9a;} .stud-class-container{width:1200px;margin:10px auto 20px;} -.stud-class-container p{height:42px;line-height:42px;} .stud-class-container .con-top{height:42px;line-height:42px;background:#fff;} .stud-class-container .con-content{background:#fff;} .stud-class-container .con-content ul{width:45%;} diff --git a/public/stylesheets/css/edu-public.css b/public/stylesheets/css/edu-public.css index ae26afdb9..c059b2792 100644 --- a/public/stylesheets/css/edu-public.css +++ b/public/stylesheets/css/edu-public.css @@ -95,7 +95,7 @@ a:hover.panel-list-title{color:#29bd8b;} a.panel-name-small{ display: inline-block; max-width:100px; color:#29bd8b; font-size:12px; } .panel-list-infobox{ width: 92%; margin-left:8%; margin-top:-70px;} .panel-lightgrey,.panel-lightgrey span{ font-size:12px; color:#888;} -.panel-inner-info{ width: 92%; margin-left:8%; color:#666;} +.panel-inner-info{ width: 92%; margin-left:8%;} .panel-bg-grey{ padding:5px 0;background:#f6f6f6; width: 100%; color:#666;} .panel-list-nodata{ width: 420px; margin:100px auto; text-align: center;} @@ -380,5 +380,4 @@ input::-ms-input-placeholder,textarea::-ms-input-placeholder {color:#cccccc;} /*-----课程名称下拉框--------*/ .course_list_ul{display: none;position: absolute;top:40px;left: -1px;width: 100% !important;border:1px solid #eeeeee;background: #FFFFFF;padding-bottom: 5px; max-height: 150px;z-index: 10} -.course_list_ul li{height:20px;padding:5px 10px;clear:both;line-height:28px;margin-bottom: 0 !important;cursor: pointer;} - +.course_list_ul li{height:20px;padding:5px 10px;clear:both;line-height:28px;margin-bottom: 0 !important;cursor: pointer;} \ No newline at end of file diff --git a/public/stylesheets/css/taskstyle.css b/public/stylesheets/css/taskstyle.css index f51ffd016..d71e0d630 100644 --- a/public/stylesheets/css/taskstyle.css +++ b/public/stylesheets/css/taskstyle.css @@ -343,7 +343,7 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh .scroll_lesson{overflow-x: hidden;overflow-y: scroll;} .searchFor{width:auto;} -.searchFor .searchCon{width:240px;border-bottom:1px solid #cccccc;float: left;height: 30px;display: none;} +.searchFor .searchCon{width:240px;border-bottom:1px solid #cccccc;float: left;height: 30px;} .searchFor .searchCon input{border: none;outline: none;height: 29px;width:91%;} .searchFor .searchImg{margin:5px 10px 0px 0px;cursor: pointer;}