diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 4cf16409a..3fea82bff 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -516,15 +516,19 @@ class AccountController < ApplicationController end if @user.save && @se.save @user.update_attributes(:professional_certification => 0) - diskfile2 = disk_auth_filename('UserAuthentication', @user.id, 'PRO') - diskfilePRO = diskfile2 + 'temp' - begin - FileUtils.mv diskfilePRO, diskfile2, force: true if File.exist? diskfilePRO - ensure - File.delete(diskfilePRO) if File.exist?(diskfilePRO) - end - if File.exist?(diskfile2) + if @se.identity == 1 ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2) + else + diskfile2 = disk_auth_filename('UserAuthentication', @user.id, 'PRO') + diskfilePRO = diskfile2 + 'temp' + begin + FileUtils.mv diskfilePRO, diskfile2, force: true if File.exist? diskfilePRO + ensure + File.delete(diskfilePRO) if File.exist?(diskfilePRO) + end + if File.exist?(diskfile2) + ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2) + end end end redirect_to professional_certification_account_path diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index c3b206165..faa0ade1d 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -86,7 +86,7 @@ class GamesController < ApplicationController had_test = Output.where(:game_id => @game.id, :query_index => (@game.query_index - 1)) @had_test_count = had_test.count @had_passed_testsests_error_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == false}.count - @had_passed_testsests_error_count = @had_test_count - @had_passed_testsests_error_count + #@had_passed_testsests_error_count = @had_test_count - @had_passed_testsests_error_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? || @shixun.status <= 1) ? 0 : @game.final_score.to_i) @@ -271,7 +271,7 @@ class GamesController < ApplicationController had_test = Output.where(:game_id => @game.id, :query_index => (@game.query_index - 1)) @had_test_count = had_test.count @had_passed_testsests_error_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == false}.count - @had_passed_testsests_error_count = @had_test_count - @had_passed_testsests_error_count + #@had_passed_testsests_error_count = @had_test_count - @had_passed_testsests_error_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? || shixun.status <= 1) ? 0 : @game.final_score.to_i) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 236c695f1..cb9058dee 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -154,7 +154,7 @@ class MyController < ApplicationController if @user.nickname.nil? || @user.lastname.nil? || ue.try(:identity).nil? || ue.try(:location).nil? || ue.try(:location).nil? @require_auth = true else - if User.current.certification != 1 && (@trail_authentication.blank? || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 24*60*60) < Time.now.to_i)) + if User.current.certification != 1 && (@trail_authentication.blank? || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 5*60) < Time.now.to_i)) @require_trail_auth = true end end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d4dfe0981..5fa93690f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -463,14 +463,20 @@ class ShixunsController < ApplicationController @shixun = Shixun.new(params[:shixun]) @shixun.user_id = User.current.id @shixun.language = params[:language] - @shixun.major_id = params[:major_id] + #@shixun.major_id = params[:major_id] @shixun.trainee = params[:trainee] @shixun.webssh = params[:webssh].to_i @shixun.identifier = identifier - if params[:course_id] - params[:course_id].each do |course_id| - @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) - end + # if params[:course_id] + # params[:course_id].each do |course_id| + # @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) + # end + # end + if CourseList.where(:name => params[:course_list].strip).count > 0 + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => CourseList.where(:name => params[:course_list].strip).first.id) + else + course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0) + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => course_list.id) end (params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false) ActiveRecord::Base.transaction do @@ -534,13 +540,20 @@ class ShixunsController < ApplicationController @shixun.language = params[:language] @shixun.trainee = params[:trainee] @shixun.webssh = params[:webssh].to_i - if params[:course_id] - @shixun.shixun_major_courses.destroy_all - params[:course_id].each do |course_id| - @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) - end + # if params[:course_id] + # @shixun.shixun_major_courses.destroy_all + # params[:course_id].each do |course_id| + # @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) + # end + # end + # @shixun.major_id = params[:major_id] + @shixun.shixun_major_courses.destroy_all + if CourseList.where(:name => params[:course_list].strip).count > 0 + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => CourseList.where(:name => params[:course_list].strip).first.id) + else + course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0) + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => course_list.id) end - @shixun.major_id = params[:major_id] params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0 ActiveRecord::Base.transaction do begin diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index b4ab956e3..1bd8599dc 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -99,32 +99,32 @@ module StudentWorkHelper project = cur_user_projects_for_homework homework if work.nil? && homework.end_time >= Time.now if homework.homework_type == 4 - link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'task-btn task-btn-blue fr',:remote => true + link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'task-btn task-btn-blue fr mr10 mt8',:remote => true else - link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr' + link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr mr10 mt8' end elsif work.nil? && homework.end_time < Time.now if homework.allow_late && homework.homework_detail_manual.comment_status < 6 if homework.homework_type == 4 - link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'task-btn task-btn-blue fr',:remote => true + link_to "关联实战", relate_myshixun_student_work_index_path(:homework => homework.id),:class => 'task-btn task-btn-blue fr mr10 mt8',:remote => true else - link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr' + link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'task-btn task-btn-blue fr mr10 mt8' end end elsif work if homework.homework_type == 4 myshixun = Myshixun.find work.myshixun_id - link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "task-btn task-btn-blue fr mr10",:target => "_blank" if myshixun + link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "task-btn task-btn-blue fr mr10 mt8",:target => "_blank" if myshixun else work_ids = "(" + homework.student_works.has_committed.map(&:id).join(",") + ")" if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 && User.current.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count > 0 #匿评作业,且作业状态不是在开启匿评之前 - link_to "匿评作品", student_work_index_url_in_org(homework.id, 2), :class => 'task-btn task-btn-blue fr', :title => "开启匿评后不可修改作品" + link_to "匿评作品", student_work_index_url_in_org(homework.id, 2), :class => 'task-btn task-btn-blue fr mr10 mt8', :title => "开启匿评后不可修改作品" elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status > 3 - link_to "查看作品", student_work_path(work), :class => 'task-btn task-btn-blue fr', :title => "匿评已结束" + link_to "查看作品", student_work_path(work), :class => 'task-btn task-btn-blue fr mr10 mt8', :title => "匿评已结束" elsif homework.end_time >= Time.now && work.user_id == User.current.id - link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'task-btn task-btn-blue fr' + link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'task-btn task-btn-blue fr mr10 mt8' else - link_to "查看作品", student_work_path(work), :class => 'task-btn task-btn-blue fr mt8 mr15', :title => "作业截止后不可修改作品" + link_to "查看作品", student_work_path(work), :class => 'task-btn task-btn-blue fr mr10 mt8', :title => "作业截止后不可修改作品" end end end diff --git a/app/views/account/_pro_certification_form.html.erb b/app/views/account/_pro_certification_form.html.erb index dac38879c..853b29803 100644 --- a/app/views/account/_pro_certification_form.html.erb +++ b/app/views/account/_pro_certification_form.html.erb @@ -35,14 +35,14 @@
- 请选择你的职业/职称 + 请选择你的职业/职称
  • - 学号不能为空 + 学号不能为空
  • @@ -50,7 +50,7 @@

    你的单位不在列表中?请点击申请添加

    - 请从下拉列表中选择你的单位 + 请从下拉列表中选择你的单位
  • @@ -61,7 +61,7 @@
  • - + <%= file_field_tag 'avatar[image]', :id => "upload_img_pro", :style => 'display:none;',#added by young @@ -398,7 +398,37 @@ var title = "<%= "#{title}" %>"; init_identity_and_title(document.getElementById('userIdentity'), identity, title); - $("#userIdentity").change(); + if(identity == "1"){ + $("#pro_cer_img_notice").html(""); + } + $("#userIdentity").change(function(){ + var option = $("#userIdentity option:selected"); + if(option.val()=="1"){ + $("#identity_hint").hide(); + $("#number").show(); + $("#user_student_id").show(); + $("#teacher").hide(); + $("#profession").hide(); + $("#pro_cer_img_notice").html(""); + }else if(option.val()=="2"){ + $("#number").hide(); + $("#user_student_id").hide(); + $("#identity_hint").hide(); + $("#teacher").hide(); + $("#profession").show(); + $("#pro_cer_img_notice").html("*"); + }else if(option.val()=="0"){ + $("#number").hide(); + $("#user_student_id").hide(); + $("#identity_hint").hide(); + $("#profession").hide(); + $("#teacher").show(); + $("#pro_cer_img_notice").html("*"); + }else{ + $("#identity_hint").hide(); + $("#pro_cer_img_notice").html("*"); + } + }); var image = $("#nh_source_pro"); var element = $("").attr("href", image.attr('src')+".png"); diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 21e75c387..55e8a19c5 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -169,6 +169,8 @@ <%# end %> <%# end %> + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @course %> <%= @course.visits %> 次访问 diff --git a/app/views/layouts/base_edu_account.html.erb b/app/views/layouts/base_edu_account.html.erb index 34b1a6a08..370aed93e 100644 --- a/app/views/layouts/base_edu_account.html.erb +++ b/app/views/layouts/base_edu_account.html.erb @@ -42,9 +42,9 @@
    试用申请已提交,我们将在一个工作日内完成审核
    - <% elsif User.current.certification == 2 || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 24*60*60) > Time.now.to_i) %> + <% elsif User.current.certification == 2 || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 5*60) > Time.now.to_i) %>
    - 您的试用申请已被拒绝,原因:<%= @trail_authentication.reason %>,请于24小时后重新申请 + 您的试用申请已被拒绝,原因:<%= @trail_authentication.reason %>,请于5分钟后重新申请
    <% end %> <% end %> diff --git a/app/views/layouts/base_shixun.html.erb b/app/views/layouts/base_shixun.html.erb index bb4d8f7a8..053e3d1fa 100644 --- a/app/views/layouts/base_shixun.html.erb +++ b/app/views/layouts/base_shixun.html.erb @@ -24,7 +24,7 @@
    <%= render :partial => 'shixuns/shixun_top' %>
    -
    +
    • " >实训
    • " >背景知识
    • diff --git a/app/views/mailer/lost_password.html.erb b/app/views/mailer/lost_password.html.erb index d7dcf7dbf..48db5bf6a 100644 --- a/app/views/mailer/lost_password.html.erb +++ b/app/views/mailer/lost_password.html.erb @@ -28,7 +28,7 @@ diff --git a/app/views/mailer/register.html.erb b/app/views/mailer/register.html.erb index 38d51fb8a..6a4298c5c 100644 --- a/app/views/mailer/register.html.erb +++ b/app/views/mailer/register.html.erb @@ -23,7 +23,7 @@ diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index ab3557118..fef674277 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -37,24 +37,23 @@

      -
    • - - <%#= select_tag :major_id, options_for_select(shixun_major_option, 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%> - -
      - -
    • + + + + + + + + + + + +
    • -
      - - -
        +
        + +
        @@ -88,93 +87,36 @@ $(function(){ $("#websh").on("click", function(){ $(this).val() == '0' ? $(this).val('1') : $(this).val("0"); - }) + }); // 实训简介自动保存 md_elocalStorage(shixun_editormd, "shixun_in_<%= User.current.id %>", "in"); md_elocalStorage(shixun_propaedeutics, "shixun_pr_<%= User.current.id %>", "pr"); //$("textarea[name='shixun[description]']").md_elocalStorage(); - // 防止刷新页面后适用课程的下拉列表为空 - $("#shixun_major").val("0"); - $(".lesson_content").val(""); - - //多选适用课程 - $("body").click(function(event){ - $(".lesson_checkbox").hide(); - $(".lesson_checkbox").attr("showul","0"); - event.stopPropagation(); + $("#new_course_list").on('input', function(e){ + throttle(search_course_list, window, e); }); - $(".lesson").click(function(event){ - if($("#shixun_major").val() == "0") { - $("#shixun_major_course_notice").html("请先选择适用专业").show(); + $("#new_course_list").on('focus', function (e) { + if ($("#new_course_list").val().trim() != '') { //如果已经有id了。肯定存在,不用去找了。 + return; } else{ - var showul=$(this).find("ul").attr("showul"); - if(showul=="0"){ - $(this).find("ul").show(); - $(this).find("ul").attr("showul","1"); - if($(this).find("ul input").length>5){ - $(this).find("ul").css("overflow-y","scroll"); - } - event.stopPropagation(); - }else{ - $(this).find("ul").hide(); - $(this).find("ul").attr("showul","0"); - event.stopPropagation(); - } + search_course_ajax(''); } }); - $(".lesson_checkbox").on('click', 'label', function(event) { + + $(".course_list_ul").on('click', 'p',function(event) { + $("#new_course_list").val($(this).html()); + $(".course_list_ul").hide(); event.stopPropagation(); }); - $(".lesson_checkbox").on('click', 'input',function(event) { - if ($(this).is(':checked')) { - if ($(".lesson_content").val() == "") { - $(".lesson_content").val($(this).attr("data-val")); - } else { - $(".lesson_content").val($(".lesson_content").val() + "," + $(this).attr("data-val")); - } - $("#shixun_major_course_notice").hide(); - event.stopPropagation(); - } else { - var valueCon = $(".lesson_content").val().split(","); - var list = []; - for (var i = 0; i < valueCon.length; i++) { - if (valueCon[i] != $(this).attr("data-val")) { - list.push(valueCon[i]); - } - } - $(".lesson_content").val(list); - event.stopPropagation(); - } + + $("body").click(function(event){ + $(".course_list_ul").hide(); + event.stopPropagation(); }); }); - $("#shixun_major").on("change", function(){ - if($("#shixun_major").val() != "0"){ - $.ajax({ - url: '/shixuns/shixun_courses', - type: 'get', - data: {major_id:$("#shixun_major").val()}, - success: function(data){ - if (data.result == 1){ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - for(var i=0; i'); - } - $("#shixun_major_notice").hide(); - } - else{ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - } - } - }); - } else{ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - } - }); + /* ------------------------------- 简介md ------------------------------*/ var shixun_editormd = editormd("shixun_introduction", { width : "89.7%", @@ -235,7 +177,7 @@ //提交新建项目 function submit_new_project() { - if(regex_shixun_name() && regex_major() && regex_major_course()) + if(regex_shixun_name() && regex_major_course()) { $("#new_shixun").submit(); } diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 741dfd2e8..9124e27c9 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -14,18 +14,17 @@

        -
      • - - <%= select_tag :major_id, options_for_select(shixun_major_option, @shixun.major_id ? @shixun.major_id : 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%> -
        - -
      • + + + + + +
      • -
        - - -
          +
          + @shixun.shixun_major_courses.map(&:course_list_id)).map(&:name).join(",") %>" autocomplete="off" style="border: 1px solid #eee;width: 100%;padding: 5px;" id="new_course_list" class="task-height-40 panel-box-sizing fl" maxlength="100" placeholder="选择实训适用的课程"> +
          @@ -62,7 +61,7 @@