From 4032a62bbf10f17c0a637a45ac835a11f2589592 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 13 Nov 2019 15:29:28 +0800 Subject: [PATCH 1/5] laboratory --- app/controllers/admins/laboratory_shixuns_controller.rb | 7 +++++++ app/controllers/admins/laboratory_subjects_controller.rb | 9 +++++++++ app/controllers/cooperative/base_controller.rb | 2 +- .../cooperative/laboratory_shixuns_controller.rb | 7 +++++++ .../cooperative/laboratory_subjects_controller.rb | 7 +++++++ app/views/admins/laboratory_shixuns/shared/_td.html.erb | 4 ++++ .../admins/laboratory_subjects/shared/_list.html.erb | 4 ++++ .../cooperative/laboratory_shixuns/shared/_td.html.erb | 4 ++++ .../cooperative/laboratory_subjects/shared/_td.html.erb | 4 ++++ app/views/home/index.json.jbuilder | 4 ++-- app/views/users/get_user_info.json.jbuilder | 1 + config/routes.rb | 8 ++++---- 12 files changed, 54 insertions(+), 7 deletions(-) diff --git a/app/controllers/admins/laboratory_shixuns_controller.rb b/app/controllers/admins/laboratory_shixuns_controller.rb index f5c7d5ef3..d190573f1 100644 --- a/app/controllers/admins/laboratory_shixuns_controller.rb +++ b/app/controllers/admins/laboratory_shixuns_controller.rb @@ -19,6 +19,13 @@ class Admins::LaboratoryShixunsController < Admins::BaseController render_ok end + def destroy + return render_js_error('不能删除自建实训', type: :notify) if current_laboratory_shixun.ownership? + current_laboratory_shixun.destroy! + + render_delete_success + end + def homepage current_laboratory_shixun.update!(homepage: true) render_ok diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index d6dc4af9d..60572110c 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -21,6 +21,15 @@ class Admins::LaboratorySubjectsController < Admins::BaseController render_ok end + def destroy + return render_js_error('不能删除自建课程', type: :notify) if current_laboratory_subject.ownership? + + current_laboratory_subject.destroy! + + render_delete_success + end + + def homepage current_laboratory_subject.update!(homepage: true) render_ok diff --git a/app/controllers/cooperative/base_controller.rb b/app/controllers/cooperative/base_controller.rb index 556cd7aa9..5ab08582d 100644 --- a/app/controllers/cooperative/base_controller.rb +++ b/app/controllers/cooperative/base_controller.rb @@ -16,7 +16,7 @@ class Cooperative::BaseController < ApplicationController private def current_laboratory - @_current_laboratory ||= Laboratory.find_by_subdomain(request.subdomain) + @_current_laboratory ||= Laboratory.find_by_subdomain('hut' || request.subdomain) end def current_setting_or_default(name) diff --git a/app/controllers/cooperative/laboratory_shixuns_controller.rb b/app/controllers/cooperative/laboratory_shixuns_controller.rb index e428416da..2aa8a0bf6 100644 --- a/app/controllers/cooperative/laboratory_shixuns_controller.rb +++ b/app/controllers/cooperative/laboratory_shixuns_controller.rb @@ -15,6 +15,13 @@ class Cooperative::LaboratoryShixunsController < Cooperative::BaseController end + def destroy + return render_js_error('不能删除自建实训', type: :notify) if current_laboratory_shixun.ownership? + current_laboratory_shixun.destroy! + + render_delete_success + end + def homepage current_laboratory_shixun.update!(homepage: true) render_ok diff --git a/app/controllers/cooperative/laboratory_subjects_controller.rb b/app/controllers/cooperative/laboratory_subjects_controller.rb index 77088c223..0243d542a 100644 --- a/app/controllers/cooperative/laboratory_subjects_controller.rb +++ b/app/controllers/cooperative/laboratory_subjects_controller.rb @@ -18,6 +18,13 @@ class Cooperative::LaboratorySubjectsController < Cooperative::BaseController current_laboratory_subject.subject.update!(update_params) end + def destroy + return render_js_error('不能删除自建实践课程', type: :notify) if current_laboratory_subject.ownership? + current_laboratory_subject.destroy! + + render_delete_success + end + def homepage current_laboratory_subject.update!(homepage: true) render_ok diff --git a/app/views/admins/laboratory_shixuns/shared/_td.html.erb b/app/views/admins/laboratory_shixuns/shared/_td.html.erb index 84cfeb450..dbdf0df75 100644 --- a/app/views/admins/laboratory_shixuns/shared/_td.html.erb +++ b/app/views/admins/laboratory_shixuns/shared/_td.html.erb @@ -25,4 +25,8 @@ <%= link_to('去修改', admins_shixun_settings_path(id: laboratory_shixun.shixun_id)) %> <%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? 'display:none' : '') %> <%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? '' : 'display:none') %> + + <% unless laboratory_shixun.ownership? %> + <%= delete_link '删除', admins_laboratory_laboratory_shixun_path(current_laboratory, laboratory_shixun, element: ".laboratory-shixun-item-#{laboratory_shixun.id}") %> + <% end %> \ No newline at end of file diff --git a/app/views/admins/laboratory_subjects/shared/_list.html.erb b/app/views/admins/laboratory_subjects/shared/_list.html.erb index 8194e3dfb..55f67dea8 100644 --- a/app/views/admins/laboratory_subjects/shared/_list.html.erb +++ b/app/views/admins/laboratory_subjects/shared/_list.html.erb @@ -36,6 +36,10 @@ <%= link_to('去修改', admins_subjects_path(id: laboratory_subject.subject_id)) %> <%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? 'display:none' : '') %> <%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? '' : 'display:none') %> + + <% unless laboratory_subject.ownership? %> + <%= delete_link '删除', admins_laboratory_laboratory_subject_path(current_laboratory, laboratory_subject, element: ".laboratory-subject-item-#{laboratory_subject.id}") %> + <% end %> <% end %> diff --git a/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb b/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb index e7f87057d..d57a05c2e 100644 --- a/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb +++ b/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb @@ -29,4 +29,8 @@ <% end %> <%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? 'display:none' : '') %> <%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? '' : 'display:none') %> + + <% unless laboratory_shixun.ownership? %> + <%= delete_link '删除', cooperative_laboratory_shixun_path(laboratory_shixun, element: ".laboratory-shixun-item-#{laboratory_shixun.id}") %> + <% end %> \ No newline at end of file diff --git a/app/views/cooperative/laboratory_subjects/shared/_td.html.erb b/app/views/cooperative/laboratory_subjects/shared/_td.html.erb index 301bbd6a7..029fdabce 100644 --- a/app/views/cooperative/laboratory_subjects/shared/_td.html.erb +++ b/app/views/cooperative/laboratory_subjects/shared/_td.html.erb @@ -25,4 +25,8 @@ <%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? 'display:none' : '') %> <%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? '' : 'display:none') %> + + <% unless laboratory_subject.ownership? %> + <%= delete_link '删除', cooperative_laboratory_subject_path(laboratory_subject, element: ".laboratory-subject-item-#{laboratory_subject.id}") %> + <% end %> \ No newline at end of file diff --git a/app/views/home/index.json.jbuilder b/app/views/home/index.json.jbuilder index 5bbd1b799..8edbcb339 100644 --- a/app/views/home/index.json.jbuilder +++ b/app/views/home/index.json.jbuilder @@ -3,11 +3,11 @@ json.images_url @images_url json.reps @rep_list json.shixuns do - json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns.present? ? @shixuns : @main_shixuns} + json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns} end json.subjects do - json.partial! 'subjects/subject', locals: {subjects: @subjects.present? ? @subjects : @main_subjects} + json.partial! 'subjects/subject', locals: {subjects: @subjects} end if current_laboratory.main_site? diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 94f3f76a9..e80c8c215 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -13,6 +13,7 @@ json.phone @user.phone json.email @user.mail json.profile_completed @user.profile_completed? json.professional_certification @user.professional_certification +json.main_site current_laboratory.main_site? if @course json.course_identity @course_identity json.course_name @course.name diff --git a/config/routes.rb b/config/routes.rb index 0c8f61d3c..6add0d256 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1049,13 +1049,13 @@ Rails.application.routes.draw do post :drag, on: :collection end - resources :laboratory_shixuns, only: [:index, :create] do + resources :laboratory_shixuns, only: [:index, :create, :destroy] do member do post :homepage post :cancel_homepage end end - resources :laboratory_subjects, only: [:index, :create] do + resources :laboratory_subjects, only: [:index, :create, :destroy] do member do post :homepage post :cancel_homepage @@ -1132,13 +1132,13 @@ Rails.application.routes.draw do resources :carousels, only: [:index, :create, :update, :destroy] do post :drag, on: :collection end - resources :laboratory_shixuns, only: [:index, :edit, :update] do + resources :laboratory_shixuns, only: [:index, :edit, :update, :destroy] do member do post :homepage post :cancel_homepage end end - resources :laboratory_subjects, only: [:index, :edit, :update] do + resources :laboratory_subjects, only: [:index, :edit, :update, :destroy] do member do post :homepage post :cancel_homepage From cabfcb40c061da630516b830db1408156302a209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 13 Nov 2019 15:30:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B0=83=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesPublic/ModulationModal_exercise.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js b/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js index 611e06464..41b985003 100644 --- a/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js +++ b/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js @@ -45,6 +45,7 @@ class ModulationModal_exercise extends Component { } Saves = () => { + debugger let { textareaval, subjective_questions, @@ -123,7 +124,7 @@ class ModulationModal_exercise extends Component { Inputsvaltests: "请输入0-100的分数", }) return; - } else if (parseFloat(Inputsval) > this.props.objective_score) { + } else if (parseFloat(Inputsvals) > this.props.objective_score) { this.setState({ Inputsvals: Inputsvals, Inputsvaltypes: true, @@ -312,7 +313,9 @@ class ModulationModal_exercise extends Component { "" } -
+

主观题成绩:

Date: Wed, 13 Nov 2019 15:31:45 +0800 Subject: [PATCH 3/5] fix --- db/migrate/20191112100418_migrate_gcc_project_team.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20191112100418_migrate_gcc_project_team.rb b/db/migrate/20191112100418_migrate_gcc_project_team.rb index 9af0905bb..633f25c62 100644 --- a/db/migrate/20191112100418_migrate_gcc_project_team.rb +++ b/db/migrate/20191112100418_migrate_gcc_project_team.rb @@ -6,7 +6,8 @@ class MigrateGccProjectTeam < ActiveRecord::Migration[5.2] all_login = [['mu2pwryse', 'pljq3f9xp', 'pfx7gfmiz'], ['p9rs7xtfl', 'prx72s8uc', 'plezci23p', 'pjysrikw7'], ['m40352189', 'p05394287'], ['m9ozhx83t', 'p05296348'], ['p35490268', 'p48921607', 'p24019738'], ['p29165708', 'm43960821']] all_login.each do |user_login| - leader = User.find_by!(login: user_login.first) + leader = User.find_by(login: user_login.first) + next if leader.blank? team = CompetitionTeam.create!(name: "#{leader.real_name}组", user_id: leader.id, competition_id: 8) team.generate_invite_code team.save! From 3472711f73fe29be5e57a2924db4696c00df554f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 13 Nov 2019 15:34:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/Studentshavecompletedthelist.js | 20 +++++++++---------- .../courses/exercise/yslexercisetable.css | 8 ++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js index 6155b1bfb..e149035d9 100644 --- a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js @@ -661,7 +661,7 @@ class Studentshavecompletedthelist extends Component { key: 'classroom', dataIndex: 'classroom', align: 'center', - className: "edu-txt-center font-14", + className: "edu-txt-center font-14 maxnamewidth260", width:"260px", render: (text, record) => ( @@ -669,15 +669,15 @@ class Studentshavecompletedthelist extends Component { -- : record.classroom === "" ? + }} className="maxnamewidth260">-- : record.classroom === "" ? -- : + }} className="maxnamewidth260">-- : {record.classroom} + }} className="maxnamewidth260">{record.classroom} } @@ -904,14 +904,14 @@ class Studentshavecompletedthelist extends Component { key: 'classroom', dataIndex: 'classroom', align: 'center', - className: "edu-txt-center font-14", + className: "edu-txt-center font-14 maxnamewidth260", width:'260px', render: (text, record) => ( {record.classroom==="--"? - {record.classroom} + {record.classroom} : - {record.classroom} + {record.classroom} } ) @@ -1100,14 +1100,14 @@ class Studentshavecompletedthelist extends Component { key: 'classroom', dataIndex: 'classroom', align: 'center', - className: "edu-txt-center font-14", + className: "edu-txt-center font-14 maxnamewidth260 ", width:'260px', render: (text, record) => ( {record.classroom==="--"? - {record.classroom} + {record.classroom} : - {record.classroom} + {record.classroom} } ) diff --git a/public/react/src/modules/courses/exercise/yslexercisetable.css b/public/react/src/modules/courses/exercise/yslexercisetable.css index 98d7e6855..b638aa304 100644 --- a/public/react/src/modules/courses/exercise/yslexercisetable.css +++ b/public/react/src/modules/courses/exercise/yslexercisetable.css @@ -47,3 +47,11 @@ white-space:nowrap; cursor: default; } + +.maxnamewidth260 { + max-width: 260px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + cursor: default; +} From e0fbbf98ee2eb86f3c9ecab6fd7959cb79927312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 13 Nov 2019 15:42:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/exercise/Studentshavecompletedthelist.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js index e149035d9..7c0c74f33 100644 --- a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js @@ -428,7 +428,7 @@ class Studentshavecompletedthelist extends Component { textAlign: "center", width:'255px', }}>--: - {record.classroom} : - {record.classroom} + {record.classroom} } ) @@ -1107,7 +1107,7 @@ class Studentshavecompletedthelist extends Component { {record.classroom==="--"? {record.classroom} : - {record.classroom} + {record.classroom} } )