diff --git a/config/routes.rb b/config/routes.rb index 8085765b4..e92440ae7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,901 +1,901 @@ -Rails.application.routes.draw do - - require 'sidekiq/web' - require 'admin_constraint' - mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new - - get 'attachments/download/:id', to: 'attachments#show' - get 'attachments/download/:id/:filename', to: 'attachments#show' - - resources :edu_settings - scope '/api' do - get 'home/index' - get 'home/search' - - get 'search', to: 'searchs#index' - - post 'praise_tread/like', to: 'praise_tread#like' - delete 'praise_tread/unlike', to: 'praise_tread#unlike' - - put 'commons/hidden', to: 'commons#hidden' - put 'commons/unhidden', to: 'commons#unhidden' - delete 'commons/delete', to: 'commons#delete' - - resources :memos do - member do - post :sticky_or_cancel - post :hidden - get :more_reply - end - - collection do - post :reply - end - end - - resources :tem_tests - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - # - # - resources :accounts do - - collection do - post :login - post :register - post :reset_password - get :logout - get :get_verification_code - get :valid_email_and_phone - end - - end - - resources :users do - member do - get :homepage_info - end - - scope module: :users do - resources :courses, only: [:index] - resources :shixuns, only: [:index] - resources :projects, only: [:index] - resources :subjects, only: [:index] - resources :question_banks, only: [:index] - resource :experience_records, only: [:show] - resource :grade_records, only: [:show] - resource :watch, only: [:create, :destroy] - resources :project_packages, only: [:index] - # 私信 - resources :private_messages, only: [:index, :create, :destroy] - resources :recent_contacts, only: [:index] - resource :private_message_details, only: [:show] - resource :unread_message_info, only: [:show] - - # 视频 - resources :videos, only: [:index, :update] do - collection do - get :review - post :batch_publish - post :cancel - end - end - resource :video_auths, only: [:create, :update] - end - - - collection do - post :following - post :unfollow - get :get_user_info - get :attachment_show - get :html_show - get :get_navigation_info - post :reply_message - get :search_user_projects - post :brief_introduction - post :attendance - get :system_update - - resource :trial_apply, only: [:create] - resources :projects, module: :users, only: [] do - get :search, on: :collection - end - - resources :tidings, only: [:index] - - scope module: :users do - resource :interest, only: [:create] - - resources :accounts, only: [:show, :update] do - resource :phone_bind, only: [:create] - resource :email_bind, only: [:create] - resource :password, only: [:update] - resource :avatar, only: [:update] - resource :auth_attachment, only: [:create] - resource :authentication_apply, only: [:create] - resource :professional_auth_apply, only: [:create] - end - end - end - end - resources :users_for_private_messages, only: [:index] - - resources :myshixuns, param: :identifier, shallow: true do - member do - post :repository - post :commits - post :file_content - post :update_file - get :reset_my_game - post :html_content - get :open_webssh - get :challenges - end - collection do - get :sigle_mul_test - match :training_task_status, :via => [:get, :post] - match :code_runinng_message, :via => [:get, :post] - end - resources :games - end - - resources :games, path: :tasks, param: :identifier do - member do - get :star - get :git_entries - get :answer - get :answer_grade - get :rep_content - get :reset_original_code - get :reset_passed_code - post :file_update - post :choose_build - get :game_build - get :game_status - post :plus_or_cancel_praise - get :cost_time - get :system_update - get :sync_modify_time - get :picture_display - get :sync_codes - get :close_webssh - get :get_answer_info - get :unlock_answer - get :check_test_sets - get :unlock_choose_answer - get :get_choose_answer - - end - collection do - get :challenges - end - end - - resources :shixuns, param: :identifier do - collection do - get :menus - get :get_recommend_shixuns - get :departments - get :get_mirror_script - post :apply_shixun_mirror - get :download_file - end - - member do - post :copy - get :propaedeutics - get :show_right - get :operation - get :ranking_list - get :discusses - get :tasks - get :collaborators - get :settings - get :get_script_contents - get :get_custom_script - post :repository - post :commits - post :file_content - post :update_file - post :close - post :add_file - get :fork_list - post :update_propaedeutics - get :add_collaborators - post :shixun_members_added - match :change_manager, :via => [:get, :post] - get :search_user_courses - post :send_to_course - delete :collaborators_delete - get :cancel_publish - get :publish - get :shixun_exec - end - - resources :challenges do - member do - get 'index_up' - get 'index_down' - post 'create_choose_question' - get 'show_choose_question' - match 'choose_type_show', :via => [:get, :post] - match 'edit_choose_question', :via => [:get, :post] - match 'update_choose_question', :via => [:get, :post] - delete 'destroy_challenge_choose' - post :crud_answer - get :answer - - end - end - - resources :repositories do - collection do - post :add_project - post :fork_project - - post :file_tree # 目录树 - post :update_file # 文件更新 - post :file_content # 文件内容 - - post :commits # 提交记录 - end - end - end - - resources :discusses do - collection do - get :new_message - get :forum_discusses - end - - member do - post :reply - post :hidden - post :reward_code - post :plus - end - end - - resources :subjects, path: :paths do - member do - get 'choose_subject_shixun' - get 'publish' - get 'cancel_publish' - get 'cancel_has_publish' - get 'statistics' - get 'shixun_report' - get 'school_report' - post 'update_attr' - post :search_members - post 'add_subject_members' - delete 'delete_member' - get :choose_course - post 'send_to_course' - delete :delete_member - post :up_member_position - post :down_member_position - get :right_banner - end - - collection do - get 'create_subject' - get 'new_subject' - post 'append_to_stage' - get 'search' - end - end - - resources :stages do - member do - get 'down_position' - get 'up_position' - end - end - - resources :files, only: [:index, :show, :update] do - collection do - delete :bulk_delete - put :bulk_move - post :bulk_send - put :bulk_public - get :public_with_course_and_project - get :mine_with_course_and_project - post :import - post :upload - put :bulk_publish - end - member do - get :histories - end - end - - resources :courses do - member do - get 'settings', :action => 'settings', :as => 'settings' - post 'set_invite_code_halt' - post 'set_public_or_private' - post 'search_teacher_candidate' - post 'add_teacher' - post 'create_graduation_group' - post 'join_graduation_group' - post 'set_course_group' - post 'change_course_admin' - post 'change_course_teacher' - post 'delete_course_teacher' - post 'teacher_application_review' - post 'transfer_to_course_group' - post 'delete_from_course' - post 'add_students_by_search' - post 'create_group_by_importing_file' - post 'duplicate_course' - post 'visits_plus_one' - get 'get_historical_courses' - get 'get_historical_course_students' - get 'course_group_list' - get 'add_teacher_popup' - get 'teachers' - get 'apply_teachers' - get 'graduation_group_list' - get 'top_banner' - get 'left_banner' - get 'students' - get 'all_course_groups' - get 'search_users' - get 'base_info' - get 'attahcment_category_list' - get 'export_member_scores_excel' #导出课堂信息 - get 'export_couser_info' - get 'export_member_act_score' - post 'switch_to_teacher' - post 'switch_to_assistant' - post 'switch_to_student' - post 'exit_course' - get 'informs' - post 'update_informs' - post 'new_informs' - delete 'delete_informs' - get 'online_learning' - post 'join_excellent_course' - get 'tasks_list' - post 'update_task_position' - end - - collection do - post 'apply_to_join_course' - post 'search_course_list' - get 'board_list' - get 'mine' - get 'search_slim' - end - - resources :polls, only:[:index,:new,:create] do - collection do - post :publish # 立即发布 - post :end_poll # 立即截止 - post :destroys # 多个删除 - post :set_public # 设置公开 - post :join_poll_banks # 加入习题集 - get :my_polls #我的问卷题库 - get :public_polls # 公共问卷题库 - get :publish_modal # 立即发布弹窗内容 - get :end_poll_modal # 立即截止弹窗内容 - end - end - - resources :homework_commons, shallow: true do - - member do - get :group_list - post :homework_code_repeat - get :code_review_results - get :code_review_detail - post :update_explanation - get :show_comment - get :settings - post :update_settings - match 'works_list', :via => [:get, :post] - # post :works_list - get :reference_answer - get :publish_groups - get :end_groups - post :alter_name - get :update_score - get :update_student_score - end - - collection do - post 'create_shixun_homework' - match 'shixuns', via: [:get, :post] - match 'subjects', via: [:get, :post] - post 'create_subject_homework' - post 'publish_homework' - post 'end_homework' - post 'set_public' - post 'move_to_category' - get 'choose_category' - post 'multi_destroy' - post 'add_to_homework_bank' - end - - resources :student_works do - member do - get :shixun_work - get :shixun_work_report - post :adjust_review_score - get :commit_des - post :update_des - post :adjust_score - post :add_score - post :add_score_reply - delete :destroy_score - delete :destroy_score_reply - get :comment_list - get :supply_attachments - post :revise_attachment - delete :destroy_score - post :appeal_anonymous_score - post :deal_appeal_score - post :cancel_appeal - get :export_shixun_work_report - end - - collection do - get :search_member_list - get :check_project - get :cancel_relate_project - post :relate_project - delete :delete_work - end - end - end - - - resources :boards, shallow: true do - resources :messages do - collection do - delete :bulk_delete - put :bulk_move - post :bulk_send - put :bulk_public - end - - member do - get :reply_list - put :sticky_top - post :reply - end - end - member do - post 'move_category' - end - end - - resources :exercises ,only:[:index,:new,:create] do - collection do - get :my_exercises #我的试卷题库 - get :public_exercises # 公共试卷题库 - get :publish_modal # 立即发布弹窗内容 - get :end_modal # 立即截止弹窗内容 - post :destroys - post :set_public # 设置公开 - post :join_exercise_banks # 加入习题集 - post :publish # 立即发布 - post :end_exercise # 立即截止 - - end - end - - resources :course_groups, shallow: true do - member do - post 'rename_group' - post 'move_category' - end - - collection do - end - end - - resources :graduation_topics do - member do - post :refuse_student_topic - post :accept_student_topic - post :student_select_topic - post :student_cancel_topic - get :show_detail - get :show_comment - end - collection do - delete :destroys - post :set_public - get :export - post :add_to_bank - end - end - - resources :graduation_tasks, shallow: true do - resources :graduation_works do - collection do - post 'search_member_list' - get 'check_project' - post 'relate_project' - get 'cancel_relate_project' - post 'revise_attachment' - end - - member do - get 'comment_list' - post 'add_score' - post 'adjust_score' - delete 'delete_score' - get 'supply_attachments' - post 'revise_attachment' - post :assign_teacher - end - end - member do - get 'settings' - post 'update_settings' - get 'tasks_list' - get :show_comment - end - - collection do - post 'set_public' - delete 'multi_destroy' - post 'publish_task' - post 'end_task' - post 'add_to_bank' - end - end - end - - resources :polls,except:[:index,:new,:create] do - member do - get :poll_setting - post :commit_setting - get :start_answer - post :commit_poll - get :commit_result - get :poll_lists # 问卷的答题列表 - post :cancel_publish #撤销发布 - get :cancel_publish_modal #撤销发布的弹窗 - get :common_header - end - resources :poll_questions,only:[:new,:create] - end - - resources :poll_questions,except:[:new,:create,:index] do - member do - post :delete_answer - post :up_down - post :commit_answer - end - resource :poll_votes,only:[:create,:destroy] - end - - resources :exercises do - member do - get :choose_shixun - get :commit_shixun - get :exercise_setting - post :commit_setting - get :start_answer - post :commit_exercise - get :redo_modal #打回重做弹窗内容 - post :redo_exercise - get :review_exercise - get :exercise_lists - # get :blank_exercise #摒弃,仅作为测试html页面才会使用 - get :export_exercise - get :common_header - get :exercise_result - post :cancel_exercise - get :begin_commit #提交前的弹窗 - end - resources :exercise_questions,only:[:new,:create,:index] - end - - resources :exercise_questions,except:[:new,:create,:index] do - member do - post :up_down - post :delete_answer - post :adjust_score - post :update_scores - end - resource :exercise_answers,only:[:create,:destroy] - end - - - resources :course_modules, shallow: true do - member do - get 'sticky_module' - get 'hidden_module' - post 'rename_module' - post 'add_second_category' - end - collection do - post 'unhidden_modules' - end - end - - resources :course_second_categories, shallow: true do - member do - post 'rename_category' - post 'move_category' - end - collection do - - end - end - - resources :question_banks do - collection do - get :bank_list - post :save_banks - get :my_courses - post :send_to_course - delete :multi_delete - post :multi_public - end - end - - resources :homework_banks do - member do - post :set_public - end - end - - resources :gtopic_banks - resources :task_banks - - resources :exercise_banks do - collection do - get :choose_shixun - end - - member do - get :commit_shixun - end - end - - resources :exercise_bank_questions do - member do - post :up_down - get :choose_shixun - end - end - - resources :poll_bank_questions - - resources :attachments - - resources :schools do - member do - resources :departments, only: [] do - get :for_option, on: :collection - end - end - collection do - get :school_list - get :for_option - end - - scope module: :ecs do - get :detail, to: 'homes#index' - - resources :ec_majors, only: [:index] - resources :ec_major_schools, only: [:index, :create, :destroy] - end - end - resources :add_school_applies, only: [:create] - resources :add_department_applies, only: [:create] - - # 为避免url过长以及层级过深,路由定义和controller继承都做了处理 - scope module: :ecs do - resources :ec_major_schools, only: [] do - resources :major_managers, only: [:create, :destroy] - resources :ec_years, only: [:index, :create, :destroy] - end - - resources :ec_years, only: [] do - resource :ec_training_objectives, only: [:show, :create] - resources :ec_graduation_requirements, only: [:index, :create] - resource :requirement_support_objectives, only: [:show, :create, :destroy] - resource :subitem_support_standards, only: [:show, :create, :destroy] - resource :students, only: [:show, :destroy] do - post :import, on: :collection - end - - resources :ec_courses, only: [:index, :create, :destroy] do - post :link_course, on: :member - - collection do - post :import - get :search - end - end - - resource :graduation_course_supports, only: [:show, :create] - resource :reach_evaluation, only: [:show, :create] - resource :reach_criteria, only: [:create] - end - - resources :ec_courses, only: [] do - resource :evaluation, only: [:show, :create] - resources :course_managers, only: [:create, :destroy] - resources :course_targets, only: [:index, :create] do - get :with_achievement_methods, on: :collection - - resource :course_achievement_methods, only: [:create] - end - resources :course_evaluations, only: [:index, :create, :update, :destroy] do - member do - get :average_score_import_template - get :detail_score_import_template - get :import_student_achievement - end - get :slimmer, on: :collection - end - resource :score_levels, only: [:show, :create] - end - end - - resource :zip, only: [] do - collection do - get :shixun_report - get :export_exercises - end - end - - resources :repertoires, only: [:index] - - scope module: :competitions do - resources :competitions, only: [:index, :show] do - resources :competition_modules, only: [:index, :show, :update] - resource :competition_staff - resources :competition_teams, only: [:index, :show] do - post :join, on: :collection - post :leave, on: :member - end - resources :teachers, only: [:index] - resources :students, only: [:index] - end - end - - resources :project_package_categories, only: [:index] - resources :project_packages, only: [:index, :show, :create, :update, :destroy] do - resources :bidding_users, only: [:create] do - post :win, on: :collection - end - end - - resources :libraries, only: [:index, :show, :create, :update, :destroy] - - scope module: :projects do - resources :project_applies, only: [:create] - end - - post 'callbacks/aliyun_vod', to: 'callbacks/aliyun_vods#create' - - namespace :wechats do - resource :js_sdk_signature, only: [:create] - end - end - - namespace :admins do - get '/', to: 'dashboards#index' - resources :dashboards, only: [:index] do - collection do - get :month_active_user - get :evaluate - end - end - resources :files, only: [:create] - - resources :daily_school_statistics, only: [:index] do - get :export, on: :collection - end - - resources :school_statistics, only: [:index] do - get :contrast, on: :collection - end - - resources :users, only: [:index, :edit, :update, :destroy] do - member do - post :reward_grade - post :lock - post :unlock - post :active - end - end - resource :import_users, only: [:create] - resource :import_course_members, only: [:create] - - resources :library_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :video_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :identity_authentications, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :professional_authentications, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :shixun_authorizations, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :subject_authorizations, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :project_package_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :shixuns, only: [:index,:destroy] - resources :shixun_settings, only: [:index,:update] - resources :department_applies,only: [:index,:edit,:update,:destroy] do - member do - post :agree - end - end - resources :mirror_repositories, only: [:index, :new, :create, :edit, :update, :destroy] do - collection do - post :merge - get :for_select - end - resources :mirror_scripts, only: [:index, :new, :create, :edit, :update, :destroy] - end - resources :choose_mirror_repositories, only: [:new, :create] - resources :departments, only: [:index, :create, :edit, :update, :destroy] do - resource :department_member, only: [:create, :update, :destroy] - post :merge, on: :collection - end - resources :myshixuns, only: [:index] - end - - resources :colleges, only: [] do - member do - get :statistics - get :course_statistics - get :student_shixun - get :shixun_time - get :shixun_report_count - get :teachers - get :shixun_chart_data - get :student_hot_evaluations - end - end - - #git 认证回调 - match 'gitauth/*url', to: 'gits#auth', via: :all - - get 'oauth/get_code', to: 'oauth#get_code' - get 'oauth/get_token_callback', to: 'oauth#get_token_callback' - - root 'main#index' - - ## react用 - get '*path', to: 'main#index', constraints: ReactConstraint.new -end +Rails.application.routes.draw do + + require 'sidekiq/web' + require 'admin_constraint' + mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new + + get 'attachments/download/:id', to: 'attachments#show' + get 'attachments/download/:id/:filename', to: 'attachments#show' + + resources :edu_settings + scope '/api' do + get 'home/index' + get 'home/search' + + get 'search', to: 'searchs#index' + + post 'praise_tread/like', to: 'praise_tread#like' + delete 'praise_tread/unlike', to: 'praise_tread#unlike' + + put 'commons/hidden', to: 'commons#hidden' + put 'commons/unhidden', to: 'commons#unhidden' + delete 'commons/delete', to: 'commons#delete' + + resources :memos do + member do + post :sticky_or_cancel + post :hidden + get :more_reply + end + + collection do + post :reply + end + end + + resources :tem_tests + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + # + # + resources :accounts do + + collection do + post :login + post :register + post :reset_password + get :logout + get :get_verification_code + get :valid_email_and_phone + end + + end + + resources :users do + member do + get :homepage_info + end + + scope module: :users do + resources :courses, only: [:index] + resources :shixuns, only: [:index] + resources :projects, only: [:index] + resources :subjects, only: [:index] + resources :question_banks, only: [:index] + resource :experience_records, only: [:show] + resource :grade_records, only: [:show] + resource :watch, only: [:create, :destroy] + resources :project_packages, only: [:index] + # 私信 + resources :private_messages, only: [:index, :create, :destroy] + resources :recent_contacts, only: [:index] + resource :private_message_details, only: [:show] + resource :unread_message_info, only: [:show] + + # 视频 + resources :videos, only: [:index, :update] do + collection do + get :review + post :batch_publish + post :cancel + end + end + resource :video_auths, only: [:create, :update] + end + + + collection do + post :following + post :unfollow + get :get_user_info + get :attachment_show + get :html_show + get :get_navigation_info + post :reply_message + get :search_user_projects + post :brief_introduction + post :attendance + get :system_update + + resource :trial_apply, only: [:create] + resources :projects, module: :users, only: [] do + get :search, on: :collection + end + + resources :tidings, only: [:index] + + scope module: :users do + resource :interest, only: [:create] + + resources :accounts, only: [:show, :update] do + resource :phone_bind, only: [:create] + resource :email_bind, only: [:create] + resource :password, only: [:update] + resource :avatar, only: [:update] + resource :auth_attachment, only: [:create] + resource :authentication_apply, only: [:create] + resource :professional_auth_apply, only: [:create] + end + end + end + end + resources :users_for_private_messages, only: [:index] + + resources :myshixuns, param: :identifier, shallow: true do + member do + post :repository + post :commits + post :file_content + post :update_file + get :reset_my_game + post :html_content + get :open_webssh + get :challenges + end + collection do + get :sigle_mul_test + match :training_task_status, :via => [:get, :post] + match :code_runinng_message, :via => [:get, :post] + end + resources :games + end + + resources :games, path: :tasks, param: :identifier do + member do + get :star + get :git_entries + get :answer + get :answer_grade + get :rep_content + get :reset_original_code + get :reset_passed_code + post :file_update + post :choose_build + get :game_build + get :game_status + post :plus_or_cancel_praise + get :cost_time + get :system_update + get :sync_modify_time + get :picture_display + get :sync_codes + get :close_webssh + get :get_answer_info + get :unlock_answer + get :check_test_sets + get :unlock_choose_answer + get :get_choose_answer + + end + collection do + get :challenges + end + end + + resources :shixuns, param: :identifier do + collection do + get :menus + get :get_recommend_shixuns + get :departments + get :get_mirror_script + post :apply_shixun_mirror + get :download_file + end + + member do + post :copy + get :propaedeutics + get :show_right + get :operation + get :ranking_list + get :discusses + get :tasks + get :collaborators + get :settings + get :get_script_contents + get :get_custom_script + post :repository + post :commits + post :file_content + post :update_file + post :close + post :add_file + get :fork_list + post :update_propaedeutics + get :add_collaborators + post :shixun_members_added + match :change_manager, :via => [:get, :post] + get :search_user_courses + post :send_to_course + delete :collaborators_delete + get :cancel_publish + get :publish + get :shixun_exec + end + + resources :challenges do + member do + get 'index_up' + get 'index_down' + post 'create_choose_question' + get 'show_choose_question' + match 'choose_type_show', :via => [:get, :post] + match 'edit_choose_question', :via => [:get, :post] + match 'update_choose_question', :via => [:get, :post] + delete 'destroy_challenge_choose' + post :crud_answer + get :answer + + end + end + + resources :repositories do + collection do + post :add_project + post :fork_project + + post :file_tree # 目录树 + post :update_file # 文件更新 + post :file_content # 文件内容 + + post :commits # 提交记录 + end + end + end + + resources :discusses do + collection do + get :new_message + get :forum_discusses + end + + member do + post :reply + post :hidden + post :reward_code + post :plus + end + end + + resources :subjects, path: :paths do + member do + get 'choose_subject_shixun' + get 'publish' + get 'cancel_publish' + get 'cancel_has_publish' + get 'statistics' + get 'shixun_report' + get 'school_report' + post 'update_attr' + post :search_members + post 'add_subject_members' + delete 'delete_member' + get :choose_course + post 'send_to_course' + delete :delete_member + post :up_member_position + post :down_member_position + get :right_banner + end + + collection do + get 'create_subject' + get 'new_subject' + post 'append_to_stage' + get 'search' + end + end + + resources :stages do + member do + get 'down_position' + get 'up_position' + end + end + + resources :files, only: [:index, :show, :update] do + collection do + delete :bulk_delete + put :bulk_move + post :bulk_send + put :bulk_public + get :public_with_course_and_project + get :mine_with_course_and_project + post :import + post :upload + put :bulk_publish + end + member do + get :histories + end + end + + resources :courses do + member do + get 'settings', :action => 'settings', :as => 'settings' + post 'set_invite_code_halt' + post 'set_public_or_private' + post 'search_teacher_candidate' + post 'add_teacher' + post 'create_graduation_group' + post 'join_graduation_group' + post 'set_course_group' + post 'change_course_admin' + post 'change_course_teacher' + post 'delete_course_teacher' + post 'teacher_application_review' + post 'transfer_to_course_group' + post 'delete_from_course' + post 'add_students_by_search' + post 'create_group_by_importing_file' + post 'duplicate_course' + post 'visits_plus_one' + get 'get_historical_courses' + get 'get_historical_course_students' + get 'course_group_list' + get 'add_teacher_popup' + get 'teachers' + get 'apply_teachers' + get 'graduation_group_list' + get 'top_banner' + get 'left_banner' + get 'students' + get 'all_course_groups' + get 'search_users' + get 'base_info' + get 'attahcment_category_list' + get 'export_member_scores_excel' #导出课堂信息 + get 'export_couser_info' + get 'export_member_act_score' + post 'switch_to_teacher' + post 'switch_to_assistant' + post 'switch_to_student' + post 'exit_course' + get 'informs' + post 'update_informs' + post 'new_informs' + delete 'delete_informs' + get 'online_learning' + post 'join_excellent_course' + get 'tasks_list' + post 'update_task_position' + end + + collection do + post 'apply_to_join_course' + post 'search_course_list' + get 'board_list' + get 'mine' + get 'search_slim' + end + + resources :polls, only:[:index,:new,:create] do + collection do + post :publish # 立即发布 + post :end_poll # 立即截止 + post :destroys # 多个删除 + post :set_public # 设置公开 + post :join_poll_banks # 加入习题集 + get :my_polls #我的问卷题库 + get :public_polls # 公共问卷题库 + get :publish_modal # 立即发布弹窗内容 + get :end_poll_modal # 立即截止弹窗内容 + end + end + + resources :homework_commons, shallow: true do + + member do + get :group_list + post :homework_code_repeat + get :code_review_results + get :code_review_detail + post :update_explanation + get :show_comment + get :settings + post :update_settings + match 'works_list', :via => [:get, :post] + # post :works_list + get :reference_answer + get :publish_groups + get :end_groups + post :alter_name + get :update_score + get :update_student_score + end + + collection do + post 'create_shixun_homework' + match 'shixuns', via: [:get, :post] + match 'subjects', via: [:get, :post] + post 'create_subject_homework' + post 'publish_homework' + post 'end_homework' + post 'set_public' + post 'move_to_category' + get 'choose_category' + post 'multi_destroy' + post 'add_to_homework_bank' + end + + resources :student_works do + member do + get :shixun_work + get :shixun_work_report + post :adjust_review_score + get :commit_des + post :update_des + post :adjust_score + post :add_score + post :add_score_reply + delete :destroy_score + delete :destroy_score_reply + get :comment_list + get :supply_attachments + post :revise_attachment + delete :destroy_score + post :appeal_anonymous_score + post :deal_appeal_score + post :cancel_appeal + get :export_shixun_work_report + end + + collection do + get :search_member_list + get :check_project + get :cancel_relate_project + post :relate_project + delete :delete_work + end + end + end + + + resources :boards, shallow: true do + resources :messages do + collection do + delete :bulk_delete + put :bulk_move + post :bulk_send + put :bulk_public + end + + member do + get :reply_list + put :sticky_top + post :reply + end + end + member do + post 'move_category' + end + end + + resources :exercises ,only:[:index,:new,:create] do + collection do + get :my_exercises #我的试卷题库 + get :public_exercises # 公共试卷题库 + get :publish_modal # 立即发布弹窗内容 + get :end_modal # 立即截止弹窗内容 + post :destroys + post :set_public # 设置公开 + post :join_exercise_banks # 加入习题集 + post :publish # 立即发布 + post :end_exercise # 立即截止 + + end + end + + resources :course_groups, shallow: true do + member do + post 'rename_group' + post 'move_category' + end + + collection do + end + end + + resources :graduation_topics do + member do + post :refuse_student_topic + post :accept_student_topic + post :student_select_topic + post :student_cancel_topic + get :show_detail + get :show_comment + end + collection do + delete :destroys + post :set_public + get :export + post :add_to_bank + end + end + + resources :graduation_tasks, shallow: true do + resources :graduation_works do + collection do + post 'search_member_list' + get 'check_project' + post 'relate_project' + get 'cancel_relate_project' + post 'revise_attachment' + end + + member do + get 'comment_list' + post 'add_score' + post 'adjust_score' + delete 'delete_score' + get 'supply_attachments' + post 'revise_attachment' + post :assign_teacher + end + end + member do + get 'settings' + post 'update_settings' + get 'tasks_list' + get :show_comment + end + + collection do + post 'set_public' + delete 'multi_destroy' + post 'publish_task' + post 'end_task' + post 'add_to_bank' + end + end + end + + resources :polls,except:[:index,:new,:create] do + member do + get :poll_setting + post :commit_setting + get :start_answer + post :commit_poll + get :commit_result + get :poll_lists # 问卷的答题列表 + post :cancel_publish #撤销发布 + get :cancel_publish_modal #撤销发布的弹窗 + get :common_header + end + resources :poll_questions,only:[:new,:create] + end + + resources :poll_questions,except:[:new,:create,:index] do + member do + post :delete_answer + post :up_down + post :commit_answer + end + resource :poll_votes,only:[:create,:destroy] + end + + resources :exercises do + member do + get :choose_shixun + get :commit_shixun + get :exercise_setting + post :commit_setting + get :start_answer + post :commit_exercise + get :redo_modal #打回重做弹窗内容 + post :redo_exercise + get :review_exercise + get :exercise_lists + # get :blank_exercise #摒弃,仅作为测试html页面才会使用 + get :export_exercise + get :common_header + get :exercise_result + post :cancel_exercise + get :begin_commit #提交前的弹窗 + end + resources :exercise_questions,only:[:new,:create,:index] + end + + resources :exercise_questions,except:[:new,:create,:index] do + member do + post :up_down + post :delete_answer + post :adjust_score + post :update_scores + end + resource :exercise_answers,only:[:create,:destroy] + end + + + resources :course_modules, shallow: true do + member do + get 'sticky_module' + get 'hidden_module' + post 'rename_module' + post 'add_second_category' + end + collection do + post 'unhidden_modules' + end + end + + resources :course_second_categories, shallow: true do + member do + post 'rename_category' + post 'move_category' + end + collection do + + end + end + + resources :question_banks do + collection do + get :bank_list + post :save_banks + get :my_courses + post :send_to_course + delete :multi_delete + post :multi_public + end + end + + resources :homework_banks do + member do + post :set_public + end + end + + resources :gtopic_banks + resources :task_banks + + resources :exercise_banks do + collection do + get :choose_shixun + end + + member do + get :commit_shixun + end + end + + resources :exercise_bank_questions do + member do + post :up_down + get :choose_shixun + end + end + + resources :poll_bank_questions + + resources :attachments + + resources :schools do + member do + resources :departments, only: [] do + get :for_option, on: :collection + end + end + collection do + get :school_list + get :for_option + end + + scope module: :ecs do + get :detail, to: 'homes#index' + + resources :ec_majors, only: [:index] + resources :ec_major_schools, only: [:index, :create, :destroy] + end + end + resources :add_school_applies, only: [:create] + resources :add_department_applies, only: [:create] + + # 为避免url过长以及层级过深,路由定义和controller继承都做了处理 + scope module: :ecs do + resources :ec_major_schools, only: [] do + resources :major_managers, only: [:create, :destroy] + resources :ec_years, only: [:index, :create, :destroy] + end + + resources :ec_years, only: [] do + resource :ec_training_objectives, only: [:show, :create] + resources :ec_graduation_requirements, only: [:index, :create] + resource :requirement_support_objectives, only: [:show, :create, :destroy] + resource :subitem_support_standards, only: [:show, :create, :destroy] + resource :students, only: [:show, :destroy] do + post :import, on: :collection + end + + resources :ec_courses, only: [:index, :create, :destroy] do + post :link_course, on: :member + + collection do + post :import + get :search + end + end + + resource :graduation_course_supports, only: [:show, :create] + resource :reach_evaluation, only: [:show, :create] + resource :reach_criteria, only: [:create] + end + + resources :ec_courses, only: [] do + resource :evaluation, only: [:show, :create] + resources :course_managers, only: [:create, :destroy] + resources :course_targets, only: [:index, :create] do + get :with_achievement_methods, on: :collection + + resource :course_achievement_methods, only: [:create] + end + resources :course_evaluations, only: [:index, :create, :update, :destroy] do + member do + get :average_score_import_template + get :detail_score_import_template + get :import_student_achievement + end + get :slimmer, on: :collection + end + resource :score_levels, only: [:show, :create] + end + end + + resource :zip, only: [] do + collection do + get :shixun_report + get :export_exercises + end + end + + resources :repertoires, only: [:index] + + scope module: :competitions do + resources :competitions, only: [:index, :show] do + resources :competition_modules, only: [:index, :show, :update] + resource :competition_staff + resources :competition_teams, only: [:index, :show] do + post :join, on: :collection + post :leave, on: :member + end + resources :teachers, only: [:index] + resources :students, only: [:index] + end + end + + resources :project_package_categories, only: [:index] + resources :project_packages, only: [:index, :show, :create, :update, :destroy] do + resources :bidding_users, only: [:create] do + post :win, on: :collection + end + end + + resources :libraries, only: [:index, :show, :create, :update, :destroy] + + scope module: :projects do + resources :project_applies, only: [:create] + end + + post 'callbacks/aliyun_vod', to: 'callbacks/aliyun_vods#create' + + namespace :wechats do + resource :js_sdk_signature, only: [:create] + end + end + + namespace :admins do + get '/', to: 'dashboards#index' + resources :dashboards, only: [:index] do + collection do + get :month_active_user + get :evaluate + end + end + resources :files, only: [:create] + + resources :daily_school_statistics, only: [:index] do + get :export, on: :collection + end + + resources :school_statistics, only: [:index] do + get :contrast, on: :collection + end + + resources :users, only: [:index, :edit, :update, :destroy] do + member do + post :reward_grade + post :lock + post :unlock + post :active + end + end + resource :import_users, only: [:create] + resource :import_course_members, only: [:create] + + resources :library_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :video_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :identity_authentications, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :professional_authentications, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :shixun_authorizations, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :subject_authorizations, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :project_package_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :shixuns, only: [:index,:destroy] + resources :shixun_settings, only: [:index,:update] + resources :department_applies,only: [:index,:edit,:update,:destroy] do + member do + post :agree + end + end + resources :mirror_repositories, only: [:index, :new, :create, :edit, :update, :destroy] do + collection do + post :merge + get :for_select + end + resources :mirror_scripts, only: [:index, :new, :create, :edit, :update, :destroy] + end + resources :choose_mirror_repositories, only: [:new, :create] + resources :departments, only: [:index, :create, :edit, :update, :destroy] do + resource :department_member, only: [:create, :update, :destroy] + post :merge, on: :collection + end + resources :myshixuns, only: [:index] + end + + resources :colleges, only: [] do + member do + get :statistics + get :course_statistics + get :student_shixun + get :shixun_time + get :shixun_report_count + get :teachers + get :shixun_chart_data + get :student_hot_evaluations + end + end + + #git 认证回调 + match 'gitauth/*url', to: 'gits#auth', via: :all + + get 'oauth/get_code', to: 'oauth#get_code' + get 'oauth/get_token_callback', to: 'oauth#get_token_callback' + + root 'main#index' + + ## react用 + get '*path', to: 'main#index', constraints: ReactConstraint.new +end diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 1adf3aef9..8045580e9 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -32,7 +32,7 @@ module.exports = { // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", // 开启调试 - // devtool: "source-map", // 开启调试 + devtool: "eval", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. diff --git a/public/react/src/App.js b/public/react/src/App.js index fbb9ac7b0..f49ebed12 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -222,6 +222,12 @@ const InfosIndex = Loadable({ loader: () => import('./modules/user/usersInfo/InfosIndex'), loading: Loading, }) +// 题库 +const BanksIndex = Loadable({ + loader: () => import('./modules/user/usersInfo/banks/BanksIndex'), + loading: Loading, +}) + // 教学案例 const MoopCases = Loadable({ @@ -245,6 +251,11 @@ const Messagerouting= Loadable({ loader: () => import('./modules/message/js/Messagerouting'), loading: Loading, }) + +const Topicbank= Loadable({ + loader: () => import('./modules/topic_bank/Topic_bank'), + loading: Loading, +}) class App extends Component { constructor(props) { super(props) @@ -388,6 +399,15 @@ class App extends Component { + {/*题库*/} + { + + return () + } + }> + {/*众包创新*/} {/*认证*/} @@ -416,6 +436,13 @@ class App extends Component { } }> + { + return () + } + }> + diff --git a/public/react/src/common/SnackbarHOC.js b/public/react/src/common/SnackbarHOC.js index d66b697ca..fe5bc4901 100644 --- a/public/react/src/common/SnackbarHOC.js +++ b/public/react/src/common/SnackbarHOC.js @@ -48,7 +48,17 @@ export function SnackbarHOC(options = {}) { snackbarHorizontal: horizontal, }) } - + //个别情况需要走 + showNotification = (description, message = "提示", icon) => { + const data = { + message, + description + } + if (icon) { + data.icon = icon; + } + notification.open(data); + } render() { const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state; @@ -70,7 +80,7 @@ export function SnackbarHOC(options = {}) { resumeHideDuration={2000} message={{this.state.snackbarText}} /> - + diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index c0a5469ad..f21dc01ab 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -264,34 +264,12 @@ const GraduationTasksSubmiteditApp=Loadable({ loader: () => import('./graduation/tasks/GraduationTasksSubmitedit'), loading: Loading, }) -//普通作业题库详情 -const Generaljobbankdetails =Loadable({ - loader: () => import('../../modules/courses/questionbank/Generaljobbankdetails'), - loading: Loading, -}); -//分组作业题库详情 -const GroupjobbankPage =Loadable({ - loader: () => import('../../modules/courses/groupjobbank/GroupjobbankPage'), - loading: Loading, -}); -//毕设选题详情 -const CompletetopicdePage =Loadable({ - loader: () => import('../../modules/courses/comtopicdetails/CompletetopicdePage'), - loading: Loading, -}); -//毕设任务详情 -const Completetaskpage =Loadable({ - loader: () => import('../../modules/courses/completetaskdetails/Completetaskpage'), - loading: Loading, -}); - //排序 const Ordering=Loadable({ loader: () => import('../../modules/courses/ordering/Ordering'), loading: Loading, }); - class CoursesIndex extends Component{ constructor(props) { super(props) @@ -478,37 +456,12 @@ class CoursesIndex extends Component{ // console.log(commons) return ( - {/*排序*/} - () - } - > - - {/*毕设任务题库详情*/} - () - } - > - {/*毕设内容题库详情*/} - () - } - > - {/*分组作业题库详情*/} - () - } - > - {/* 普通作业题库详情*/} - () - } - > + {/*排序*/} + () + } + > {/* 资源列表页 */} { if (response.data.name) { const data = response.data; - - const contentFileList = data.attachments.map(item => { - return { - id: item.id, - uid: item.id, - name: appendFileSizeToUploadFile(item), - url: item.url, - filesize: item.filesize, - status: 'done' - } - }) - const answerFileList = data.ref_attachments.map(item => { - return { - id: item.id, - uid: item.id, - name: appendFileSizeToUploadFile(item), - url: item.url, - filesize: item.filesize, - status: 'done' - } - }) - + data.isEdit = this.isEdit this.setState({ - ...data, - // course_id: data.course_id, - // course_name: data.course_name, - // category: data.category, - title_num: parseInt(data.name.length), - workLoaded: true, - init_min_num: data.min_num, - init_max_num: data.max_num, - // description: data.description, - reference_answer: data.reference_answer, - contentFileList, - answerFileList, - }, () => { - setTimeout(() => { - this.contentMdRef.current.setValue(data.description || '') - this.answerMdRef.current.setValue(data.reference_answer || '') - - }, 2000) - - this.props.form.setFieldsValue({ - title: data.name, - description: data.description || '', - reference_answer: data.reference_answer || '', - }); - + course_id: data.course_id, + course_name: data.course_name, + category: data.category, }) - + this.newWorkFormRef.initValue(response.data) } }) .catch(function (error) { @@ -123,72 +74,15 @@ class NewWork extends Component{ }); } - // 输入title - changeTitle=(e)=>{ - console.log(e.target.value.length); - this.setState({ - title_num: parseInt(e.target.value.length) - }) + onCancel = () => { + this.props.toListPage(this.props.match.params, this.state.category.category_id) } - handleSubmit = () => { - const courseId = this.state.course_id || this.props.match.params.coursesId ; - - this.props.form.validateFieldsAndScroll((err, values) => { - console.log(values) - const mdContnet = this.contentMdRef.current.getValue().trim(); - console.log(mdContnet) - values.description = mdContnet; - // return; - - {/* max={has_commit ? init_min_num : null } */} - {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} - // 已有提交作品,人数范围只能扩大 - const { has_commit, max_num, init_max_num, min_num, init_min_num } = this.state; - if (has_commit) { - if (max_num < init_max_num || min_num > init_min_num) { - this.props.showNotification(`已有提交作品,人数范围只能扩大(原设置为:${init_min_num} - ${init_max_num})`) - return; - } - } - // const errKeys = Object.keys(err); // || errKeys.length == 1 && errKeys[0] == 'content' && mdContnet - if (!err) { - if (this.isEdit) { - this.doEdit(courseId, values) - } else { - this.doNew(courseId, values) - } - - } else { - $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) - } - }) - } - doEdit = (courseId, values) => { + doEdit = (params) => { const workId = this.props.match.params.workId const newUrl = `/homework_commons/${workId}.json` - let attachment_ids = this.state.contentFileList.map(item => { - return item.response ? item.response.id : item.id - }) - let reference_attachment_ids = this.state.answerFileList.map(item => { - return item.response ? item.response.id : item.id - }) - - const { min_num, max_num, base_on_project, category } = this.state - const isGroup = this.props.isGroup() - axios.put(newUrl, { - type: isGroup ? 3 : 1, - name: values.title, - description: values.description, - reference_answer: values.reference_answer, - attachment_ids, - reference_attachment_ids, - - min_num, - max_num, - base_on_project - }) + axios.put(newUrl, params) .then((response) => { if (response.data.status == 0) { this.props.showNotification('保存成功') @@ -199,30 +93,11 @@ class NewWork extends Component{ console.log(error); }); } - doNew = (courseId, values) => { - const newUrl = `/courses/${courseId}/homework_commons.json` - - let attachment_ids = this.state.contentFileList.map(item => { - return item.response ? item.response.id : item.id - }) - let reference_attachment_ids = this.state.answerFileList.map(item => { - return item.response ? item.response.id : item.id - }) - const isGroup = this.props.isGroup() - const { min_num, max_num, base_on_project, category } = this.state - - axios.post(newUrl, { - type: isGroup ? 3 : 1, - name: values.title, - description: values.description, - reference_answer: values.reference_answer, - attachment_ids, - reference_attachment_ids, + doNew = (params) => { + const coursesId = this.props.match.params.coursesId + const newUrl = `/courses/${coursesId}/homework_commons.json` - min_num, - max_num, - base_on_project - }) + axios.post(newUrl, params) .then((response) => { if (response.data.status == 0) { this.props.showNotification('保存成功') @@ -265,119 +140,31 @@ class NewWork extends Component{ } } - deleteAttachment = (file, stateName) => { - // 初次上传不能直接取uid - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - console.log('--- success') - - this.setState((state) => { - const index = state[stateName].indexOf(file); - const newFileList = state[stateName].slice(); - newFileList.splice(index, 1); - return { - [stateName]: newFileList, - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - max_num_change = (val) => { - if (val < 2) { - this.setState({ - max_num: 2, - }) - return; - } - const { min_num } = this.state; - this.setState({ - max_num: val, - min_num: val <= min_num ? val - 1 : min_num - }) - } - min_num_change = (val) => { - this.setState({ min_num: val }) - } - base_on_project_change = () => { - this.setState({ base_on_project: !this.state.base_on_project }) - } render(){ let {typeId,coursesId,pageType}=this.props.match.params; - const { getFieldDecorator } = this.props.form; + const isGroup = this.props.isGroup() const moduleName = !isGroup? "普通作业":"分组作业"; const moduleEngName = this.props.getModuleName() let{ - title_value, contentFileList, answerFileList, max_num, min_num, base_on_project, - init_max_num, init_min_num, - title_num, course_name, category, has_commit, has_project + course_name, category }=this.state const { current_user } = this.props - const courseId = this.state.course_id || this.props.match.params.coursesId ; + const courseId = this.state.course_id || coursesId ; const isEdit = this.isEdit; - if ((isEdit == undefined || isEdit) && !this.state.workLoaded) { - return '' - } - const uploadProps = { - width: 600, - fileList: contentFileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUploadActionUrl()}`, - onChange: this.handleContentUploadChange, - onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), - beforeUpload: (file) => { - console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 150; - if (!isLt150M) { - this.props.showNotification('文件大小必须小于150MB!'); - } - return isLt150M; - }, - }; - const answerUploadProps = { - width: 600, - fileList: answerFileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUrl()}/api/attachments.json`, - onChange: this.handleAnswerUploadChange, - onRemove: (file) => this.onAttachmentRemove(file, 'answerFileList'), - beforeUpload: (file) => { - console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 150; - if (!isLt150M) { - this.props.showNotification('文件大小必须小于150MB!'); - } - return isLt150M; - }, - }; + + const common = { + onCancel:this.onCancel, + isGroup: this.props.isGroup, + doNew: this.doNew, + doEdit: this.doEdit, + } return(
- {/*

- {course_name} - > - {typeId==1 ?"普通作业":"分组作业"} - > - {pageType==="new"?"新建":"编辑"} -

*/} {this.isEdit ?"编辑":"新建"}{ moduleName } - {/* history.goBack() - this.props.toListPage(this.props.match.params, category.category_id)} - */} this.props.history.goBack()}> 返回

- {/* onSubmit={this.handleSubmit} */} -
- - {getFieldDecorator('title', { - rules: [{ - required: true, message: '请输入标题' - }], - })( - - )} - - - - - { - {getFieldDecorator('description', { - rules: [{ - required: true, message: '请输入作业内容和要求' - }], - })( - - )} - } - - - (单个文件150M以内) - - - - { isGroup && - - {getFieldDecorator('personNum', { - rules: [{ - required: false - // required: true, message: '请输入最小人数和最大人数' - }], - })( -
-

- - {/* max={has_commit ? init_min_num : null } */} - - - - ~ - {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} - - - - -

-

- - 基于项目实施 - - - -

-
- )} -
- } - - {getFieldDecorator('reference_answer', { - rules: [{ - required: false - }], - })( - - )} - - - (单个文件150M以内) - - - - - - + {this.newWorkFormRef = ref}} + >
) } } -const WrappedBoardsNew = Form.create({ name: 'NewWork' })(NewWork); -export default WrappedBoardsNew; \ No newline at end of file + +export default NewWork; \ No newline at end of file diff --git a/public/react/src/modules/courses/busyWork/NewWorkForm.js b/public/react/src/modules/courses/busyWork/NewWorkForm.js new file mode 100644 index 000000000..eaae55a42 --- /dev/null +++ b/public/react/src/modules/courses/busyWork/NewWorkForm.js @@ -0,0 +1,473 @@ +import React,{ Component } from "react"; +import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Modal } from "antd"; +import axios from 'axios' +import '../css/busyWork.css' +import '../css/Courses.css' +import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' +import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; +import CBreadcrumb from '../common/CBreadcrumb' + +const confirm = Modal.confirm; +const $ = window.$ +const MAX_TITLE_LENGTH = 60; + +/** + 需要注意的props + isGroup +*/ +class NewWorkForm extends Component{ + constructor(props){ + super(props); + this.contentMdRef = React.createRef(); + this.answerMdRef = React.createRef(); + + this.state={ + title_value:"", + title_num: 0, + contentFileList: [], + answerFileList: [], + workLoaded: false, + base_on_project: true, + category: {}, + min_num: 2, + max_num: 10, + } + } + initValue = (data) => { + if (data.isEdit) { + const contentFileList = data.attachments.map(item => { + return { + id: item.id, + uid: item.id, + name: appendFileSizeToUploadFile(item), + url: item.url, + filesize: item.filesize, + status: 'done' + } + }) + const answerFileList = data.ref_attachments.map(item => { + return { + id: item.id, + uid: item.id, + name: appendFileSizeToUploadFile(item), + url: item.url, + filesize: item.filesize, + status: 'done' + } + }) + + this.setState({ + ...data, + // course_id: data.course_id, + // course_name: data.course_name, + // category: data.category, + title_num: parseInt(data.name.length), + workLoaded: true, + init_min_num: data.min_num, + init_max_num: data.max_num, + // description: data.description, + reference_answer: data.reference_answer, + contentFileList, + answerFileList, + }, () => { + setTimeout(() => { + this.contentMdRef.current.setValue(data.description || '') + this.answerMdRef.current.setValue(data.reference_answer || '') + + }, 2000) + + this.props.form.setFieldsValue({ + title: data.name, + description: data.description || '', + reference_answer: data.reference_answer || '', + }); + + }) + } else { // new + + } + } + + + // 输入title + changeTitle=(e)=>{ + console.log(e.target.value.length); + this.setState({ + title_num: parseInt(e.target.value.length) + }) + } + handleSubmit = () => { + const courseId = this.state.course_id || this.props.match.params.coursesId ; + + this.props.form.validateFieldsAndScroll((err, values) => { + console.log(values) + const mdContnet = this.contentMdRef.current.getValue().trim(); + console.log(mdContnet) + values.description = mdContnet; + // return; + + {/* max={has_commit ? init_min_num : null } */} + {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} + // 已有提交作品,人数范围只能扩大 + const { has_commit, max_num, init_max_num, min_num, init_min_num } = this.state; + if (has_commit) { + if (max_num < init_max_num || min_num > init_min_num) { + this.props.showNotification(`已有提交作品,人数范围只能扩大(原设置为:${init_min_num} - ${init_max_num})`) + return; + } + } + + // const errKeys = Object.keys(err); // || errKeys.length == 1 && errKeys[0] == 'content' && mdContnet + if (!err) { + if (this.state.isEdit) { + this.doEdit(courseId, values) + } else { + this.doNew(courseId, values) + } + + } else { + $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) + } + }) + } + doEdit = (courseId, values) => { + let attachment_ids = this.state.contentFileList.map(item => { + return item.response ? item.response.id : item.id + }) + let reference_attachment_ids = this.state.answerFileList.map(item => { + return item.response ? item.response.id : item.id + }) + + const { min_num, max_num, base_on_project, category } = this.state + const isGroup = this.props.isGroup() + + const params = { + type: isGroup ? 3 : 1, + name: values.title, + description: values.description, + reference_answer: values.reference_answer, + attachment_ids, + reference_attachment_ids, + + min_num, + max_num, + base_on_project + } + this.props.doEdit && this.props.doEdit(params) + } + doNew = (courseId, values) => { + let attachment_ids = this.state.contentFileList.map(item => { + return item.response ? item.response.id : item.id + }) + let reference_attachment_ids = this.state.answerFileList.map(item => { + return item.response ? item.response.id : item.id + }) + const isGroup = this.props.isGroup() + const { min_num, max_num, base_on_project, category } = this.state + + const params = { + type: isGroup ? 3 : 1, + name: values.title, + description: values.description, + reference_answer: values.reference_answer, + attachment_ids, + reference_attachment_ids, + + min_num, + max_num, + base_on_project + } + this.props.doNew && this.props.doNew(params) + + } + + handleContentUploadChange = (info) => { + if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { + let contentFileList = info.fileList; + this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList) }); + } + } + handleAnswerUploadChange = (info) => { + if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { + let answerFileList = info.fileList; + this.setState({ answerFileList: appendFileSizeToUploadFileAll(answerFileList) }); + } + } + + onAttachmentRemove = (file, stateName) => { + if(!file.percent || file.percent == 100){ + this.props.confirm({ + content: '是否确认删除?', + + onOk: () => { + this.deleteAttachment(file, stateName) + }, + onCancel() { + console.log('Cancel'); + }, + }); + } + return false; + } + deleteAttachment = (file, stateName) => { + // 初次上传不能直接取uid + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { + console.log('--- success') + + this.setState((state) => { + const index = state[stateName].indexOf(file); + const newFileList = state[stateName].slice(); + newFileList.splice(index, 1); + return { + [stateName]: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); + } + max_num_change = (val) => { + if (val < 2) { + this.setState({ + max_num: 2, + }) + return; + } + const { min_num } = this.state; + this.setState({ + max_num: val, + min_num: val <= min_num ? val - 1 : min_num + }) + } + min_num_change = (val) => { + this.setState({ min_num: val }) + } + base_on_project_change = () => { + this.setState({ base_on_project: !this.state.base_on_project }) + } + + render(){ + let {typeId,coursesId,pageType}=this.props.match.params; + const { getFieldDecorator } = this.props.form; + const isGroup = this.props.isGroup() + let{ + title_value, contentFileList, answerFileList, max_num, min_num, base_on_project, + init_max_num, init_min_num, + title_num, course_name, category, has_commit, has_project, + + isEdit + }=this.state + const { current_user } = this.props + + const courseId = this.state.course_id || this.props.match.params.coursesId ; + + if ((isEdit) && !this.state.workLoaded) { + return '' + } + const uploadProps = { + width: 600, + fileList: contentFileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUrl()}/api/attachments.json`, + onChange: this.handleContentUploadChange, + onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), + beforeUpload: (file) => { + console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 150; + if (!isLt150M) { + this.props.showNotification('文件大小必须小于150MB!'); + } + return isLt150M; + }, + }; + const answerUploadProps = { + width: 600, + fileList: answerFileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUrl()}/api/attachments.json`, + onChange: this.handleAnswerUploadChange, + onRemove: (file) => this.onAttachmentRemove(file, 'answerFileList'), + beforeUpload: (file) => { + console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 150; + if (!isLt150M) { + this.props.showNotification('文件大小必须小于150MB!'); + } + return isLt150M; + }, + }; + + return( + + + +
+ + {getFieldDecorator('title', { + rules: [{ + required: true, message: '请输入标题' + }], + })( + + )} + + + + + { + {getFieldDecorator('description', { + rules: [{ + required: true, message: '请输入作业内容和要求' + }], + })( + + )} + } + + + (单个文件150M以内) + + + + { isGroup && + + {getFieldDecorator('personNum', { + rules: [{ + required: false + // required: true, message: '请输入最小人数和最大人数' + }], + })( +
+

+ + {/* max={has_commit ? init_min_num : null } */} + + + + ~ + {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} + + + + +

+

+ + 基于项目实施 + + + +

+
+ )} +
+ } + + {getFieldDecorator('reference_answer', { + rules: [{ + required: false + }], + })( + + )} + + + (单个文件150M以内) + + + +
+ + + + + ) + } +} +const WrappedWorkForm = Form.create({ name: 'NewWorkForm' })(NewWorkForm); +export default WrappedWorkForm; \ No newline at end of file diff --git a/public/react/src/modules/courses/completetaskdetails/Completetaskdetails.js b/public/react/src/modules/courses/completetaskdetails/Completetaskdetails.js index 850ed2b89..7078f00e8 100644 --- a/public/react/src/modules/courses/completetaskdetails/Completetaskdetails.js +++ b/public/react/src/modules/courses/completetaskdetails/Completetaskdetails.js @@ -1,5 +1,6 @@ + import React, {Component} from "react"; -import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder'; +import { WordsBtn,on, off, trigger,MarkdownToHtml,getImageUrl} from 'educoder'; import { Button, Checkbox, @@ -13,6 +14,9 @@ import { import './completetaskdetails.css'; import GroupPackage from "../groupjobbank/GroupPackage"; import GroupPackage2 from "../groupjobbank/GroupPackage2"; +import AttachmentsList from "../../../common/components/attachment/AttachmentList"; +import NoneData from '../../courses/coursesPublic/NoneData' + class Groupjobbandetails extends Component { @@ -57,20 +61,35 @@ class Groupjobbandetails extends Component { render() { - + let{datas}=this.props; return (
+ { + datas&&(datas.description===null? + + :datas.description==="null"? + + : + datas.description===""? + + : + + //
+ ) + } + {/*
*/} + {/*{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {*/} + {/* return (*/} + {/* */} + {/* )*/} + {/*})}*/} +
+ {datas.attachments === undefined ? "" : + } +
+ -
- - - -
diff --git a/public/react/src/modules/courses/completetaskdetails/Completetaskpage.js b/public/react/src/modules/courses/completetaskdetails/Completetaskpage.js index d7cd7a62c..e2b1e29e1 100644 --- a/public/react/src/modules/courses/completetaskdetails/Completetaskpage.js +++ b/public/react/src/modules/courses/completetaskdetails/Completetaskpage.js @@ -1,34 +1,43 @@ import React, {Component} from "react"; -import {Link, NavLink} from 'react-router-dom'; -import {WordsBtn, ActionBtn} from 'educoder'; +import {BrowserRouter as Router,Route,Switch,Link, NavLin} from 'react-router-dom'; +import {WordsBtn, ActionBtn,getImageUrl} from 'educoder'; +import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form } from "antd"; import axios from 'axios'; -import { - notification -} from "antd"; -import CoursesListType from '../coursesPublic/CoursesListType'; -import Completetaskdetails from './Completetaskdetails'; +import BanksMenu from '../../user/usersInfo/banks/banksMenu' +import Loadable from 'react-loadable'; +import Loading from '../../../Loading'; import '../css/members.css'; import "../common/formCommon.css"; import '../css/Courses.css'; import '../css/busyWork.css'; import '../poll/pollStyle.css'; +const Completetaskdetails = Loadable({ + loader: () => import('./Completetaskdetails'), + loading: Loading, +}) + class Completetaskpage extends Component { //分组作业内容详情 constructor(props) { super(props); // this.answerMdRef = React.createRef(); - this.setState({ + this.state={ workid:1, isSpin:false, datas:[], - }) + visible:false, + banksMenu:undefined + } } componentDidMount() { // console.log("父组件加载框"); + this.getonedata(); + } + getonedata(){ if( this.props.match.params.workid){ this.setState({ workid: this.props.match.params.workid, @@ -47,14 +56,40 @@ class Completetaskpage extends Component { this.setState({ isSpin:true, }) - let url = `/homework_banks/${workids}.json`; + let url = `/task_banks/${workids}.json`; // axios.get(url).then((response) => { if(response){ if(response.data){ this.setState({ - datas:response.data.informs, - }) + datas:response.data, + }); + try { + const crumbData={ + title:response && response.data && response.data.name, + is_public:response && response.data && response.data.is_public, + crumbArray:[ + {content:'详情'} + ] + }; + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/gtask/${workids}/${this.props.match.params.type}/details`,content:'内容详情'}, + ], + category:'gtask',//毕设选题 + tos:`/banks/gtask/${workids}/edit/${this.props.match.params.type}`, + id:workids, + is_public:response && response.data && response.data.is_public, + type:this.props.match.params.type, + } + this.setState({ + banksMenu:menuData + }) + this.props.initPublic(crumbData); + }catch (e) { + + } }else { this.setState({ datas:[], @@ -79,60 +114,33 @@ class Completetaskpage extends Component { }) }); } - - - - bindRef = ref => { this.child = ref } -///////////////教师截止 - render() { - - const isAdmin = this.props.isAdmin(); - // console.log(119) - + let {datas} = this.state; + let{ + banksMenu + }=this.state; return ( -
- - -
- - -
-

- MySQL数据库编程开发实训(基础篇) -

- -
- -
- -
- - - -
-
+ + { + banksMenu && + + } + + { + return () + } + }> + + ) } } export default Completetaskpage; - diff --git a/public/react/src/modules/courses/completetaskdetails/completetaskdetails.css b/public/react/src/modules/courses/completetaskdetails/completetaskdetails.css index fd1b10f51..809736d69 100644 --- a/public/react/src/modules/courses/completetaskdetails/completetaskdetails.css +++ b/public/react/src/modules/courses/completetaskdetails/completetaskdetails.css @@ -1,7 +1,9 @@ + .yslquestionbank1{ padding-top: 30px !important; padding-right: 30px !important; padding-left: 30px !important; + padding-bottom: 14px !important; } .yslquesHeigth{ min-height: 500px !important; @@ -10,7 +12,6 @@ .yslquesmarkdowntext{ font-size: 16px; color: #707070; - } .yslquesmat26{ margin-top: 26px; @@ -55,4 +56,10 @@ .yslboomdivsys{ color: #666666; font-size: 14px; -} \ No newline at end of file +} +.pad20{ + padding-bottom: 20px !important; +} +.mt24{ + margin-top: 24px !important ; + } \ No newline at end of file diff --git a/public/react/src/modules/courses/comtopicdetails/CompletetopicdePage.js b/public/react/src/modules/courses/comtopicdetails/CompletetopicdePage.js index cde4f5f5e..2235c5a1e 100644 --- a/public/react/src/modules/courses/comtopicdetails/CompletetopicdePage.js +++ b/public/react/src/modules/courses/comtopicdetails/CompletetopicdePage.js @@ -1,29 +1,32 @@ import React, {Component} from "react"; -import {Link, NavLink} from 'react-router-dom'; -import {WordsBtn, ActionBtn} from 'educoder'; +import {BrowserRouter as Router,Route,Switch,Link, NavLin} from 'react-router-dom'; +import {WordsBtn, ActionBtn,getImageUrl} from 'educoder'; import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form } from "antd"; import axios from 'axios'; -import { - notification -} from "antd"; -import CoursesListType from '../coursesPublic/CoursesListType'; -import Completetopicdetails from './Completetopicdetails'; +import BanksMenu from '../../user/usersInfo/banks/banksMenu' +import Loadable from 'react-loadable'; +import Loading from '../../../Loading'; import '../css/members.css'; import "../common/formCommon.css"; import '../css/Courses.css'; import '../css/busyWork.css'; import '../poll/pollStyle.css'; - +const Completetopicdetails = Loadable({ + loader: () => import('./Completetopicdetails'), + loading: Loading, +}) class CompletetopicdePage extends Component { //毕设选题内容详情 constructor(props) { super(props); // this.answerMdRef = React.createRef(); - this.setState({ + this.state={ workid:1, isSpin:false, datas:[], - }) + visible:false, + banksMenu:undefined + } } @@ -48,14 +51,40 @@ class CompletetopicdePage extends Component { this.setState({ isSpin:true, }) - let url = `/homework_banks/${workids}.json`; + let url = `/gtopic_banks/${workids}.json`; // axios.get(url).then((response) => { if(response){ if(response.data){ this.setState({ - datas:response.data.informs, - }) + datas:response.data, + }); + try { + const crumbData={ + title:response && response.data && response.data.name, + is_public:response && response.data && response.data.is_public, + crumbArray:[ + {content:'详情'} + ] + } + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/gtopic/${workids}/${this.props.match.params.type}/details`,content:'内容详情'}, + ], + category:'gtopic',//毕设选题 + tos:`/banks/gtopic/${workids}/edit/${this.props.match.params.type}`, + id:workids, + is_public:response && response.data && response.data.is_public, + type:this.props.match.params.type, + } + this.setState({ + banksMenu:menuData + }) + this.props.initPublic(crumbData); + }catch (e) { + + } }else { this.setState({ datas:[], @@ -81,58 +110,35 @@ class CompletetopicdePage extends Component { }); } - /// 确认是否下载 - - - bindRef = ref => { this.child = ref } -///////////////教师截止 - render() { + let {tab,datas,visible} = this.state; - const isAdmin = this.props.isAdmin(); - // console.log(119) - - + let{ + banksMenu + }=this.state + // + // const common={ + // initPublic:this.initPublic, + // } return ( -
- - -
- -
-

- 题库 - > - 详情 -

-
-
-

- MySQL数据库编程开发实训(基础篇) -

- -
- -
- -
- - - {/*{parseInt(tab) === 1 ? :""}*/} - -
-
+ + { + banksMenu && + + } + + { + return () + } + }> + + ) } } diff --git a/public/react/src/modules/courses/comtopicdetails/Completetopicdetails.js b/public/react/src/modules/courses/comtopicdetails/Completetopicdetails.js index 15b4c24cf..0ee640425 100644 --- a/public/react/src/modules/courses/comtopicdetails/Completetopicdetails.js +++ b/public/react/src/modules/courses/comtopicdetails/Completetopicdetails.js @@ -1,5 +1,5 @@ import React, {Component} from "react"; -import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder'; +import { WordsBtn,on, off, trigger,MarkdownToHtml,getImageUrl} from 'educoder'; import { Button, Checkbox, @@ -12,6 +12,8 @@ import { } from "antd"; import GroupPackage from '../groupjobbank/GroupPackage' import './completetopicde.css'; +import AttachmentsList from "../../../common/components/attachment/AttachmentList"; +import NoneData from '../../courses/coursesPublic/NoneData' class Completetopicdetails extends Component { @@ -56,52 +58,69 @@ class Completetopicdetails extends Component { render() { - + let{datas}=this.props; return (
- -
- - + { + datas&&(datas.description===null? + + :datas.description==="null"? + + : + datas.description===""? + + : + + + //
+ ) + } + {/*
*/} + + {/*{datas.attachment_list === undefined ? "" : datas.attachment_list.map((item, key) => {*/} + {/* return (*/} + {/* */} + {/* )*/} + {/*})}*/} +
+ {datas.attachment_list === undefined ? "" : + } +

课题类型: - 设计 + {datas&&datas.topic_type===1?"设计":datas&&datas.topic_type===2?"论文":datas&&datas.topic_type===3?"创作":"无"}

课题来源: - 生产/社会实践 + {datas&&datas.topic_source===1?"生产/社会实际":datas&&datas.topic_source===2?"结合科研":datas&&datas.topic_source===3?"其它":"无"}

课题性质1: - 设计 + {datas&&datas.topic_property_first===1?"真题":datas&&datas.topic_property_first===2?"模拟题":"无"}

课题性质2: - 设计 + {datas&&datas.topic_property_second===1?"纵向课题":datas&&datas.topic_property_second===2?"横向课题":datas&&datas.topic_property_second===3?"自选":"无"}

-
+

课题重复情况: - 新需求 + {datas&&datas.topic_repeat===1?"新题":datas&&datas.topic_repeat===2?"往届题,有新要求":datas&&datas.topic_repeat===3?"往届题,无新要求":"无"}

调研或实习地点: - 长沙 + {datas&&datas.province}{datas&&datas.city}

课题单位来源: - 湖南省据C++创始人Stroustrup有限公司 + {datas&&datas.source_unit===undefined?"无":datas&&datas.source_unit===null?"无":datas&&datas.source_unit===""?"无":datas&&datas.source_unit==="null"?"无":datas.source_unit}

diff --git a/public/react/src/modules/courses/comtopicdetails/completetopicde.css b/public/react/src/modules/courses/comtopicdetails/completetopicde.css index fd566ffdc..963d6522d 100644 --- a/public/react/src/modules/courses/comtopicdetails/completetopicde.css +++ b/public/react/src/modules/courses/comtopicdetails/completetopicde.css @@ -55,4 +55,8 @@ .yslboomdivsys{ color: #666666; font-size: 14px; +} +.mb29px{ + padding-top: 14px !important; + margin-bottom: 29px !important; } \ No newline at end of file diff --git a/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js b/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js index 68a4c6efe..cca75fc86 100644 --- a/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js +++ b/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js @@ -37,7 +37,7 @@ class ShixunChooseModal extends Component{ hometypepvisible:loading }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url, { params: { @@ -76,7 +76,7 @@ class ShixunChooseModal extends Component{ }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url).then((result)=>{ if(result.status===200){ diff --git a/public/react/src/modules/courses/coursesPublic/ShixunModal.js b/public/react/src/modules/courses/coursesPublic/ShixunModal.js index 3a3e20041..5c1720ace 100644 --- a/public/react/src/modules/courses/coursesPublic/ShixunModal.js +++ b/public/react/src/modules/courses/coursesPublic/ShixunModal.js @@ -25,7 +25,7 @@ class ShixunModal extends Component{ hometypepvisible:true, }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url).then((result)=>{ if(result.status===200){ @@ -51,7 +51,7 @@ class ShixunModal extends Component{ hometypepvisible:loading }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url, { params: { diff --git a/public/react/src/modules/courses/exercise/ExerciseDisplay.js b/public/react/src/modules/courses/exercise/ExerciseDisplay.js index a0296476f..cbaf38c80 100644 --- a/public/react/src/modules/courses/exercise/ExerciseDisplay.js +++ b/public/react/src/modules/courses/exercise/ExerciseDisplay.js @@ -53,11 +53,15 @@ class ExerciseDisplay extends Component{ componentDidMount = () => { const Id = this.props.match.params.Id if (Id) { - const url = `/exercises/${Id}.json` + const url = `/${this.props.urlPath || 'exercises'}/${Id}.json` axios.get(url) .then((response) => { - if (response.data.status == 0) { - this.setState({...response.data}) + if (response.data.exercise) { + response.data.exercise.exercise_description = response.data.exercise.exercise_description || response.data.exercise.description + response.data.exercise.exercise_name = response.data.exercise.exercise_name || response.data.exercise.name + response.data.exercise.exercise_status = response.data.exercise.exercise_status == undefined ? 1 : response.data.exercise.exercise_status + this.setState({...response.data}) + this.props.detailFetchCallback && this.props.detailFetchCallback(response); } }) .catch(function (error) { diff --git a/public/react/src/modules/courses/exercise/ExerciseNew.js b/public/react/src/modules/courses/exercise/ExerciseNew.js index 017fff71e..80f837686 100644 --- a/public/react/src/modules/courses/exercise/ExerciseNew.js +++ b/public/react/src/modules/courses/exercise/ExerciseNew.js @@ -5,440 +5,63 @@ import { Slider, Button, Upload, Icon, Rate, Checkbox, message, Row, Col, Select, Modal, Tooltip } from 'antd'; -import { Q_TYPE_SINGLE, Q_TYPE_MULTI, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common' -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import axios from 'axios' // import './board.css' -import "../common/formCommon.css" +// import "../common/formCommon.css" // import { RouteHOC } from './common.js' -import CBreadcrumb from '../common/CBreadcrumb' -import {getUrl, ActionBtn} from 'educoder'; -import SingleEditor from './new/SingleEditor' -import SingleDisplay from './new/SingleDisplay' -import JudgeEditor from './new/JudgeEditor' -import JudgeDisplay from './new/JudgeDisplay' -import NullEditor from './new/NullEditor' -import NullDisplay from './new/NullDisplay' -import MainEditor from './new/MainEditor' -import MainDisplay from './new/MainDisplay' -import ShixunEditor from './new/ShixunEditor' -import ShixunDisplay from './new/ShixunDisplay' +// import { Q_TYPE_SINGLE, Q_TYPE_MULTI, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common' +// import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; +// import CBreadcrumb from '../common/CBreadcrumb' +import {getUrl, ActionBtn, CBreadcrumb} from 'educoder'; + +// import SingleEditor from './new/SingleEditor' +// import SingleDisplay from './new/SingleDisplay' +// import JudgeEditor from './new/JudgeEditor' +// import JudgeDisplay from './new/JudgeDisplay' +// import NullEditor from './new/NullEditor' +// import NullDisplay from './new/NullDisplay' +// import MainEditor from './new/MainEditor' +// import MainDisplay from './new/MainDisplay' +// import ShixunEditor from './new/ShixunEditor' +// import ShixunDisplay from './new/ShixunDisplay' -import ShixunChooseModal from '../coursesPublic/ShixunChooseModal' import update from 'immutability-helper' import './new/common.css' import '../css/Courses.css' + +import ExerciseNewCommon from './ExerciseNewCommon' const { TextArea } = Input; -const confirm = Modal.confirm; -const $ = window.$ -const { Option } = Select; -const TITLE_MAX_LENGTH = 60; + class ExerciceNew extends Component{ constructor(props){ super(props); this.state = { - exercise_questions: [], - exercise_name: '', - exercise_description: '', - exercise_types: {}, - editMode: !this.props.match.params.Id, - } - } - - // 已发布试卷编辑保存的确认弹框 - changeScore = (question_id,answerArray) =>{ - this.props.confirm({ - content:'修改了标准答案', - subContent:"是否重新计算学生答题的成绩?", - onOk:()=>{ - this.sureChangeScore(question_id,answerArray) - }, - onCancel:()=>{ - this.addSuccess(); - } - }) - } - - // 已发布试卷修改答案确认修改分数 - sureChangeScore = (question_id,answerArray) =>{ - let url=`/exercise_questions/${question_id}/update_scores.json` - axios.post((url),{ - standard_answers:answerArray - }).then((result)=>{ - if(result){ - this.props.showNotification(`${result.data.message}`); - this.addSuccess(); - } - }).catch((error)=>{ - console.log(error); - }) - } - - fetchExercise = () => { - const Id = this.props.match.params.Id - this.isEdit = !!Id - if (Id) { - const url = `/exercises/${Id}/edit.json` - axios.get(url) - .then((response) => { - if (response.data.status == 0) { - const { exercise, ...others } = response.data - this.setState({ - ...exercise, - ...others, - editMode: false - }) - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const courseId=this.props.match.params.coursesId; - - const newUrl = `/courses/${courseId}/exercises/new.json` - axios.get(newUrl) - .then((response) => { - if (response.data.status == 0) { - this.setState({ - ...response.data - }) - } - }) - .catch(function (error) { - console.log(error); - }); + } } componentDidMount = () => { - this.fetchExercise() - } - handleSubmit = (e) => { } - onSaveExercise = () => { - const { exercise_name, exercise_description } = this.state; - const exercise_id = this.props.match.params.Id - const courseId = this.props.match.params.coursesId - if (this.isEdit) { - const editUrl = `/exercises/${exercise_id}.json` - axios.put(editUrl, { - exercise_name, - exercise_description - }) - .then((response) => { - if (response.data.status == 0) { - this.setState({editMode: false}) - this.props.showNotification('试卷编辑成功') - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const url = `/courses/${courseId}/exercises.json` - axios.post(url, { - exercise_name, - exercise_description - }) - .then((response) => { - if (response.data.status == 0) { - this.setState({editMode: false}) - - this.props.showNotification('试卷新建成功') - const exercise_id = response.data.data.exercise_id; - this.isEdit = true; - - this.props.history.replace(`/courses/${courseId}/exercises/${exercise_id}/edit`); - - } - }) - .catch(function (error) { - console.log(error); - }); - } - } - exercise_name_change = (e) => { - this.setState({exercise_name: e.target.value}) - } - exercise_description_change = (e) => { - this.setState({exercise_description: e.target.value}) - } - // #问题的类型,0为单选题,1为多选题,2为判断题,3为填空题,4为主观题,5为实训题 - _checkIsEditing = () => { - if (this.editingId && $(this.editingId).length ) { - this.props.showNotification('请先保存或取消当前正在编辑的问题。') - $("html").animate({ scrollTop: $(this.editingId).offset().top - 100}) - return true - } - return false - } - onEditorCancel = () => { - this.editingId = null; - // 找到编辑或新建的item,新建就删掉item,编辑就isNew改为false - const { exercise_questions } = this.state - let index = -1; - for(let i = 0; i < exercise_questions.length; i++) { - if (exercise_questions[i].isNew == true) { - index = i; - break; - } - } - if (exercise_questions[index].question_id) { // 编辑 - this.setState( - (prevState) => ({ - exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: false}}}) - // update(prevState.exercise_questions, {$splice: [[index, 1]]}) - }) - ) - } else { // 新建 - this.setState( - (prevState) => ({ - exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]}) - }) - ) - } - } - addQuestion = (question_id_to_insert_after, type) => { - if (!this.isEdit) { - this.props.showNotification('请先输入试卷标题,并保存试卷') - return; - } - if (this._checkIsEditing()) { - return; - } - if (type == Q_TYPE_SHIXUN) { - this.addShixun(question_id_to_insert_after) - } else { - this.addEditingQuestion(type, question_id_to_insert_after) - } - } - chooseShixun = (array) => { - this.addEditingQuestion(Q_TYPE_SHIXUN, this.question_id_to_insert_after, { - shixun_id: array[0] - }) - } - chooseShixunSuccess = () => { - this.refs.shixunChooseModal.setVisible(false) - } - addShixun = (question_id_to_insert_after) => { - if (!this.isEdit) { - this.props.showNotification('请先输入试卷标题,并保存试卷') - return; - } - // TODO 弹框选择实训 - if (this._checkIsEditing()) { - return; - } - this.refs.shixunChooseModal.setVisible(true) - this.question_id_to_insert_after = question_id_to_insert_after; - return; - // 拉取实训items - this.addEditingQuestion(Q_TYPE_SHIXUN, question_id_to_insert_after, { - shixun_id: 50 - }) - } - editQestion = (index) => { - if (this._checkIsEditing()) { - return; - } - this.editingId = `#question_${index}` - - this.setState( - (prevState) => ({ - exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: true}}}) - }) - ) - } - onSort = (index, question_id, isUp) => { - if (this._checkIsEditing()) { - return; - } - const url = `/exercise_questions/${question_id}/up_down.json` - axios.post(url, { opr: isUp ? 'up' : 'down'}) - .then((response) => { - if (response.data.status == 0) { - // this.props.showNotification('移动成功') - this.fetchExercise() - } - }) - .catch(function (error) { - console.log(error); - }); - } - onSortDown = (index, question_id) => { - this.onSort(index, question_id, false) - } - onSortUp = (index, question_id) => { - this.onSort(index, question_id, true) - } - getInitScore = (question_type, question_id_to_insert_after) => { - /** - 1.每个题型的首个题目默认值规则如下: - 选择题:5分 01 - 判断题:2分 2 - 填空题:2分 3 - 简答题:10分 4 - 实训题:每个关卡5分 5 - */ - let init_question_score = 0; - if (question_type == 0 || question_type == 1) { - init_question_score = 5 - } else if (question_type == 2) { - init_question_score = 2 - } else if (question_type == 3) { - init_question_score = 2 - } else if (question_type == 4) { - init_question_score = 10 - } else if (question_type == 5) { - init_question_score = 5 - } - const _indexBefore = question_id_to_insert_after ? this.findIndexById(question_id_to_insert_after) : this.state.exercise_questions.length - 1 - for (let i = _indexBefore; i >= 0; i--) { - if(this.state.exercise_questions[i].question_type == question_type) { - init_question_score = this.state.exercise_questions[i].question_score - break; - } - } - return init_question_score; - } - addEditingQuestion = (question_type, question_id_to_insert_after, otherAttributes) => { - - let init_question_score = this.getInitScore(question_type, question_id_to_insert_after) - - let questionObj = { - question_type: question_type, // 需要这个通过类型判断 - init_question_score: init_question_score, - isNew: true, // 新建或编辑,用是否有id区分是新建还是编辑 - question_id_to_insert_after, - ...otherAttributes - } - const { exercise_questions } = this.state; - let new_exercise_questions = exercise_questions.slice(0) - let newIndex = new_exercise_questions.length; - - if (question_id_to_insert_after) { - const _indexBefore = this.findIndexById(question_id_to_insert_after) - new_exercise_questions.splice(_indexBefore + 1, 0, questionObj) - newIndex = _indexBefore + 1 - } else { - new_exercise_questions.push(questionObj) - } - this.editingId = `#question_${newIndex}` - this.setState({ exercise_questions: new_exercise_questions }, () => { - setTimeout(() => { - $(this.editingId).length && $("html").animate({ scrollTop: $(this.editingId).offset().top - 100}) - }, 500) - }) - } - findIndexById = (id) => { - const { exercise_questions } = this.state - for(let i = 0; i < exercise_questions.length; i++) { - if (exercise_questions[i].question_id == id) { - return i; - } - } - } - onQestionDelete = (question_id) => { - this.props.confirm({ - content: `确认要删除这个问题吗?`, - onOk: () => { - const url = `/exercise_questions/${question_id}.json` - axios.delete(url) - .then((response) => { - if (response.data.status == 0) { - this.props.showNotification('删除成功') - this.fetchExercise() - - // const { exercise_questions } = this.state - // const index = this.findIndexById(question_id) - - // this.setState( - // (prevState) => ({ - // exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]}) - // }) - // ) - } - }) - .catch(function (error) { - console.log(error); - }); - } - }) - } - addSuccess = () => { - this.editingId = null; - this.fetchExercise() - } - goToPreview = () => { - const exercise_id = this.props.match.params.Id - const courseId = this.props.match.params.coursesId - this.props.history.push(`/courses/${courseId}/exercises/${exercise_id}/student_exercise_list?tab=2`) + initData = (data) => { + this.setState({left_banner_id: data.left_banner_id}) } render() { - let { exercise_name, exercise_description, course_id, exercise_types, - exercise_questions, left_banner_id } = this.state; - // if (this.isEdit && !exercise_types) { - // return '' - // } - // const { getFieldDecorator } = this.props.form; - const { q_counts, q_scores, q_doubles, q_doubles_scores, q_judges, q_judges_scores, - q_mains, q_mains_scores, q_nulls, q_nulls_scores, q_shixuns, q_shixuns_scores, q_singles, q_singles_scores} = exercise_types; - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - // sm: { span: 8 }, - sm: { span: 24 }, - }, - wrapperCol: { - xs: { span: 24 }, - // sm: { span: 16 }, - sm: { span: 24 }, - }, - }; + let { left_banner_id } = this.state; + const { current_user } = this.props - const isAdmin = this.props.isAdmin() + const courseId=this.props.match.params.coursesId; - const exercise_id = this.props.match.params.Id const isEdit = this.isEdit - const commonHandler = { - onQestionDelete: this.onQestionDelete, - addSuccess: this.addSuccess, - addQuestion: this.addQuestion, - onEditorCancel: this.onEditorCancel, - changeScore:this.changeScore, - editQestion: this.editQestion, - onSortDown: this.onSortDown, - onSortUp: this.onSortUp, - displayCount: exercise_questions.length, - exercise_status: this.state.exercise_status, - exerciseIsPublish: this.state.exercise_status >= 2 - } + return(
- - +
{ current_user &&

- {!this.state.editMode && } - {this.state.editMode &&
-
- - {/* {getFieldDecorator('subject', { - rules: [{ - required: true, message: '请输入标题', - }, { - max: 20, message: '最大限制为20个字符', - }], - })( */} - - - {/* )} */} - - - - {/* {getFieldDecorator('select_board_id', { - // initialValue: '3779', - })( */} - -
- } - -
- ) - }) - } -
+
) } diff --git a/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js new file mode 100644 index 000000000..792c1b64f --- /dev/null +++ b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js @@ -0,0 +1,117 @@ +import React,{ Component } from "react"; +import {Checkbox,Radio} from "antd"; + + +import '../css/members.css' +import '../css/busyWork.css' +import './pollStyle.css' + + +const map={1:"单选题",2:"多选题",3:"主观题",4:"主观题"} +class PollDetailTabThirdInfo extends Component{ + constructor(props){ + super(props); + } + render(){ + let { pollDetail }=this.props; + return( +
+ { + pollDetail && pollDetail.poll.polls_description && +

{ pollDetail.poll.polls_description }

+ } +

+ { pollDetail && pollDetail.question_types.q_counts===0 ? "" : + + { + pollDetail && pollDetail.question_types.q_counts > 0 && + 合计{pollDetail.question_types.q_counts}题: + } + { + pollDetail && pollDetail.question_types.q_singles > 0 && + 单选题{pollDetail.question_types.q_singles}题 + } + { + pollDetail && pollDetail.question_types.q_doubles > 0 && + 多选题{pollDetail.question_types.q_doubles}题 + } + { + pollDetail && pollDetail.question_types.q_mains > 0 && + 主观题{pollDetail.question_types.q_mains}题 + } + + } +

+ + { + pollDetail && pollDetail.questions.map((item,key)=>{ + return( +
+

+ {item.question.question_number}、{map[item.question.question_type]} + { item.question.is_necessary==1 ? 必答:选答 } + { item.question.question_type == 2 && item.question.min_choices != undefined && item.question.min_choices != null && item.question.max_choices != undefined && item.question.max_choices != null ? + + { + item.question.min_choices == item.question.max_choices ? "可选"+item.question.max_choices+"项" : + "可选"+item.question.min_choices+"-"+item.question.max_choices+"项" + } + :"" + } +

+
  • {item.question.question_title}
  • + { + // 单选题 + item.question.question_type==1 && + + { + item.question.answers.map((index,k)=>{ + return( +
  • + + {index.answer_text} + { + index.answer_text=="其他" ?

    :"" + } + +
  • + ) + }) + } +
    + } + { + // 多选题 + item.question.question_type==2 && + + { + item.question.answers.map((index,k)=>{ + return( +
  • + + {index.answer_text} + { + index.answer_text=="其他" ?

    :"" + } +
  • + ) + }) + } +
    + } + { + // 主观题 + item.question.question_type == 3 && +
    + +
    + } +
    + ) + }) + } +
    + ) + } +} +export default PollDetailTabThirdInfo \ No newline at end of file diff --git a/public/react/src/modules/courses/poll/PollInfo.js b/public/react/src/modules/courses/poll/PollInfo.js index 2476e0bc3..bb019c4a4 100644 --- a/public/react/src/modules/courses/poll/PollInfo.js +++ b/public/react/src/modules/courses/poll/PollInfo.js @@ -19,7 +19,6 @@ class PollInfo extends Component{ super(props); this.state={ courseName:undefined, - userName:undefined, poll:undefined, question_answered:undefined, question_types:undefined, @@ -73,8 +72,7 @@ class PollInfo extends Component{ getInfo=()=>{ this.setState({ - courseName:this.props.current_user.course_name, - userName:this.props.current_user.username + courseName:this.props.current_user.course_name }) let pollId=this.props.match.params.pollId; let user_id=this.props.match.params.login; @@ -291,7 +289,7 @@ class PollInfo extends Component{ render(){ let coursesId=this.props.match.params.coursesId; - let{poll,question_answered,question_types,questions,courseName,userName, + let{poll,question_answered,question_types,questions,courseName, inputArray, modalsType, modalsTopval, diff --git a/public/react/src/modules/courses/poll/PollNewQuestbank.js b/public/react/src/modules/courses/poll/PollNewQuestbank.js new file mode 100644 index 000000000..5530f839a --- /dev/null +++ b/public/react/src/modules/courses/poll/PollNewQuestbank.js @@ -0,0 +1,4143 @@ +import React, {Component} from "react"; +import {Form, Input, Tooltip, Checkbox, Radio, Select, message, Modal, Button} from 'antd' +import {WordsBtn, ActionBtn,WordNumberTextarea} from 'educoder' + +import {Link} from 'react-router-dom' + +import '../css/members.css' +import "../common/formCommon.css" + +import './pollStyle.css' +import '../css/Courses.css' +import axios from 'axios' +import moment from "../new/CoursesNew"; +import Modals from "../../modals/Modals"; +import PollListItem from "./PollListItem"; +import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; + +const TextArea = Input.TextArea +const RadioGroup = Radio.Group +const CheckboxGroup = Checkbox.Group +const Option = Select.Option; +const maps = {1: "未发布", 2: "提交中", 3: "已截止"} +const confirm = Modal.confirm; + +class PollNewQuestbank extends Component { + // 问卷新建和编辑 + // + // * addonAfter 字数限制 + // * q_counts 题目总数 + // * mysingles 单选题数量 + // * mydoubles 多选题数量 + // * mymainsint 主观题数量 + // * adddom 添加编辑的数据 页面点击新增题目 + // * editentry 编辑条目 新增的题目点击到条目中 + //* questionnair 问卷是否存在 默认不存在 + // * + + constructor(props) { + super(props); + this.contentMdRef = React.createRef(); + this.state = { + visible: false, + poll_questions: [], + user_permission: "", + addonAfter: 0, + addonAftertwo: 0, + mysingles: 0, + mydoubles: 0, + mymainsint: 0, + adddom: [], + editentry: [], + questionnair: false, + polls_name: undefined, + polls_nametest: "", + polls_description: "", + polls_descriptiontest: "", + storagedesc: "", + storagedesctwo: "", + coursesId: "", + pollid: undefined, + polls_status: undefined, + q_countst: 0, + Newedit: true, + Insertposition: undefined, + Modalstype: false, + mysave: false, + readOnlys: "readOnly", + problemtopic: null, + problemtopicbool: false, + newoption: false, + cancellation: false, + bindingid: undefined, + Newdisplay: false, + first_category_url: "", + left_banner_id: "", + } + // console.log("试卷新建和编辑"); + // console.log(JSON.stringify(props)); + + } + + changeTopicName = (e) => { + // console.log("调用了changeTopicName"); + let num = parseInt(e.target.value.length); + if (num > 60) { + return; + } + this.setState({ + addonAfter: num < 0 ? 0 : num + }); + this.setState({ + polls_nametest: e.target.value + }) + } + + + changeTopicNametwo = (e) => { + // console.log("获取的值" + e.target.value); + let num = 100 - parseInt(e.target.value.length); + this.setState({ + addonAftertwo: num < 0 ? 0 : num + }) + this.setState({ + polls_descriptiontest: e.target.value + }) + } + + // 初始化数据 + componentDidMount = () => { + // console.log("componentDidMount 50") + if (this.props.isStudent() === true) { + + this.props.history.push("/403") + + return + } + // if (this.props.match.params.news !== undefined) { + // if (this.props.match.params.news === "new") { + // this.state.Newedit === true; + // this.setState({ + // Newedit: true, + // mysave: true, + // readOnlys: "", + // cancellation: true, + // }) + // } else { + + this.Initializatio_data(); + this.state.Newedit === false; + this.setState({ + Newedit: false, + mysave: false, + readOnlys: "readOnly", + }) + // } + // } + + console.log("问卷返回"); + console.log(this.props); + try { + if (this.props.current_user !== undefined) { + this.setState({ + first_category_url: this.props.current_user.first_category_url, + }); + console.log("======================="); + console.log(this.props.current_user.first_category_url); + } + } catch (e) { + console.log("12312312312") + console.log(e); + } + + }; + componentDidUpdate = (prevProps) => { + // console.log("componentDidUpdate"); + // console.log(prevProps); + // console.log(this.props); + if (prevProps.current_user != this.props.current_user) { + if (this.props.current_user !== undefined) { + // console.log(this.props.current_user.login); + // console.log(prevProps.current_user.login); + this.setState({ + first_category_url: this.props.current_user.first_category_url, + }) + } + } + } + + //获取权限 + // getPollInfo(){ + // // console.log(this.props.match); + // let pollId=this.props.match.params.pollId; + // let url=`/polls/${pollId}/common_header.json` + // axios.get(url).then((result)=>{ + // if(result.status==200){ + // this.setState({ + // pollDetail:result.data, + // user_permission:result.data.user_permission + // }) + // } + // }).catch((error)=>{ + // console.log(error); + // }) + // } + //初始化请求网络 + Initializatio_data = () => { + console.log("Initializatio_data 582") + //课堂id + let coursesId = this.props.match.params.coursesId; + //时间id + let pollid = this.props.match.params.workid; + console.log(pollid); + // let coursesId = 557; + if (pollid === undefined) { + // console.log("没有问卷新建问卷~~~") + // let coursesId=this.props.match.params.coursesId; + // // to={`/courses/${coursesId}/polls/new`} + // + // const urll = `/courses/${coursesId}/polls/new.json` + // axios.get(urll).then((result) => { + // if (result.status === 200) { + // console.log(urll) + // console.log("问卷新建成功") + // console.log(JSON.stringify(result)) + // // var path=`/courses/${coursesId}/polls/new`; + // // + // // this.props.history.push({ pathname: path, state: { } }); + // } + // }).catch((error) => { + // console.log(error) + // }) + + // const urlls = `/courses/${coursesId}/polls.json` + // axios.post(urlls,{ + // polls_name: "这是标题", + // polls_description:"这是标题须知" + // }).then((result)=>{ + // console.log("创建问卷++++++") + // console.log(result) + // try { + // if(result.data.status===0){ + // console.log("创建问卷") + // console.log(JSON.stringify(result.data)) + // } + // }catch (e) { + // + // } + // + // }) + //没有问卷 + this.setState({ + projects: [], + polls_name: "", + polls_description: "", + poll_questions: [], + question_types: [], + pollid: undefined, + mysingles: 0, + mydoubles: 0, + mymainsint: 0, + polls_nametest: "", + polls_descriptiontest: "", + coursesId: 0, + questionnair: false + }) + } else { + const url = `/exercise_banks/${pollid}.json`; + axios.get(url).then((result) => { + if (result) { + console.log("247"); + console.log(result); + + + } + + + if (result.data) { + if (result.data.poll) { + if (result.data.poll.polls_name) { + let num = parseInt(result.data.poll.polls_name.length); + this.setState({ + addonAfter: num < 0 ? 0 : num + }) + } + } + + } + + this.setState({ + projects: result.data, + pollid: pollid, + polls_status: result.data.poll.is_public === false ? 1 : 2, + polls_name: result.data.poll.name, + polls_description: result.data.poll.description, + poll_questions: result.data.questions, + question_types: result.data.question_types, + mysingles: result.data.question_types.q_singles, + mydoubles: result.data.question_types.q_doubles, + mymainsint: result.data.question_types.q_mains, + q_counts: result.data.question_types.q_counts, + polls_nametest: result.data.poll.name, + polls_descriptiontest: result.data.poll.description, + questionnair: true, + left_banner_id: result.data.left_banner_id + }) + + if (result.data.poll.name) { + if (result.data.poll.name.length > 0) { + this.setState({ + addonAfter: result.data.poll.name.length, + }) + } + } + try { + const crumbData={ + title:'编辑', + is_public:result && result.data && result.data.is_public, + crumbArray:[ + {to:`/banks/poll/${pollid}/${this.props.match.params.type}`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + }catch (e) { + + } + }).catch((error) => { + console.log(error) + }) + } + + } + + //重新获取数据 + thisinitializationdatanew = () => { + var pollidsy = null; + if (this.state.pollid !== undefined) { + pollidsy = this.state.pollid; + if (pollidsy === null || pollidsy === undefined) { + pollidsy = this.props.match.params.workid; + } + } + + if (pollidsy === null || pollidsy === undefined) { + return + } + + const url = `/exercise_banks/${pollidsy}.json`; + axios.get(url).then((result) => { + if (result !== undefined) { + this.setState({ + projects: result.data, + pollid: pollidsy, + polls_status: result.data.poll.is_public === false ? 1 : 2, + polls_name: result.data.poll.name, + polls_description: result.data.poll.description, + poll_questions: result.data.questions, + question_types: result.data.question_types, + mysingles: result.data.question_types.q_singles, + mydoubles: result.data.question_types.q_doubles, + mymainsint: result.data.question_types.q_mains, + q_counts: result.data.question_types.q_counts, + polls_nametest: result.data.poll.name, + polls_descriptiontest: result.data.poll.description, + questionnair: true, + left_banner_id: result.data.left_banner_id + }); + + + if (result.data.poll.name) { + if (result.data.poll.name.length > 0) { + this.setState({ + addonAfter: result.data.poll.name.length, + }) + } + } + } + + // console.log("有问卷~~~") + + + // } + }).catch((error) => { + console.log(error) + }) + } + //新建问卷 + newword = () => { + if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + this.props.showNotification(`请输入标题`); + return + } + let coursesId = this.props.match.params.coursesId; + const urlls = `/courses/${coursesId}/polls.json` + axios.post(urlls, { + polls_name: this.state.polls_nametest, + polls_description: this.state.polls_descriptiontest + }).then((result) => { + if (result.data.status === 0) { + this.state.Newedit === false; + // this.props.showNotification(`试卷创建成功`); + this.setState({ + pollid: result.data.data.id, + Newedit: false, + }) + this.props.history.push(`/courses/${this.props.match.params.coursesId}/polls/${result.data.data.id}/detail?tab=2`) + } + }) + } + //添加单选题目 + addmysingles = () => { + + if (this.state.newoption === true) { + this.setState({ + newoption: false + }) + } + this.setState({ + Newdisplay: true, + }) + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 1) { + Insertposition = i; + } + + } + this.addMytopic(1, this.state.pollid, Insertposition, false, 0); + this.scrollToAnchor("publishtimeid"); + } + + //添加多选题目 + addmydoubles = () => { + // console.log("addmymainsint 70") + if (this.state.newoption === true) { + this.setState({ + newoption: false + }) + } + this.setState({ + Newdisplay: true, + }) + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 2) { + Insertposition = i; + } + + + } + this.addMytopic(2, this.state.pollid, Insertposition, false, 0); + this.scrollToAnchor("publishtimeid"); + + // } + } + + //添加主观题目 + addmymainsint = () => { + this.setState({ + Newdisplay: true, + }) + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 3) { + Insertposition = i; + } + + + } + + this.addMytopic(3, this.state.pollid, Insertposition, false, 0); + this.scrollToAnchor("publishtimeid"); + } + + //编辑方法 + adddomedit = (object) => { + // console.log("adddomedit 76"); + if (this.state.q_countst > 0) { + this.props.showNotification(`不能同时编辑两题`); + + return; + } + var anserbool = false; + this.setState({ + q_countst: 1, + bindingid: object.question.id + }) + // window.scrollTo(0, this.refs.targetElement.offsetTops) + let {adddom} = this.state; + // var arr =new Object(objects); + // console.log(arr) + // adddom.push(arr); + var question = {}; + var Insertposition = this.state.poll_questions.length; + if (object.question.question_type === 1) { + var answers = []; + var questiontwo = {}; + ///////////////////////////daying + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + anserbool = true; + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + + + } + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 1) { + Insertposition = i; + } + } + } else if (object.question.question_type === 2) { + //插入多选题 + var answers = []; + var questiontwo = {}; + + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + anserbool = true; + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 2) { + Insertposition = i; + } + } + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 3) { + Insertposition = i; + } + } + } + this.setState({ + adddom: adddom, + newoption: anserbool, + Insertposition: Insertposition + }) + + } + + //新增添加题目 有new + addMytopic = (index, pollid, Insertposition, Whether, id) => { + //Whether 是否插入 + // console.log("addMytopic 90") + // console.log(index) + // console.log(pollid) + // console.log(Insertposition) + // console.log(Whether) + console.log("addMytopic"); + console.log(id); + if (this.state.q_countst > 0) { + this.props.showNotification(`不能同时编辑两题`); + + return; + } + this.state.Insertposition = Insertposition; + var Whethername = null; + if (Whether === true) { + Whethername = id; + } + this.setState({ + Insertposition: Insertposition, + q_countst: 1, + }) + // window.scrollTo(0, this.refs.targetElement.offsetTop) + var arrr = this.state.adddom; + let newarrr = [...arrr]; + + var arr = this.state.poll_questions; + let newarr = [...arr]; + + if (newarr.length > 0) { + if (index === 1) { + // 插入单选题 + // console.log(this.state.poll_questions[newarr.length - 1].question.id); + var question = {} + var questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, + "is_necessary": 1, + "question_number": 1, + "question_title": "", + "question_type": 1, + "new": "new", + "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 2) { + //插入多选题 + var question = {} + var questiontwo = { + "id": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, + "is_necessary": 1, + "question_number": 2, + "question_title": "", + "question_type": 2, + "max_choices": 0, + "min_choices": 0, + "new": "new", + "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 3) { + //插入主观题 + // console.log(this.state.poll_questions[newarr.length - 1].question.id); + var question = {} + var questiontwo = { + "id": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, + "is_necessary": 1, + "question_number": 3, + "question_title": "", + "question_type": 3, + "new": "new", + "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, + "answers": [] + }; + question = {"question": questiontwo}; + newarrr.push(question); + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } + } else { + /////上面视图全部删除后 要加载的 + if (index === 1) { + // 插入单选题 + var ids; + try { + ids = this.state.poll_questions[newarr.length - 1].question.id; + } catch (e) { + ids = 1; + } + var questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": Whether === true ? id : ids, + "is_necessary": 1, + "question_number": 1, + "question_title": "", + "question_type": 1, + "new": "new", + "newid": Whether === true ? id : ids + 1, + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 2) { + //插入多选题 + var ids; + try { + ids = this.state.poll_questions[newarr.length - 1].question.id; + } catch (e) { + ids = 1; + } + var questiontwo = { + "id": Whether === true ? id : ids, + "is_necessary": 1, + "question_number": 2, + "question_title": "", + "question_type": 2, + "max_choices": 0, + "min_choices": 0, + "new": "new", + "newid": Whether === true ? id : ids + 1, + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 3) { + //插入主观题 + var ids; + try { + ids = this.state.poll_questions[newarr.length - 1].question.id; + } catch (e) { + ids = 1; + } + var questiontwo = { + "id": Whether === true ? id : ids, + "is_necessary": 1, + "question_number": 3, + "question_title": "", + "question_type": 3, + "new": "new", + "newid": Whether === true ? id : ids + 1, + "answers": [] + }; + question = {"question": questiontwo}; + newarrr.push(question); + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + } + } + } + + //删除指定条目 + Deleteadddom = (indexo, bool) => { + // console.log("deleteadddom 259") + + var arr = this.state.adddom; + let newarr = [...arr]; + newarr.splice(indexo, 1); + if (bool === true) { + this.setState({ + adddom: newarr, + q_countst: 0, + problemtopic: null, + problemtopicbool: false, + bindingid: undefined, + Newdisplay: false, + newoption: false, + }) + + } else { + this.setState({ + adddom: newarr, + q_countst: 0, + problemtopic: null, + problemtopicbool: false, + Newdisplay: false, + newoption: false, + }) + } + } + //保存并继续 + //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) + Deleteadddomtwo = (indexo, object, bool) => { + var thiss = this; + if (bool === true) { + this.setState({ + q_countst: 1, + bindingid: undefined, + Newdisplay: false, + + }) + } else { + this.setState({ + q_countst: 1, + Newdisplay: false, + }) + } + if (object.question.question_type === 3) { + this.HandleInputTopics(this.contentMdRef.current.getValue().trim(), indexo); + + } + var poll_questionslength = this.state.poll_questions.length; + // console.log("deleteadddomtwo|||||||||||||||||||||||||||||||||||||||||\\"); + // console.log(indexo); + // console.log(object); + // console.log(object.question.question_type); + let arr = this.state.adddom; + let arrpoll = this.state.poll_questions; + let newarr = [...arr]; + let newarrpoll = [...arrpoll]; + + //选项内容不能为空 + let max = 0; + let maxtie = newarr[indexo].question.answers.length; + for (var k = 0; k < newarr[indexo].question.answers.length; k++) { + try { + if (newarr[indexo].question.answers[k].answer_text != undefined) { + if (newarr[indexo].question.answers[k].answer_text === "") { + max = max + 1; + } + } + } catch (e) { + // console.log("PollNew281") + console.log(e) + } + } + if (object.question.question_type !== 3) { + if (newarr[indexo].question.question_title === "") { + this.props.showNotification(`题目不能为空`); + + return + } + } + if (max > 0) { + if (object.question.question_type === 1) { + this.props.showNotification(`选项内容不能为空`); + + return + } else if (object.question.question_type === 2) { + this.props.showNotification(`选项内容不能为空`); + + return + } + + } + + if (object.question.question_type === 1) { + if (maxtie < 2) { + this.props.showNotification(`选项不能少于2个!`); + return + } + } else if (object.question.question_type === 2) { + if (maxtie < 3) { + this.props.showNotification(`选项不能少于3个!`); + return + } + } + + + if (object.question.question_type === 2) { + if (object.question.max_choices > 0) { + // if (object.question.min_choices < 2) { + // this.props.showNotification(`可选最小不能少于2个`); + // + // return; + // + // } + } + + } + if (object.question.new === "new") { + // 根据数组里面的new 来确定是否是新增还是 修改 + //添加道数组上 + //不能共用数组 所以自己写个新数组 然后push 上面卷子中 + var question = {}; + if (object.question.question_type === 1) { + + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + // 这个是装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + + + } + + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + var insindex = null; + // if (poll_questionslength !== thiss.state.Insertposition) { + // insindex = newarrpoll[thiss.state.Insertposition].question.id; + // } + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length); + //插入多选题 + // if (object.question.max_choices > arrc.length) { + // // console.log("选择题的最大可选项不能大于选项数") + // this.props.showNotification(`选择题的最大可选项不能大于选项数`); + // + // return; + // } + // if (object.question.min_choices === 0) { + // // console.log("选择题的最大可选项不能小于2项目") + // this.props.showNotification(`选择题的最大可选项不能小于2项目`); + // + // return; + // + // } + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 3) { + // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); + //插入主观题 + var answers = []; + var questiontwo = {}; + var answerstwos = []; + var answerstwoss = []; + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwoss.push(datatwo); + } + } + } + + answers = answerstwoss.concat(answerstwos); + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": this.contentMdRef.current.getValue().trim(), + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + // var insindex = null; + // if (poll_questionslength !== thiss.state.Insertposition) { + // insindex = newarrpoll[thiss.state.Insertposition].question.id; + // } + //主观题不需要可选选项 + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } + //////////////////////////////////////////////////////////////////////////////////////////////////// 上面是新增 + } else { + ///////////////////////////////////////////////////////////////////////////////////////////////////修改点了编辑 + // console.log("点了编辑") + var uuk = -1 + //这个地方判断 点了编辑上面题目又把他删除了 保存的时候就只能是插入新增了 + for (var uk = 0; uk < newarrpoll.length; uk++) { + if (object.question.id === newarrpoll[uk].question.id) { + uuk = uk; + } + } + + + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + //这个装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + + + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 1, arrc, null, 0, 0,0); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("他原来的删除掉了") + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); + newarrpoll.push(question); + } + newarr[indexo].question.new = "new" + // console.log(newarrpoll) + } else if (object.question.question_type === 2) { + //插入多选题 + + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification('可选的最大限制不能小于最小限制!'); + + return; + } + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //插入多选题 + // if (object.question.max_choices > arrc.length) { + // // console.log("选择题的最大可选项不能大于答案数") + // this.props.showNotification('选择题的最大可选项不能大于选项数!'); + // + // return; + // } + // if (object.question.min_choices === 0) { + // // console.log("选择题的最大可选项不能小于2项目") + // this.props.showNotification('选择题的最大可选项不能小于2项目!'); + // + // return; + // + // } + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("删除") + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length); + newarrpoll.push(question); + } + // console.log(newarrpoll) + newarr[indexo].question.new = "new" + } else if (object.question.question_type === 3) { + // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); + + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": this.contentMdRef.current.getValue().trim(), + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 3, null, null, 0, 0,0); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("删除") + this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); + newarrpoll.push(question); + } + // console.log(newarrpoll) + newarr[indexo].question.new = "new" + } + + } + + + //添加到上面列表中 + //改变题目总数 + if (object.question.question_type === 1) { + //单选题 + this.state.mysingles = this.state.mysingles + 1; + } else if (object.question.question_type === 2) { + //多选题 + this.state.mydoubles = this.state.mydoubles + 1; + } else if (object.question.question_type === 3) { + //主观题 + this.state.mymainsint = this.state.mymainsint + 1; + + } + this.setState({ + // poll_questions: newarrpoll, + adddom: newarr, + problemtopic: null, + problemtopicbool: false, + // mysingles: this.state.mysingles, + // mydoubles: this.state.mydoubles, + // mymainsint: this.state.mymainsint + }) + + } + + + //保存 后期可以考虑和保存并继续 合并 + //保存,即完成新建并退出本题编辑 + // indexo 第几个数组 + //object 单个数组数据 + Deleteadddomthree = (indexo, object, bool) => { + if (bool === true) { + this.setState({ + bindingid: undefined, + }) + } + this.setState({ + Newdisplay: false, + }); + if (object.question.question_type === 3) { + this.HandleInputTopics(this.contentMdRef.current.getValue().trim(), indexo); + + } + // console.log("deleteadddom 349") + var thiss = this; + let arr = this.state.adddom; + let arrpoll = this.state.poll_questions; + let newarr = [...arr]; + let newarrpoll = [...arrpoll]; + var poll_questionslength = this.state.poll_questions.length; //获取单前问题最大长度 + //选项内容不能为空 + let max = 0; + let maxtie = newarr[indexo].question.answers.length; + //判断选项值是否不为空 + for (var k = 0; k < newarr[indexo].question.answers.length; k++) { + try { + if (newarr[indexo].question.answers[k].answer_text != undefined) { + if (newarr[indexo].question.answers[k].answer_text === "") { + max = max + 1; + } + } + } catch (e) { + // console.log("PollNew281") + // console.log(e) + } + } + if (object.question.question_type !== 3) { + if (newarr[indexo].question.question_title === "") { + this.props.showNotification('题目不能为空!'); + return + } + } + if (max > 0) { + if (object.question.question_type === 1) { + this.props.showNotification('选项内容不能为空!'); + return + } else if (object.question.question_type === 2) { + this.props.showNotification('选项内容不能为空!'); + return + } + + } + if (object.question.question_type === 1) { + if (maxtie < 2) { + this.props.showNotification('选项不能少于2个!'); + return + } + } else if (object.question.question_type === 2) { + if (maxtie < 3) { + this.props.showNotification('选项不能少于3个!'); + return + } + } + + + if (object.question.question_type === 2) { + if (object.question.max_choices > 0) { + // if (object.question.min_choices < 2) { + // this.props.showNotification(`可选最小不能少于2个`); + // return; + // } + } + } + if (object.question.new === "new") { + ///////////////////////////////////////////////////////////////////新增模式 + // 根据数组里面的new 来确定是否是新增还是 修改 + //添加道数组上 + //不能共用数组 所以自己写个新数组 然后push 上面卷子中 + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + // 这个是装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题' + // var id; + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1 + // } catch (e) { + // id = 1; + // } + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //获取指定id 号 用来插入,如果不是就是在最后添加 + + //执行新增操作 + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length); + //插入多选题 + // if (object.question.max_choices > arrc.length) { + + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 3) { + // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); + + //插入主观题 + var answers = []; + var questiontwo = {}; + var answerstwos = []; + var answerstwoss = []; + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwoss.push(datatwo); + } + } + } + answers = answerstwoss.concat(answerstwos); + + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": this.contentMdRef.current.getValue().trim(), + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //主观题不需要可选选项 + + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } + ///////////////////////////////////////////////////////////////////新增模式 + } else { + //////////////////////////////////////////////////////////////////////////////修改模式 + //修改 + var uuk = -1 + for (var uk = 0; uk < newarrpoll.length; uk++) { + if (object.question.id === newarrpoll[uk].question.id) { + uuk = uk; + // console.log("删除了数据=-09876543234567890-111111111111") + } + } + + + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + //这个装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 1, arrc, null, 0, 0,0); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("删除") + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); + newarrpoll.push(question); + } + // console.log(newarrpoll) + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + + + if(object.question.max_choices){ + if(object.question.max_choices>0){ + if(object.question.min_choices){ + if(object.question.min_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + + if(object.question.min_choices){ + if(object.question.min_choices>0){ + if(object.question.max_choices){ + if(object.question.max_choices===0){ + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + } + }else { + this.props.showNotification(`最小和最大限制须同时为数值或者“--"`); + return; + + } + } + + } + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //插入多选题 + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("删除") + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length); + newarrpoll.push(question); + } + // console.log(newarrpoll) + + } else if (object.question.question_type === 3) { + // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); + + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": this.contentMdRef.current.getValue().trim(), + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 3, null, null, 0, 0,0); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("删除") + this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); + newarrpoll.push(question); + } + // console.log(newarrpoll) + + } + + } + + + //添加到上面列表中 + //改变题目总数 + if (object.question.question_type === 1) { + //单选题 + this.state.mysingles = this.state.mysingles + 1; + } else if (object.question.question_type === 2) { + //多选题 + this.state.mydoubles = this.state.mydoubles + 1; + } else if (object.question.question_type === 3) { + //主观题 + this.state.mymainsint = this.state.mymainsint + 1; + + } + + //这里更新数据 + if (this.state.q_countst == 1) { + this.setState({ + q_countst: 0, + }) + } + this.Deleteadddom(indexo); + // console.log(indexo) + } + + + ////新增到服务器中 + createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id,length) => { + var thiss = this; + var poll_id = this.state.pollid; + var urlly = `/poll_bank_questions.json`; + var max_choicess = null; + var min_choicess = null; + try { + if (max_choices === 0 && min_choices === 0) { + max_choicess = null; + min_choicess = null; + } else { + max_choicess = max_choices; + min_choicess = min_choices; + } + }catch (e) { + max_choicess = null; + min_choicess = null; + } + var datay={}; + datay={ + exercise_bank_id: poll_id, + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + question_answers: option, + question_other_answer: null, + insert_id: insert_id + } + try { + if(number===2){ + datay={ + exercise_bank_id: poll_id, + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, + min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, + question_answers: option, + question_other_answer: null, + insert_id: insert_id + } + } + }catch (e) { + + } + + axios.post(urlly,datay).then((result) => { + // try { + if (result !== undefined) { + if (result.data.status === 0) { + this.props.showNotification(`已完成`); + thiss.thisinitializationdatanew(); + // console.log("确认创建问题") + // console.log(result) + // try { + // if (result.data.status === 0) { + // console.log("确认创建问题") + // console.log(JSON.stringify(result.data)) + // } + // } catch (e) { + // + // } + } + } + // } catch (e) { + // + // } + + }) + + + } + ///编辑修改到服务器当中 + edittotheserver = (object, number, option, other, max_choices, min_choices,length) => { + // console.log("调用了edittotheserver") + var url = `/poll_bank_questions/${object.question.id}.json` + var thiss = this; + var max_choicess = null; + var min_choicess = null; + try { + if (max_choices === 0 && min_choices === 0) { + max_choicess = null; + min_choicess = null; + } else { + max_choicess = max_choices; + min_choicess = min_choices; + } + }catch (e) { + max_choicess = null; + min_choicess = null; + } + var datay={}; + datay={ + // debug: true, + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + question_answers: option, + question_other_answer: null, + }; + try { + if(number===2){ + datay={ + // debug: true, + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, + min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, + question_answers: option, + question_other_answer: null, + }; + } + }catch (e) { + + } + + axios.put(url,datay).then((result) => { + try { + if (result.data.status === 0) { + this.props.showNotification(`编辑题目成功`); + thiss.thisinitializationdatanew(); + } + } catch (e) { + // console.log("调用了edittotheserver") + console.log(e) + } + }) + } + + //删除到服务器当中 + eletetoserver = (pollid, newarr, type, index) => { + // console.log("调用了eletetoserver") + var id = pollid; + var url = `/exercise_bank_questions/${id}.json` + let {mysingles, mydoubles, mymainsint} = this.state + var thiss = this; + + axios + .delete(url, {}) + .then(function (response) { + // console.log(response) + if (response === undefined) { + return; + } + if (response.data.message === "删除成功") { + thiss.props.showNotification(`删除成功`); + + newarr.splice(index, 1); + if (type === 1) { + mysingles = mysingles - 1; + } else if (type === 2) { + mydoubles = mydoubles - 1; + + } else if (type === 3) { + mymainsint = mymainsint - 1; + + } + // thiss.setState({ + // poll_questions: newarr, + // mysingles: mysingles, + // mydoubles: mydoubles, + // mymainsint: mymainsint + // }); + thiss.thisinitializationdatanew(); + } + }) + } + + //上下移到服务器中 + Upanddownmovementof = (bool, poll_question_id) => { + // console.log("调用了Upanddownmovementofr") + // console.log(poll_question_id) + var thiss = this; + if (bool === true) { + var url = `/exercise_bank_questions/${poll_question_id}/up_down.json`; + axios.put(url, { + opr: "up", + }).then((result) => { + try { + if (result.data.status === 0) { + this.props.showNotification(`上移成功`); + thiss.thisinitializationdatanew(); + } + // console.log(JSON.stringify(result)) + } catch (e) { + // console.log("上移题目成功 错误") + console.log(e) + } + + }) + } else { + var url = `/exercise_bank_questions/${poll_question_id}/up_down.json`; + axios.put(url, { + opr: "down", + }).then((result) => { + try { + if (result.data.status === 0) { + // message.success("下移题目成功", 1) + this.props.showNotification(`下移成功`); + thiss.thisinitializationdatanew(); + } + // console.log(JSON.stringify(result)) + } catch (e) { + // console.log("下移题目成功 错误") + console.log(e) + } + }) + } + + } + + //删除编辑新增条目 + //id 条目的唯一id + //i 为要删除的子条目 + Deleteentrys = (id, i, stirngname) => { + // console.log(id) + // console.log(stirngname); + var arrtwoy = this.state.adddom; + let newarrtwoy = [...arrtwoy]; + for (var k = 0; k < newarrtwoy.length; k++) { + if (newarrtwoy[k] != undefined) { + if (newarrtwoy[k].question.id === id) { + for (var c = 0; c < newarrtwoy[k].question.answers.length; c++) { + if (c === i) { + // console.log("删除了") + // console.log(c) + newarrtwoy[k].question.answers.splice(c, 1); + } + } + } + } + } + if (stirngname === true) { + // console.log(stirngname); + this.setState({ + newoption: false, + adddom: newarrtwoy, + + }) + } else { + // console.log(stirngname); + this.setState({ + adddom: newarrtwoy, + }); + } + + + } + + + // 新增选项 + Ewoption = (id, object) => { + // console.log("ewoption 440") + // console.log("是否是新建题目还是编辑") + // console.log(object.question.new) + + + let arrtwo = this.state.adddom; + let newarrtwo = [...arrtwo]; + + + for (var k = 0; k < newarrtwo.length; k++) { + // console.log(arrtwo[k].question.id); + if (newarrtwo[k] != undefined) { + if (newarrtwo[k].question.id === id) { + var data = { + "answer_id": newarrtwo[k].question.answers.length + 1, + "answer_position": newarrtwo[k].question.answers.length + 1, + "answer_text": "" + }; + //向头部添加元素 + // newarrtwo[k].question.answers.unshift(data); + //如果有其他这一项就删除掉 + if (newarrtwo[k].question.answers.length > 0) { + for (var o = 0; o < newarrtwo[k].question.answers.length; o++) { + if (newarrtwo[k].question.answers[o].answer_text != undefined) { + if (newarrtwo[k].question.answers[o].answer_text === "其他") { + newarrtwo[k].question.answers.splice(o, 0, data); + this.setState({ + adddom: newarrtwo + }) + return + } else { + if (o === newarrtwo[k].question.answers.length - 1) { + newarrtwo[k].question.answers.push(data); + this.setState({ + adddom: newarrtwo + }) + return + } + } + } + } + } else { + newarrtwo[k].question.answers.push(data); + this.setState({ + adddom: newarrtwo + }) + } + + } + } + } + + } + + + swapArray = (arr, index1, index2) => { + arr[index1] = arr.splice(index2, 1, arr[index1])[0]; + return arr; + } + + //新增其他选项 + Addanotheroption = (id) => { + // console.log("addanotheroption 457") + let arrtwo = this.state.adddom; + let newarrtwo = [...arrtwo]; + // console.log(newarrtwo) + for (var k = 0; k < newarrtwo.length; k++) { + if (newarrtwo[k] != undefined) { + if (newarrtwo[k].question.id === id) { + var data = { + "answer_id": newarrtwo[k].question.answers.length + 1, + "answer_position": newarrtwo[k].question.answers.length + 1, + "answer_text": "其他" + }; + newarrtwo[k].question.answers.push(data); + } + } + } + this.setState({ + adddom: newarrtwo, + newoption: true, + }) + } + + + //点击向上排序按钮事件 + handleClickBySortUp = (index, object) => { + // console.log("handleClickBySortUp 521") + let arr = this.state.poll_questions; + let newarr = [...arr]; + // console.log(newarr) + if (index != 0) { + this.Upanddownmovementof(true, object.question.id); + let temp = newarr[index - 1]; + newarr[index - 1] = newarr[index]; + newarr[index] = temp; + this.setState({ + poll_questions: newarr, + }); + } + } + + //点击向下排序按钮事件 + handleClickBySortDown = (index, object) => { + // console.log("handleClickBySortDown 536") + let arr = this.state.poll_questions; + let newarr = [...arr]; + // + if (index != newarr.length - 1) { + this.Upanddownmovementof(false, object.question.id); + let temp = newarr[index + 1]; + newarr[index + 1] = newarr[index]; + newarr[index] = temp; + this.setState({ + poll_questions: newarr, + }); + } else { + // console.log("2222index==arr.length"); + // console.log(this.state.poll_questions); + } + } + + //点击删除按钮事件 + handleClickByDelete = (type, index, object) => { + // console.log("handleClickByDelete 556") + // console.log("object.question.id") + // console.log(object.question.id) + let arr = this.state.poll_questions; + let newarr = [...arr]; + this.eletetoserver(object.question.id, newarr, type, index) + + } + + // 数字输入监听 + //e为获取组件对象 + //i外层数组 + //k为内层数组 + HandleInputChanges = (e, i, k) => { + console.log("handleInputChanges" + " " + e); + console.log("handleInputChanges" + " " + i); + console.log("handleInputChanges" + " " + k); + // console.log("handleInputChanges 612") + + let value = e.target.value;//取到input的数据 + // console.log("handleInputChanges value is :" + value); + // console.log(k); + let arr = this.state.adddom; + let newarr = [...arr]; + + newarr[i].question.answers[k].answer_text = value + this.setState({ + adddom: newarr + }) + + } + + //标题输入监听 + HandleInputTopic = (e, i) => { + // console.log("handleInputTopic 633") + + let value = e.target.value;//取到input的数据 + // console.log("handleInputTopic value is :" + value); + // console.log(i); + let arr = this.state.adddom; + let newarr = [...arr]; + newarr[i].question.question_title = value + this.setState({ + adddom: newarr + }) + } + + HandleInputTopics = (value, i) => { + console.log("handleInputTopic 633") + console.log(value); + //取到input的数据 + // console.log("handleInputTopic value is :" + value); + // console.log(i); + let arr = this.state.adddom; + let newarr = [...arr]; + newarr[i].question.question_title = value + this.setState({ + adddom: newarr + }) + } +//最小值 + HandleGradationGroupChangee = (value, index, max, length) => { + // console.log("最小值"); + // console.log(value); + // console.log(index); + // console.log(max); + // console.log(length); + + // debugger + var minbool = false; + var maxbool = false; + let arr = this.state.adddom; + // if (parseInt(value) === 0 || parseInt(value) === "0" || parseInt(value) === null || parseInt(value) === undefined || parseInt(value) < 1) { + // minbool = true; + // } + // if (max === 0 || max === "0" || max === null || max === undefined) { + // maxbool = true; + // } + // + // if (minbool === true && maxbool === true) { + // for (var i = 0; i < arr.length; i++) { + // if (index === i) { + // arr[i].question.min_choices = parseInt(value); + // } + // } + // this.setState({ + // adddom: arr + // }) + // } else { + for (var i = 0; i < arr.length; i++) { + if (index === i) { + arr[i].question.min_choices = parseInt(value); + // arr[i].question.max_choices = length; + break; + } + } + this.setState({ + adddom: arr + }) + // } + + } + + //最大值 + HandleGradationGroupChangeee = (value, index,minchoices,length) => { + // console.log("2112"); + // console.log(value); + // console.log(minchoices); + // console.log("最大值"); + // console.log(value); + // console.log(index); + // console.log(minchoices); + // console.log(length); + let arr = this.state.adddom; + for (var i = 0; i < arr.length; i++) { + if (index === i) { + // if(parseInt(value)===0&&parseInt(minchoices)===0){ + // arr[i].question.min_choices= parseInt(0); + // arr[i].question.max_choices = parseInt(0); + // }else if(parseInt(minchoices)===0){ + // arr[i].question.min_choices= parseInt(2); + // arr[i].question.max_choices = parseInt(value); + // } + // else if(parseInt(value)===0&&parseInt(minchoices)>0){ + // arr[i].question.min_choices= parseInt(minchoices); + // arr[i].question.max_choices = parseInt(value); + // } + // else { + // arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); + arr[i].question.max_choices = parseInt(value); + // } + } + } + // console.log(2119); + // console.log(arr); + this.setState({ + adddom: arr + }) + // console.log(this.state.adddom); + } + + //提交题目//没有就创建新的题库,新建问newz题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 + submitQuestionnaire = () => { + if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + this.props.showNotification("请输入标题"); + return + } + if(this.state.poll_questions&&this.state.poll_questions.length===0){ + this.props.showNotification("至少创建1个题目"); + return; + } + + this.props.history.push(`/banks/poll/${this.props.match.params.workid}`); + // this.props.initPublic(undefined); + // console.log("调用了submitQuestionnaire") + // if (this.state.Newedit === true) { + // + // this.newword(); + // + // } else { + // if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + // this.props.showNotification("请输入标题"); + // return + // } + // + // if (this.state.polls_descriptiontest.length > 100) { + // + // } + // var pollid; + // if (this.state.pollid === undefined) { + // pollid = this.props.match.params.workid; + // } else { + // pollid = this.state.pollid; + // } + // + // // if(mews ==="new"){ + // if (this.state.poll_questions && this.state.poll_questions.length === 0) { + // this.props.showNotification("至少创建1个题目"); + // return; + // } + // // } + // + // var url = `/polls/${pollid}.json`; + // axios.put(url, { + // polls_name: this.state.polls_nametest, + // polls_description: this.state.polls_descriptiontest + // }).then((result) => { + // try { + // // console.log(JSON.stringify(result)) + // if (result.data.status === 0) { + // // console.log("更新题目成功") + // // this.props.showNotification("保存成功"); + // + // } + // } catch (e) { + // + // } + // }) + // } + } + + cancelmodel = () => { + + this.setState({ + Modalstype: false, + Modalstopval: "", + ModalsBottomval: "", + }) + + } + savedelete = (question_type, index, item) => { + // console.log("savedelete"); + this.handleClickByDelete(question_type, index, item); + this.setState({ + Modalstype: false, + Modalstopval: "", + ModalsBottomval: "", + }) + } + // 问题的类型,1单选题,2为多选题,3为主观题 + showDeleteConfirm = (question_type, index, item) => { + this.setState({ + Modalstype: true, + Modalstopval: "是否确认删除?", + ModalsBottomval: "", + ModalCancel: this.cancelmodel, + ModalSave: () => this.savedelete(question_type, index, item), + }) + + } + //必答选项 + OnCheckAllChange = (e, index) => { + // console.log("onCheckAllChange"); + // console.log(e.target.checked); + // console.log(e.target.value); + let arr = this.state.adddom; + for (var i = 0; i < arr.length; i++) { + if (index === i) { + if (e.target.checked === true) { + arr[i].question.is_necessary = 1; + + } else { + arr[i].question.is_necessary = 0; + } + } + } + this.setState({ + adddom: arr + }) + } + + //重新编辑标题和须知 + adddomeditit = () => { + if (this.state.mysave === true) { + this.setState({ + mysave: false, + readOnlys: "readOnly", + storagedesc: this.state.polls_nametest, + storagedesctwo: this.state.polls_descriptiontest, + }) + } else if (this.state.mysave === false) { + this.setState({ + mysave: true, + readOnlys: "", + storagedesc: this.state.polls_nametest, + storagedesctwo: this.state.polls_descriptiontest, + }) + } + } + //取消保存 + onSaveExercisetwo = () => { + if (this.state.mysave === true) { + this.setState({ + mysave: false, + Newedit: false, + readOnlys: "readOnly", + polls_nametest: this.state.storagedesc, + polls_descriptiontest: this.state.storagedesctwo, + }) + } else { + this.setState({ + mysave: false, + Newedit: false, + readOnlys: "readOnly", + polls_nametest: this.state.storagedesc, + polls_descriptiontest: this.state.storagedesctwo, + }) + } + } + // 创建问卷 + onSaveExercise = () => { + // if (this.state.Newedit === true) { + // + // if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + // this.props.showNotification(`请输入标题`); + // return + // } + // let coursesId = this.props.match.params.coursesId; + // const urlls = `/courses/${coursesId}/polls.json` + // axios.post(urlls, { + // polls_name: this.state.polls_nametest, + // polls_description: this.state.polls_descriptiontest + // }).then((result) => { + // if (result === undefined) { + // return; + // } + // this.state.Newedit === false; + // this.props.showNotification(`问卷创建成功!`); + // this.setState({ + // pollid: result.data.data.id, + // Newedit: false, + // mysave: false, + // readOnlys: "readOnly", + // cancellation: false, + // }); + // // var currenturl = window.location.href; + // // var newUrl = (currenturl.split("?"))[0]; + // // var newr=(newUrl.slice("new"))[0]; + // // console.log(newUrl); + // // console.log("2301"); + // // console.log(newr); + // // window.history.pushState('','',newUrl+'?tab='+e); + // // window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; + // + // }) + // } else { + if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + this.props.showNotification("请输入标题"); + return + } + + var pollid; + if (this.state.pollid === undefined) { + pollid = this.props.match.params.workid; + } else { + pollid = this.state.pollid; + } + + + var url = `/exercise_banks/${pollid}.json`; + axios.put(url, { + exercise_name: this.state.polls_nametest, + exercise_description: this.state.polls_descriptiontest + }).then((result) => { + if (result !== undefined) { + this.props.showNotification(`问卷更新成功!`); + this.setState({ + mysave: false, + readOnlys: "readOnly", + }) + } + + }) + // } + + } + gotohome = () => { + // const { current_user} = this.props + if (this.state.first_category_url) { + window.location.href = this.state.first_category_url; + } else { + this.props.history.goBack(); + } + + // + // let courseId=this.props.match.params.coursesId; + // if(courseId===undefined){ + // this.props.history.push("/courses"); + // }else{ + // this.props.history.push(this.props.current_user.first_category_url); + // } + } + //试图 + toWorkDetail = () => { + // console.log(this.props); + // console.log("toWorkDetail"); + this.props.history.push(`/banks/poll/${this.props.match.params.workid}/${this.props.match.params.type}`); + // this.props.initPublic(undefined); + }; + //跳转道描点的地方 + scrollToAnchor = (anchorName) => { + if (anchorName) { + // 找到锚点 + let anchorElement = document.getElementById(anchorName); + // 如果对应id的锚点存在,就跳转到锚点 + if(anchorElement) { anchorElement.scrollIntoView(); } + } + } + + + render() { + let { + addonAfter, + user_permission, + polls_status, + Modalstype, + mysave, + readOnlys, + newoption, + cancellation, + left_banner_id, + addonAftertwo + } = this.state + //获取老师权限 + // console.log("[`${maps[polls_status && polls_status]}`]]"); + // console.log(polls_status); + // console.log([[`${maps[polls_status && polls_status]}`]] + ""); + + // const {getFieldDecorator} = this.props.form; + const formItemLayout = { + labelCol: { + xs: {span: 24}, + // sm: { span: 8 }, + sm: {span: 24}, + }, + wrapperCol: { + xs: {span: 24}, + // sm: { span: 16 }, + sm: {span: 24}, + }, + }; + + const radioStyle = { + display: 'block', + height: '30px', + lineHeight: '30px', + }; + + // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) + var displaymysave = (mysave === true) ? "" : "display:none;"; + return ( +
    + {/*提示*/} + {Modalstype && Modalstype === true ? : ""} +
    + {/*

    */} + {/* this.gotohome()}>{this.props.coursedata.name}*/} + {/* >*/} + {/*{*/} + {/* this.props.match.params.news === "new"?*/} + {/* 问卷*/} + {/* :*/} + {/*问卷*/} + {/*}*/} + + {/*>*/} + {/*{this.props.match.params.news === undefined ? "新建" : this.props.match.params.news === "new" ? "新建" : "编辑"}*/} + {/* 编辑*/} + + {/*

    */} + {/*
    */} + {/*

    {this.props.match.params.news === undefined ? "新建问卷" : this.props.match.params.news === "new" ? "新建问卷" : "编辑问卷"}

    */} + {/*

    编辑

    */} + {/*{*/} + {/* this.props.match.params.news === "new" ?*/} + {/* 返回*/} + {/* :*/} + {/**/} + {/*}*/} + {/*
    */} + + {/**/} + { + this.state.mysave === false ? +
    + +
    + +
    + : "" + } + { + this.state.mysave === true ? +
    +
    + + +
    +
    *问卷标题 +
    + { + // this.props.match.params.news === undefined ? "" : this.props.match.params.news === "new" ? + // ( + this.state.mysave === false ? + + : "" + // ) + // :"" + } + +
    + {/*suffix={String(addonAfter)}*/} + + + +
    +
    + + +
    问卷须知
    + + + {/**/} + { + this.state.Newedit === true || this.state.mysave === true ? +
    + + {cancellation === false ? + + : ""} + +
    + : "" + } + +
    + +
    : "" + } + + +

    + + + { + this.state.mysingles + this.state.mydoubles + this.state.mymainsint === 0 ? "" : +

    + + {this.state.mysingles === 0 ? "" : 单选题{this.state.mysingles === undefined ? "" : this.state.mysingles} 题} + + {this.state.mydoubles === 0 ? "" : + 多选题{this.state.mydoubles === undefined ? "" : this.state.mydoubles}题} + {this.state.mymainsint === 0 ? "" : + + 主观题{this.state.mymainsint === undefined ? "" : this.state.mymainsint}题 + + } + + + 合计 {this.state.q_counts === undefined ? "" : this.state.q_counts} +
    + + } + +

    + + {polls_status === undefined || polls_status === 1 ? +
    +
    + this.addmysingles()}>单选题 + this.addmydoubles()}>多选题 + this.addmymainsint()}>主观题 +
    +
    + :
    } + +
    + + {/*自动生成修改好的获取到的*/} + {/**************************************************************************/} + {this.state.poll_questions === undefined ? "" : this.state.poll_questions.map((item, index) => { + console.log('打印this.state.poll_questions'); + console.log(this.state.poll_questions); + console.log(this.state.adddom); + let resultDom; + resultDom =
    +

    + {index + 1}、 + {item.question.question_type === 1 ? "单选题" : item.question.question_type === 2 ? "多选题" : "主观题"} + {item.question.is_necessary === 1 ? "(必答)" : item.question.question_type === 2 ? "(选答)" : "(选答)"} + { + item.question.question_type === 2? + {(item.question.min_choices === undefined && item.question.max_choices === undefined ? "不限制" : item.question.min_choices === null && item.question.max_choices === null ? "不限制" : item.question.min_choices === 0 && item.question.max_choices === 0 ? "": item.question.min_choices === "null" && item.question.max_choices === "null" ? "不限制" : item.question.min_choices === item.question.max_choices && item.question.max_choices === item.question.min_choices ? "可选"+(item.question.max_choices)+"项" : "可选" +(item.question.min_choices===undefined||item.question.min_choices===null||item.question.min_choices===""||item.question.min_choices==="null"?2:item.question.min_choices) + "-" + (item.question.max_choices===undefined||item.question.max_choices===null||item.question.max_choices===""||item.question.max_choices==="null"?item.question.answers.length:item.question.max_choices) + "项")} + : "" + } + + { + polls_status === undefined || polls_status === 1 ? + + this.showDeleteConfirm(item.question.question_type, index, item)}> + {index === 0 ? "" : + this.handleClickBySortUp(index, item)}>} + {index === this.state.poll_questions.length - 1 ? "" : + this.handleClickBySortDown(index, item)}>} + this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id)}> + this.adddomedit(item)}> + : this.adddomedit(item)}> + } + +

    +

    {item.question.question_title}

    + {/*
    {item.question.question_title}
    */} + {item.question.question_type === 1 ? +
    + + {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { + return ( +
    + + {items.answer_text} + +
    + ) + })} +
    + {/*单选题*/} + + +
    + : item.question.question_type === 2 ? +
    + + {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { + return ( +
    + + {items.answer_text} +
    + ) + })} +
    + {/*多选题*/} +
    + + : item.question.question_type === 3 ? + // 主观题 + (
    + +
    ) : (
    )} +
    + + return ( +
    + {/*这里是编辑和新增的地方*/} + { + this.state.bindingid && this.state.bindingid === item.question.id ? + (this.state.Newdisplay === false ? +
    +
    + {this.state.adddom === undefined ? "" : this.state.adddom === undefined ? "" : this.state.adddom.length === 0 ? "" : item.question.id === this.state.adddom[0].question.id && this.state.adddom.map((itemo, indexo) => { + let arrid = itemo.question.id; + let resultDomtwo; + resultDomtwo = +
    + {itemo&&itemo.question&&itemo.question.question_number}、 + {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} + this.OnCheckAllChange(e, indexo)} + className="lineh-40" + style={{"marginLeft": "20px"}}>必答 + + + { + itemo.question.question_type === 3 ? + + : + + + } + {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { + return ( +
    + {itemt.answer_text === undefined ? ( +
    ) : itemt.answer_text === "其他" ? ( +

    + 其它 + + + + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + itemo.question.question_type === 1 ? ( + indext > 1 ? + + { + itemo.question.question_type === 2 ? "" : + this.Deleteentrys(arrid, indext, true)}> + } + + + + : "") + : "" : ""} + +

    ) : (

    + 选项 + + + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + indext > 1 ? + + this.Deleteentrys(arrid, indext, false)}> + { + itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? + + this.Ewoption(itemo.question.id, itemo)}> + : itemo.question.answers.length - 1 === indext ? + this.Ewoption(itemo.question.id, itemo)}> + : + } + + : indext === 1 && itemo.question.answers.length === 2 || indext === 1 && itemo.question.answers.length === 3 ? + this.Ewoption(itemo.question.id, itemo)}> : "" + : ""} +

    )} +
    + ) + })} + +
    + {itemo.question.question_type === 1 ? ( +
    + {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} +
    + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + "" + : ""} + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + + (this.state.newoption === false ? + this.Addanotheroption(itemo.question.id)}>添加[其它]选项 + : "") + : ""} + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 + +
    +
    + + + ) + + + : itemo.question.question_type === 2 ? ( + //////////////////////////////////////////// 可选 +
    +
    +
    + 可选 +
    + {/*可选最小1*/} + + + ~ + {/*可选最大1*/} + + + (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 + +
    + +
    +
    +
    + ) + + : (
    ) + + } +
    +
    + {itemo.question.question_type === 2 ? + // ( + // this.state.polls_status === undefined || this.state.polls_status === 1 ? + //
    + // + // {/*
    this.Ewoption(itemo.question.id, itemo)}>新增选项*/} + // + // {/* {*/} + // {/* this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : ""*/} + // {/* }*/} + // + // {/*
    */} + // + // + // + // this.Deleteadddom(indexo,true)}>取消 + // this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + // this.Deleteadddomthree(indexo, itemo,true)}>保存并退出 + // + //
    + // + // + // : + //
    + // + // this.Deleteadddom(indexo,true)}>取消 + // this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + // this.Deleteadddomthree(indexo, itemo,true)}> 保存并退出 + // + //
    + // ) + "" + : itemo.question.question_type === 3 ? +
    + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 + +
    + : + ""} + + +
    +
    + + + return ( +
    + {resultDomtwo} +
    + ) + })} +
    +
    : "") + : +
    + {resultDom} + {this.state.Newdisplay === false ? + +
    + {this.state.adddom === undefined ? "" : this.state.adddom === undefined ? "" : this.state.adddom.length === 0 ? "" : item.question.id === this.state.adddom[0].question.id && this.state.adddom.map((itemo, indexo) => { + let arrid = itemo.question.id; + let resultDomtwo; + resultDomtwo = +
    + {itemo&&itemo.question&&itemo.question.question_number}、 + + {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} + this.OnCheckAllChange(e, indexo)} + className="lineh-40" + style={{"marginLeft": "20px"}}>必答 + + { + itemo.question.question_type === 3 ? + + : + + + } + {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { + console.log("chishiyong1"); + console.log(itemo.question.answers[itemo.question.answers.length - 1]); + return ( +
    + {itemt.answer_text === undefined ? ( +
    ) : itemt.answer_text === "其他" ? ( +

    + 其它 + + + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + indext > 1 ? + + { + itemo.question.question_type === 2 ? "" : + this.Deleteentrys(arrid, indext, true)}> + } + + {/* {*/} + {/* itemo.question.answers.length-1=== indext?*/} + {/* this.Ewoption(itemo.question.id, itemo)}>*/} + {/*: */} + {/* }*/} + + : "" + : ""} +

    ) : (

    + 选项 + + + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + indext > 1 ? + + this.Deleteentrys(arrid, indext, false)}> + { + itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? + this.Ewoption(itemo.question.id, itemo)}> + : itemo.question.answers.length - 1 === indext ? + this.Ewoption(itemo.question.id, itemo)}> + : + + } + + : indext === 1 && itemo.question.answers.length === 2 || indext === 1 && itemo.question.answers.length === 3 ? + this.Ewoption(itemo.question.id, itemo)}> : "" + : ""} +

    )} +
    + ) + })} + +
    + {itemo.question.question_type === 1 ? ( +
    + {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} +
    + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + "" + : ""} + {this.state.polls_status === undefined || this.state.polls_status === 1 ? + + (this.state.newoption === false ? + this.Addanotheroption(itemo.question.id)}>添加[其它]选项 + : "") + : ""} + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 + +
    +
    + + + ) + + + : itemo.question.question_type === 2 ? ( + //////////////////////////////////////////// 可选 +
    +
    +
    + 可选 +
    + {/*可选最小2*/} + + + ~ + {/*可选最大2*/} + + + (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)} + >保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 + +
    + +
    +
    +
    + ) + + : (
    ) + + } +
    +
    + {itemo.question.question_type === 2 ? + // ( + // this.state.polls_status === undefined || this.state.polls_status === 1 ? + //
    + // + //
    this.Ewoption(itemo.question.id, itemo)}>新增选项 + // + // { + // this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : "" + // } + // + //
    + // + // + // + // this.Deleteadddom(indexo,true)}>取消 + // this.Deleteadddomtwo(indexo, itemo,true)} + // >保存并继续 + // this.Deleteadddomthree(indexo, itemo,true)}>保存并退出 + // + //
    + // + // + // : + //
    + // + // this.Deleteadddom(indexo,true)}>取消 + // this.Deleteadddomtwo(indexo, itemo,true)} + // >保存并继续 + // this.Deleteadddomthree(indexo, itemo,true)}> 保存并退出 + // + //
    + // ) + "" + + : itemo.question.question_type === 3 ? +
    + + this.Deleteadddom(indexo, true)}>取消 + this.Deleteadddomtwo(indexo, itemo, true)} + >保存并继续 + this.Deleteadddomthree(indexo, itemo, true)}> 保存并退出 + +
    + : + ""} + + +
    +
    + + + return ( +
    + {resultDomtwo} +
    + ) + })} +
    : ""} +
    + } +
    + + ) + })} + + + {/*新建单选多选2*/} +
    + { + this.state.Newdisplay === true ? +
    + {this.state.adddom === undefined ? "": this.state.adddom.map((itemo, indexo) => { + // console.log('打印this.state.adddom') + // console.log(this.state.adddom); + let arrid = itemo.question.id; + let resultDomtwo; + resultDomtwo = +
    + {itemo&&itemo.question&&itemo.question.question_number}、 + {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} + this.OnCheckAllChange(e, indexo)} + className="lineh-40" + style={{"marginLeft": "20px"}}>必答 + + { + itemo.question.question_type === 3 ? + + : + + } + + + {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { + console.log("ceshiyong2"); + console.log(itemo.question.answers.length - 1); + return ( +
    + {itemt.answer_text === undefined ? ( +
    ) : itemt.answer_text === "其他" ? ( +

    + 其它 + + + {polls_status === undefined || polls_status === 1 ? + indext > 1 ? + + { + itemo.question.question_type === 2 ? "" + : + this.Deleteentrys(arrid, indext, true)}> + } + + + + + : "" + : ""} +

    ) : (

    + 选项 + + + {polls_status === undefined || polls_status === 1 ? + (indext > 1 ? + + this.Deleteentrys(arrid, indext, false)}> + { + itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? + this.Ewoption(itemo.question.id, itemo)}> + : + itemo.question.answers.length - 1 === indext ? + this.Ewoption(itemo.question.id, itemo)}> + : + + + } + + : indext === 1 && itemo.question.answers.length === 2 || indext === 1 && itemo.question.answers.length === 3 ? + this.Ewoption(itemo.question.id, itemo)}> : "") + : ""} +

    )} +
    + ) + })} + +
    + {itemo.question.question_type === 1 ? ( +
    + {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} +
    + {polls_status === undefined || polls_status === 1 ? + "" + : ""} + {polls_status === undefined || polls_status === 1 ? + + (newoption === false ? + this.Addanotheroption(itemo.question.id)}>添加[其它]选项 + : "") + : ""} + + this.Deleteadddom(indexo)}>取消 + this.Deleteadddomtwo(indexo, itemo)} + > 保存并继续 + this.Deleteadddomthree(indexo, itemo)}>保存并退出 + +
    +
    + + + ) + + + : itemo.question.question_type === 2 ? ( + //////////////////////////////////////////// 可选 +
    +
    +
    + 可选 +
    + {/*可选最小3*/} + + + ~ + {/*可选最大3*/} + + + (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) + + this.Deleteadddom(indexo)}>取消 + this.Deleteadddomtwo(indexo, itemo)} + >保存并继续 + this.Deleteadddomthree(indexo, itemo)}> 保存并退出 + +
    + +
    +
    +
    + ) + + : (
    ) + + } +
    +
    + {itemo.question.question_type === 2 ? + // ( + // polls_status === undefined || polls_status === 1 ? + //
    + // + //
    this.Ewoption(itemo.question.id, itemo)}>新增选项 + // + // { + // newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : "" + // } + // + //
    + // + // + // + // this.Deleteadddom(indexo)}>取消 + // this.Deleteadddomtwo(indexo, itemo)} + // >保存并继续 + // this.Deleteadddomthree(indexo, itemo)}> 保存并退出 + // + //
    + // + // + // : + //
    + // + // this.Deleteadddom(indexo)}>取消 + // this.Deleteadddomtwo(indexo, itemo)} + // > 保存并继续 + // this.Deleteadddomthree(indexo, itemo)}>保存并退出 + // + //
    + // ) + "" + : itemo.question.question_type === 3 ? +
    + + this.Deleteadddom(indexo)}>取消 + this.Deleteadddomtwo(indexo, itemo)} + >保存并继续 + this.Deleteadddomthree(indexo, itemo)}>保存并退出 + +
    + : + ""} + + +
    +
    + + + return ( +
    + {resultDomtwo} +
    + ) + })} +
    + : + "" + } + + +
    +
    + + {/**/} +
    +
    +
    + ) + } + +} + +// RouteHOC() +export default PollNewQuestbank +{/*
    */ +} +{/* {*/ +} +{/* this.props.match.params.news === "new" ?*/ +} +{/* this.state.Newedit === false ?*/ +} +{/*
    */ +} +{/*
    */ +} + +{/*
    */ +} +{/* this.addmysingles()}>单选题*/ +} +{/* this.addmydoubles()}>多选题*/ +} +{/* this.addmymainsint()}>主观题*/ +} +{/*
    */ +} +{/*
    */ +} +{/* : ""*/ +} +{/* :*/ +} +{/*
    */ +} +{/*
    */ +} +{/*
    */ +} +{/* this.addmysingles()}>单选题*/ +} +{/* this.addmydoubles()}>多选题*/ +} +{/* this.addmymainsint()}>主观题*/ +} +{/*
    */ +} +{/*
    */ +} +{/* }*/ +} +{/*
    */ +} +{/*{*/ +} +{/* this.props.match.params.news === "new" ?*/ +} +{/* (this.state.Newedit === false ?*/ +} +{/* */ +} +{/*
  • */ +} +{/* this.props.history.goBack()}>取消*/ +} +{/* this.submitQuestionnaire(this.props.match.params.news)}>提交*/ +} +{/*
  • */ +} + + +{/*
    */ +} + +{/* : "")*/ +} +{/* :*/ +} +{/* */ +} +{/*}*/ +} \ No newline at end of file diff --git a/public/react/src/modules/courses/poll/pollStyle.css b/public/react/src/modules/courses/poll/pollStyle.css index a486101cd..19f1b35cd 100644 --- a/public/react/src/modules/courses/poll/pollStyle.css +++ b/public/react/src/modules/courses/poll/pollStyle.css @@ -17,7 +17,22 @@ min-height: 40px; min-line-height: 40px; } - +.ml61{ + margin-left: 61px; +} +.w64{ + width: 64px; +} +.w55{ + width: 55px!important; +} +.max1010{ + width: 1010px !important; + max-width: 1010px !important; +} +.yw18{ + min-width: 18px; +} /* 选答 */ .chooseAnswer{ display: inline-block; @@ -185,7 +200,7 @@ width: 100%; } .answerList li:hover{ - background: #F8F8F8; + background: #F0F8FF; } textarea:read-only{ background: #f3f3f3; diff --git a/public/react/src/modules/courses/questionbank/Generaljobanswer.js b/public/react/src/modules/courses/questionbank/Generaljobanswer.js index 3bfc6cd36..5dcbd254e 100644 --- a/public/react/src/modules/courses/questionbank/Generaljobanswer.js +++ b/public/react/src/modules/courses/questionbank/Generaljobanswer.js @@ -1,5 +1,5 @@ import React, {Component} from "react"; -import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder'; +import { WordsBtn,on, off, trigger,MarkdownToHtml,getImageUrl} from 'educoder'; import { Button, Checkbox, @@ -12,6 +12,8 @@ import { } from "antd"; import GroupPackage from '../groupjobbank/GroupPackage' import './questionbank.css'; +import AttachmentsList from '../../../common/components/attachment/AttachmentList'; +import NoneData from '../../courses/coursesPublic/NoneData' class Generaljobanswer extends Component { @@ -28,7 +30,7 @@ class Generaljobanswer extends Component { console.log("componentDidMount"); // let query = this.props.location.pathname; // const type = query.split('/'); - // this.setState({ + // this.setState({n // shixuntypes:type[3] // }) // this.props.triggerRef(this); @@ -55,18 +57,37 @@ class Generaljobanswer extends Component { render() { - + let{datas}=this.props return (
    + { + datas&&(datas.reference_answer===null? + + :datas.reference_answer==="null"? + + : + datas.reference_answer===""? + + : + + + //
    + ) + } + {/*
    */} +
    + {datas.attachments === undefined ? "" : + } +
    + + {/*{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {*/} + {/* return (*/} + {/* */} + {/* )*/} + {/*})}*/} -
    -
    diff --git a/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js b/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js index 29453a7b5..63b447dec 100644 --- a/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js +++ b/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js @@ -1,20 +1,26 @@ import React, {Component} from "react"; -import {Link, NavLink} from 'react-router-dom'; -import {WordsBtn, ActionBtn} from 'educoder'; +import {BrowserRouter as Router,Route,Switch,Link, NavLin} from 'react-router-dom'; +import {WordsBtn, ActionBtn,getImageUrl} from 'educoder'; import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form } from "antd"; import axios from 'axios'; -import { - notification -} from "antd"; -import CoursesListType from '../coursesPublic/CoursesListType'; -import Generaljobdetails from './Generaljobdetails'; -import Generaljobanswer from './Generaljobanswer'; +import BanksMenu from '../../user/usersInfo/banks/banksMenu' +import Loadable from 'react-loadable'; +import Loading from '../../../Loading'; import '../css/members.css'; import "../common/formCommon.css"; import '../css/Courses.css'; import '../css/busyWork.css'; import '../poll/pollStyle.css'; - +// 问卷内容 +const Generaljobdetails = Loadable({ + loader: () => import('./Generaljobdetails'), + loading: Loading, +}) +// 试卷详情 +const Generaljobanswer = Loadable({ + loader: () => import('./Generaljobanswer'), + loading: Loading, +}); class Generaljobbankdetails extends Component { //普通作业内容详情 constructor(props) { @@ -25,50 +31,24 @@ class Generaljobbankdetails extends Component { workid:1, isSpin:false, datas:[], + visible:false, + banksMenu:undefined } - } - //切换tab - ChangeTab = (e) => { - // console.log(e); - this.setState({ - tab: e - }) - try { - var currenturl = window.location.href; - var newUrl = (currenturl.split("?"))[0]; - window.history.pushState('','',newUrl+'?tab='+e); - }catch (e) { - console.log(e); - console.log("44"); - } - - } - - componentDidMount() { - // console.log("父组件加载框"); - const query = this.props.location.search; - const type = query.split('?tab='); - // let sum = [] - // sum.push(type[1]) - // console.log("componentDidMountcomponentDidMount"); - // console.log(type); - this.setState({ - tab: type[1], - }); + this.getonedata(); + } - console.log("Generaljobbankdetails"); - console.log(this.props); + getonedata=()=>{ if( this.props.match.params.workid){ this.setState({ workid: this.props.match.params.workid, }) } this.getdata(this.props.match.params.workid); - } + }; //获取数据的地方 getdata=(workid)=>{ var workids= workid; @@ -86,8 +66,35 @@ class Generaljobbankdetails extends Component { if(response){ if(response.data){ this.setState({ - datas:response.data.informs, + datas:response.data, }) + try { + const crumbData={ + title:response && response.data && response.data.name, + is_public:response && response.data && response.data.is_public, + crumbArray:[ + {content:'详情'} + ] + }; + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/normal/${workids}/${this.props.match.params.type}/details`,content:'内容详情'}, + {to:`/banks/normal/${workids}/${this.props.match.params.type}/answer`,content:'参考答案'} + ], + category:'normal',//毕设选题 + tos:`/banks/normal/${workids}/edit/${this.props.match.params.type}`, + id:workids, + is_public:response && response.data && response.data.is_public, + type:this.props.match.params.type, + } + this.setState({ + banksMenu:menuData + }) + this.props.initPublic(crumbData); + }catch (e) { + + } }else { this.setState({ datas:[], @@ -111,63 +118,49 @@ class Generaljobbankdetails extends Component { isSpin:false, }) }); - } - - - bindRef = ref => { this.child = ref } -///////////////教师截止 + }; + // initPublic = (crumbData,menuData) =>{ + // this.setState({ + // banksMenu:menuData + // }) + // this.props.initPublic(crumbData); + // } render() { - let {tab} = this.state; - - const isAdmin = this.props.isAdmin(); - // console.log(119) + let {tab,datas,visible} = this.state; + let{ + banksMenu + }=this.state return ( -
    - - -
    - -
    -

    - 题库 - > - 详情 -

    -
    -
    -

    - MySQL数据库编程开发实训(基础篇) -

    - -
    - - - - {parseInt(tab) === 0 ? :""} - {parseInt(tab) === 1 ? :""} - -
    -
    + + { + banksMenu && + + } + + { + return () + } + }> + { + return () + } + }> + + + ) } } export default Generaljobbankdetails; - diff --git a/public/react/src/modules/courses/questionbank/Generaljobdetails.js b/public/react/src/modules/courses/questionbank/Generaljobdetails.js index 9de444123..a2209b4f9 100644 --- a/public/react/src/modules/courses/questionbank/Generaljobdetails.js +++ b/public/react/src/modules/courses/questionbank/Generaljobdetails.js @@ -1,5 +1,6 @@ + import React, {Component} from "react"; -import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder'; +import { WordsBtn,on, off, trigger,markdownToHTML, MarkdownToHtml ,getImageUrl} from 'educoder'; import { Button, Checkbox, @@ -12,15 +13,15 @@ import { } from "antd"; import GroupPackage from '../groupjobbank/GroupPackage' import './questionbank.css'; - - +import AttachmentsList from "../../../common/components/attachment/AttachmentList"; +import NoneData from '../../courses/coursesPublic/NoneData' +//内容详情 class Generaljobdetails extends Component { constructor(props) { super(props); this.state = { - } } @@ -56,21 +57,27 @@ class Generaljobdetails extends Component { render() { - + let{datas}=this.props; return (
    - -
    - - + { + datas&&(datas.description===null? + + :datas.description==="null"? + + :datas&&datas.description===""? + : + + //
    + ) + } +
    + {datas.attachments === undefined ? "" : + } +
    -
    diff --git a/public/react/src/modules/courses/questionbank/questionbank.css b/public/react/src/modules/courses/questionbank/questionbank.css index 43dcfa9c6..97d49f7b4 100644 --- a/public/react/src/modules/courses/questionbank/questionbank.css +++ b/public/react/src/modules/courses/questionbank/questionbank.css @@ -23,4 +23,8 @@ .ysltextcolor99999{ color: #999999; font-size: 16px; +} +.mt16px{ + margin-top: 16px; + padding-bottom: 30px; } \ No newline at end of file diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index bd90db42f..bee373bd9 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -862,19 +862,19 @@ class Trainingjobsetting extends Component { var exams = parseFloat(Proportion.toFixed(1)); var intk = srorelength*exams; intkk=oushution - intk; - console.log("奇数"); - console.log(srorelength);//3 - console.log(oushution);//79 - console.log(exams);//26.3 - console.log(intk);//78.9 - console.log(intkk); + // console.log("奇数"); + // console.log(srorelength);//3 + // console.log(oushution);//79 + // console.log(exams);//26.3 + // console.log(intk);//78.9 + // console.log(intkk); }else { // 偶数 var examsy =parseFloat(Proportion.toFixed(1)); intkks=oushution - (examsy*srorelength); - console.log("偶数"); - console.log(oushution); - console.log((examsy*srorelength)); + // console.log("偶数"); + // console.log(oushution); + // console.log((examsy*srorelength)); } var mact=0; diff --git a/public/react/src/modules/modals/SendTopics.js b/public/react/src/modules/modals/SendTopics.js new file mode 100644 index 000000000..98bec53a6 --- /dev/null +++ b/public/react/src/modules/modals/SendTopics.js @@ -0,0 +1,165 @@ +import React,{ Component } from "react"; +import { Modal,Radio,Input,Tooltip,Checkbox,Select, Row,Col } from "antd"; +import axios from 'axios'; +const { Search } = Input; +class SendTopics extends Component{ + constructor(props){ + super(props); + this.state={ + courses:[], + search:null, + Radiolist:undefined, + showcheck:false + } + } + + + + + componentDidMount(){ + let{search}=this.state; + this.onupdatalist(search) + } + + onupdatalist=(search)=>{ + let url="/question_banks/my_courses.json"; + axios.get(url,{params:{ + search + } + }).then((result)=>{ + this.setState({ + courses:result.data.courses + }) + }).catch((error)=>{ + console.log(error); + }) + } + + onSearchChange=(e)=>{ + this.setState({ + search:e.target.value + }) + // this.onupdatalist(e.target.value) + } + + onSearch=(search)=>{ + this.onupdatalist(search) + } + + + onChange=(e)=>{ + this.setState({ + Radiolist:e.target.value + }) + } + + submitInfo=()=>{ + let{Radiolist}=this.state; + let url=`/question_banks/send_to_course.json`; + let object_id=this.props.checkBoxValues; + let object_type=this.props.category; + if(Radiolist===undefined){ + this.setState({ + showcheck:true + }) + }else{ + axios.post(url,{ + object_id: object_id, + object_type:object_type, + course_id:Radiolist + } + ).then((result)=>{ + if(result.data.status===0){ + this.props.showNotification(result.data.message) + this.props.topicscancelmodel() + this.props.updataslist() + }else{ + this.props.showNotification(result.data.message) + } + }).catch((error)=>{ + console.log(error) + }) + } + + } + render(){ + let{courses,Radiolist,showcheck}= this.state; + + const radioStyle = { + display: 'block', + height: '30px', + lineHeight: '30px', + }; + + return( +
    + + + + +
    +
    + 温馨提示:选择的题将会发送到指定课堂 +
    +
    + +
    +
    + + { + courses && courses.map((item,key)=>{ + return( +
    + + {item.course_name} + +
    + ) + }) + } +
    + +
    + {showcheck===true?
    请先选择课堂
    :""} + +
    +
    +
    + ) + } + +} +export default SendTopics; \ No newline at end of file diff --git a/public/react/src/modules/moop_cases/CaseNew.js b/public/react/src/modules/moop_cases/CaseNew.js index ae9ef4f6f..2fbe993bc 100644 --- a/public/react/src/modules/moop_cases/CaseNew.js +++ b/public/react/src/modules/moop_cases/CaseNew.js @@ -49,7 +49,7 @@ class CaseNew extends Component{ onAttachmentRemove = (file, stateName) => { if(!file.percent || file.percent == 100){ this.props.confirm({ - content: '是否确认删除?', + content: '是否确认删除?', onOk: () => { this.deleteAttachment(file, stateName) }, @@ -244,7 +244,10 @@ class CaseNew extends Component{ // 选择标签 changeType=(type)=>{ + // console.log(this.state.casesTags); + // debugger let tags = []; + if(this.state.casesTags.indexOf(type) > -1){ tags = this.state.casesTags.filter(item => item != type); }else{ diff --git a/public/react/src/modules/projectPackages/packageconcnet.css b/public/react/src/modules/projectPackages/packageconcnet.css index f7ee4cc06..22dd4ebc8 100644 --- a/public/react/src/modules/projectPackages/packageconcnet.css +++ b/public/react/src/modules/projectPackages/packageconcnet.css @@ -295,11 +295,11 @@ .topsj{ position: absolute; - top: -6px; + top: -3px; } .bottomsj{ position: absolute; - bottom: -6px; + bottom: -5px; } .touchSelect .ant-spin-dot-spin{ margin-top: 30% !important; diff --git a/public/react/src/modules/topic_bank/Topic_bank.js b/public/react/src/modules/topic_bank/Topic_bank.js new file mode 100644 index 000000000..499351d75 --- /dev/null +++ b/public/react/src/modules/topic_bank/Topic_bank.js @@ -0,0 +1,45 @@ +import React, { Component } from 'react'; + +import { Redirect } from 'react-router'; + +import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; + +import Loading from '../../Loading' + +import Loadable from 'react-loadable'; +import { TPMIndexHOC } from '../tpm/TPMIndexHOC' +import { SnackbarHOC } from 'educoder' + + +const PackageIndex = Loadable({ + loader: () => import('../user/usersInfo/InfosTopics'), + loading: Loading, +}) + + +class Topic_bank extends Component { + constructor(props) { + super(props) + } + + componentDidMount(){ + } + + render() { + return ( +
    + + + () + } + > + + +
    + ); + } +} + +export default SnackbarHOC() (TPMIndexHOC (Topic_bank)) ; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/Infos.js b/public/react/src/modules/user/usersInfo/Infos.js index 242e25464..3a2632061 100644 --- a/public/react/src/modules/user/usersInfo/Infos.js +++ b/public/react/src/modules/user/usersInfo/Infos.js @@ -43,7 +43,10 @@ const InfosVideo = Loadable({ loader: () => import('./video/InfosVideo'), loading:Loading, }) - +const InfosTopics=Loadable({ + loader: () => import('./InfosTopics'), + loading:Loading, +}) const $ = window.$; class Infos extends Component{ @@ -258,13 +261,10 @@ class Infos extends Component{ {/* --------------------------------------------------------------------- */} - - - {/* 众包 */} - {/* http://localhost:3007/courses/1309/homework/9300/setting */} - () + (props) => () } > @@ -297,7 +297,15 @@ class Infos extends Component{ } > - {/* 项目 */} + {/* 众包 */} + {/* http://localhost:3007/courses/1309/homework/9300/setting */} + () + } + > + + {/* 视频 */} () @@ -305,6 +313,7 @@ class Infos extends Component{ > + () diff --git a/public/react/src/modules/user/usersInfo/InfosBanner.js b/public/react/src/modules/user/usersInfo/InfosBanner.js index 3aa329ec9..99afce1d0 100644 --- a/public/react/src/modules/user/usersInfo/InfosBanner.js +++ b/public/react/src/modules/user/usersInfo/InfosBanner.js @@ -27,6 +27,14 @@ class InfosBanner extends Component{ let {pathname}=this.props.location; moduleName=pathname.split("/")[3]; + let user_id=this.props.current_user&&this.props.current_user.user_id; + let user_type=this.props.current_user&&this.props.current_user.user_identity; + let targetuserid=this.props.data&&this.props.data.id; + + // console.log(is_current) + // console.log(current_user) + // console.log(current_user.is_teacher) + // console.log(current_user.admin) return(
    @@ -115,6 +123,14 @@ class InfosBanner extends Component{ to={`/users/${username}/videos`}>视频 } + {/*自己的主页且不是学生显示题库按钮*/} + {((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&
  • + this.setState({moduleName: 'topics'})} + to={`/users/${username}/topics/personal`}>题库 +
  • } +
    diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js new file mode 100644 index 000000000..535cbbf85 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -0,0 +1,557 @@ +import React, { Component } from 'react'; +import { SnackbarHOC } from 'educoder'; +import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom'; +import {Tooltip,Menu,Pagination,Spin, Dropdown,Checkbox} from 'antd'; +import axios from 'axios'; +import {getImageUrl,WordsBtn} from 'educoder'; +import moment from 'moment'; +import Modals from '../../modals/Modals'; +import SendTopics from '../../modals/SendTopics' +import NoneData from '../../courses/coursesPublic/NoneData'; +import "./usersInfo.css"; +import Withoutpermission from './Withoutpermission.png'; + + + +class InfosTopics extends Component{ + constructor(props){ + super(props); + this.state={ + isSpin:false, + category:"normal", + course_list_id:undefined, + sort_by:"updated_at", + sort_direction:"desc", + page:1, + data:undefined, + checkBoxValues:[], + per_page:15, + isshowprofes:false + } + } + + componentDidMount(){ + let types=this.props.match.params.topicstype; + let professional_certification=this.props.current_user&&this.props.current_user.professional_certification; + + if(professional_certification===false&&types==="publicly"){ + this.setState({ + isshowprofes:true + }) + }else{ + this.updataslist() + } + } + componentDidUpdate(prevProps) { + + if(prevProps.current_user!=this.props.current_user){ + let types=this.props.match.params.topicstype; + let professional_certification=this.props.current_user&&this.props.current_user.professional_certification; + + console.log(professional_certification) + if(professional_certification===false&&types==="publicly"){ + this.setState({ + isshowprofes:true + }) + }else{ + this.updataslist() + } + } + } + updataslist=()=>{ + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,page) + } + searchAlldata=(type,category,course_list_id,sort_by,sort_direction,page)=>{ + + // if(this.props.current_user.login!=this.props.match.params.username){ + // return + // }else{ + // + // } + let user_id=this.props.match.params&&this.props.match.params.username; + if(user_id!=undefined){ + let {per_page}=this.state; + let url=`/users/${user_id}/question_banks.json`; + axios.get(url,{params:{ + type, + object_type:category, + course_list_id, + sort_by, + sort_direction, + page, + per_page + } + }).then((response) => { + this.setState({ + data:response.data, + checkBoxValues:[] + }) + }).catch((error) => { + + }); + } + } + + searchCategory=(type)=>{ + this.setState({ + category:type, + course_list_id:undefined, + }) + + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,type,undefined,sort_by,sort_direction,page) + } + + searchCourselistid=(id)=>{ + this.setState({ + course_list_id:id + }) + + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,id,sort_by,sort_direction,page) + } + + onCheckBoxChange=(checkedValues)=>{ + if(checkedValues.length>15){ + this.props.showNotification("选择条数不能大于15条") + }else{ + this.setState({ + checkBoxValues:checkedValues + }) + } + + } + + updatedlist=(updatedtype)=>{ + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + if(updatedtype===sort_by){ + if(sort_direction==="desc"){ + this.setState({ + sort_direction:"asc", + sort_by:updatedtype + }) + this.searchAlldata(types,category,course_list_id,updatedtype,"asc",page) + }else{ + this.setState({ + sort_direction:"desc", + sort_by:updatedtype + }) + this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page) + } + }else{ + this.setState({ + sort_direction:"desc", + sort_by:updatedtype + }) + this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page) + } + } + + + changePage=(pageNumber)=>{ + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,pageNumber) + this.setState({ + page:pageNumber, + checkBoxValues:[] + }) + } + + deletecheckBoxValues=()=>{ + let {checkBoxValues}=this.state; + + if(checkBoxValues.length===0){ + this.props.showNotification("请选择题库") + }else{ + this.setState({ + Modalstype:true, + Modalstopval:"是否确认删除?", + ModalCancel:this.topicscancelmodel, + ModalSave:this.topicssavedelete, + }) + } + } + + topicssavedelete=()=>{ + let {checkBoxValues,category}=this.state; + const url = `/question_banks/multi_delete.json`; + axios.delete(url, { data: { + object_id: checkBoxValues, + object_type:category + }}) + .then((response) => { + if(response.data.status===0){ + this.updataslist() + this.props.showNotification(response.data.message) + }else{ + this.props.showNotification(response.data.message) + } + }) + .catch(function (error) { + console.log(error); + }); + + this.topicscancelmodel() + } + + + topicscancelmodel=()=>{ + this.setState({ + Modalstype:false, + Loadtype:false, + visible:false, + Modalstopval:"", + ModalCancel:"", + ModalSave:"", + checkBoxValues:[], + checkedtype:false + }) + + } + openTopics=(id)=>{ + this.setState({ + Modalstype:true, + Modalstopval:"公开后不能重设为私有", + ModalsBottomval:"是否确认设为公开?", + ModalCancel:this.topicscancelmodel, + ModalSave:()=>this.topicssaveonOpen(id), + }) + } + + topicssaveonOpen=(id)=>{ + + let {category}=this.state; + const url = `/question_banks/multi_public.json`; + axios.post(url,{ + object_id:[id], + object_type:category + }).then((response) => { + if(response.data.status===0){ + this.updataslist() + this.props.showNotification(response.data.message) + }else{ + this.props.showNotification(response.data.message) + } + }).catch(function (error) { + console.log(error); + }); + + this.topicscancelmodel() + } + + + sendTopics=()=>{ + let {checkBoxValues}=this.state; + if(checkBoxValues.length===0){ + this.props.showNotification("请选择题库") + }else{ + this.setState({ + visible:true + }) + } + + } + render(){ + let{ + category, + course_list_id, + isSpin, + data, + page, + sort_direction, + sort_by, + checkBoxValues, + Modalstype, + visible, + isshowprofes + } = this.state; + let { + is_current, + current_user, + }=this.props; + + let categorylist=[ + {val:"普通作业",type:"normal"}, + {val:"分组作业",type:"group"}, + {val:"毕设选题",type:"gtopic"}, + {val:"毕设任务",type:"gtask"}, + {val:"试卷",type:"exercise"}, + {val:"问卷",type:"poll"}, + ] + + let types=this.props.match.params.topicstype; + let username=this.props.match.params.username; + + + //types===publicly 公共 + //types===personal 私有 + let user_id=this.props.current_user&&this.props.current_user.user_id; + let user_type=this.props.current_user&&this.props.current_user.user_identity; + let targetuserid=this.props.data&&this.props.data.id; + + + + // console.log(is_current) + // console.log(current_user) + // console.log(current_user.is_teacher) + // console.log(current_user.admin) + const menu = ( + + this.updatedlist("updated_at")}> + 最近更新 + + this.updatedlist("name")}> + 题目更新 + + {types==="publicly"?this.updatedlist("contributor")}> + 贡献者 + :""} + + ); + return( +
    + {/*提示*/} + + {Modalstype&&Modalstype===true?:""} + + {/*发送至弹窗*/} + { + visible&&visible===true? + this.updataslist()} + topicscancelmodel={()=>this.topicscancelmodel()} + />:"" + } + + + +
    + {types==="publicly"?:} + + {isshowprofes===false? +
    + +
    + {categorylist.map((item,key)=>{ + return( + this.searchCategory(item.type)}>{item.val} + ) + })} + +
    + +
    +
  • this.searchCourselistid(undefined)}>全部
  • +
    + {data===undefined?"":data.course_list===undefined||data.course_list.length===0?"":data.course_list.map((item,key)=>{ + return( +
  • this.searchCourselistid(item.id)}>{item.name}
  • + ) + })} +
    +
    + +
    :
    +

    +

    +
    +
    通过职业认证的教师才能访问公共题库
    + +
    +

    +
    } + + + + +
    + + {isshowprofes===false?
    +

    + {data&&data.count===undefined?0:data&&data.count} + 已选择 {checkBoxValues.length} 个 (不支持跨页勾选) +

    +

    + + + {sort_by==="updated_at"?'最近更新':sort_by==="name"?'题目更新':sort_by==="contributor"?"贡献者":""} + this.updatedlist(sort_by)}> + + + + + + {((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&this.sendTopics()}>发送} + {types==="personal"?((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&this.deletecheckBoxValues()}>删除:""} +

    +
    :""} + + + {isshowprofes===true?"":data===undefined?:data.question_banks===undefined||data.question_banks.length===0?: + + {data.question_banks.map((item,key)=>{ + return( +
    +
    +
    + +
    + {((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&} + + + 55?item.name:""} className="ml10 fl mt3 font-16 color-dark maxwidth900" href={ + category==="normal"?`/banks/normal/${item.id}/${types}/details`: + category==="group"?`/banks/group/${item.id}/${types}/details`: + category==="poll"?`/banks/poll/${item.id}/${types}`: + category==="exercise"?`/banks/exercise/${item.id}/${types}`: + category==="gtask"?`/banks/gtask/${item.id}/${types}`: + category==="gtopic"?`/banks/gtopic/${item.id}/${types}`:"" + } + > + {item.name} + + + {item.is_public===true?公开:""} + + + +
    + +

    + + {types==="publicly"?{item.creator_name}:""} + {item.quotes_count} 次引用 + {item.solve_count} 次答题 + {moment(item.updated_at).fromNow()} + + {item.course_list_name===null?"": +

    {item.course_list_name}
    + } +

    + +
    + {types==="personal"?((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&编辑 + :""} + {types==="personal"&&item.is_public===false?((is_current && current_user && current_user.is_teacher ) || current_user && current_user.admin) + &&this.openTopics(item.id)}>设为公开:""} + +
    +
    +
    + +
    +
    + )})} +
    + } + + { + isshowprofes===true?"":data&&data.count >15 && +
    + +
    + } + +
    +
    + ) + } +} +export default InfosTopics; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/Withoutpermission.png b/public/react/src/modules/user/usersInfo/Withoutpermission.png new file mode 100755 index 000000000..791a0bc6e Binary files /dev/null and b/public/react/src/modules/user/usersInfo/Withoutpermission.png differ diff --git a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js index e6c39d578..496c21459 100644 --- a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js +++ b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js @@ -93,7 +93,7 @@ class BanksIndex extends Component{ { crumbData && - 题库 + { crumbData && crumbData.is_public == true ? '公共' : '我的' }题库 { crumbData.crumbArray && crumbData.crumbArray.map((item,key)=>{ return( @@ -105,23 +105,26 @@ class BanksIndex extends Component{ } { - crumbData && -

    - {crumbData && crumbData.title} - {crumbData.is_public == true ? '公开':'私有'} -

    - } + crumbData &&

    + {crumbData && crumbData.title} + { crumbData.is_public == true ? + 公开 + : + 私有 + } + +

    } {/*毕设任务编辑*/} - { return () } }> - { return ( - { return ( - { return ( - { return () @@ -156,40 +160,46 @@ class BanksIndex extends Component{ {/*题库问卷编辑详情*/} - () } > - { return () } }> - - {/*毕设任务题库详情*/} - { + return () + } + }> + {/*毕设任务题库详情*/} + () } > {/*毕设内容题库详情*/} - () } > {/*分组作业题库详情*/} - () } > {/* 普通作业题库详情*/} - () } diff --git a/public/react/src/modules/user/usersInfo/banks/BanksTabIndex.js b/public/react/src/modules/user/usersInfo/banks/BanksTabIndex.js new file mode 100644 index 000000000..491deb57a --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/BanksTabIndex.js @@ -0,0 +1,87 @@ +import React, { Component } from 'react'; + +import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; + + +import Loadable from 'react-loadable'; +import Loading from '../../../../Loading'; + +import BanksMenu from './banksMenu' +// 毕设选题 +const GtopicBanks = Loadable({ + loader: () => import('./GtopicBanks'), + loading: Loading, +}) +// 问卷内容 +const PollBanks = Loadable({ + loader: () => import('./PollBanksContent'), + loading: Loading, +}) +// 试卷详情 +const ExerciseBanksDetail = Loadable({ + loader: () => import('./ExerciseBanksDetail'), + loading: Loading, +}); + +class BanksTabIndex extends Component{ + constructor(props){ + super(props); + this.state={ + banksMenu:undefined + } + } + + initPublic = (crumbData,menuData) =>{ + this.setState({ + banksMenu:menuData + }) + this.props.initPublic(crumbData); + } + + render(){ + let{ + banksMenu + }=this.state + + const common={ + initPublic:this.initPublic, + } + return( + + { + banksMenu && + + } + + { + return () + } + }> + + { + return () + } + }> + { + return () + } + }> + + + + ) + } +} +export default (BanksTabIndex); \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/ExerciseBanksDetail.js b/public/react/src/modules/user/usersInfo/banks/ExerciseBanksDetail.js new file mode 100644 index 000000000..08988d824 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/ExerciseBanksDetail.js @@ -0,0 +1,55 @@ +import React, { Component } from 'react'; +import axios from 'axios' + +import ExerciseDisplay from '../../../courses/exercise/ExerciseDisplay' + +class ExerciseBanksDetail extends Component{ + constructor(props){ + super(props); + this.state={ + + } + } + + componentDidMount = () =>{ + + } + detailFetchCallback = (result) => { + let Id=this.props.match.params.Id; + + const crumbData={ + title: result.data.exercise && result.data.exercise.name, + is_public: result.data.exercise && result.data.exercise.is_public, + crumbArray:[ + {content:'详情'}, + ] + } + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/exercise/${Id}/${this.props.match.params.type}`,content:'内容详情'} + ], + category:'exercise',// + tos: `/banks/exercise/${Id}/edit/${this.props.match.params.type}`, + id: Id, + is_public: result.data.exercise && result.data.exercise.is_public, + type:this.props.match.params.type, + } + this.props.initPublic(crumbData,menuData); + } + + render(){ + let { pollDetail } = this.state + + return( +
    + + +
    + ) + } +} +export default ExerciseBanksDetail diff --git a/public/react/src/modules/user/usersInfo/banks/ExerciseBanksEdit.js b/public/react/src/modules/user/usersInfo/banks/ExerciseBanksEdit.js new file mode 100644 index 000000000..7ab9aedec --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/ExerciseBanksEdit.js @@ -0,0 +1,67 @@ +import React, { Component } from 'react'; +import axios from 'axios' + + +import ExerciseNewCommon from '../../../courses/exercise/ExerciseNewCommon' + +class ExerciseBanksEdit extends Component { + constructor(props){ + super(props); + this.state = { + isPublic: undefined, + // isGroup: false + } + } + componentDidMount = () =>{ + + + } + + initData = (responseData) =>{ + const Id = this.props.match.params.Id; + + const crumbData={ + title:'编辑', + is_public: responseData && responseData.data && responseData.data.exercise.is_public, + crumbArray:[ + {to:`/banks/exercise/${Id}/${this.props.match.params.type}`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + } + + render(){ + let { workId } = this.props.match.params + const common = { + // onCancel:this.onCancel, + // isGroup: this.isGroup, + // doNew: this.doNew, + // doEdit: this.doEdit, + initData: this.initData + } + return( +
    + + this.exerciseNewCommonRef = ref} + isEdit={true} + shixunsUrl={`/exercise_banks/choose_shixun.json`} + exercise_url={'exercise_banks'} + exercise_url_questions={'exercise_bank_questions'} + > +
    + ) + } +} +export default ExerciseBanksEdit; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/GtaskBanksEdit.js b/public/react/src/modules/user/usersInfo/banks/GtaskBanksEdit.js new file mode 100644 index 000000000..4c3bc4e24 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/GtaskBanksEdit.js @@ -0,0 +1,99 @@ +import React, { Component } from 'react'; +import axios from 'axios' +import NewGtaskForm from './NewGtaskForm'; +import NewWorkForm from "./HomeworkBanksEdit"; + +class GtaskBanksEdit extends Component { + constructor(props){ + super(props); + this.state = { + isPublic: undefined, + isGroup: false + } + } + componentDidMount = () =>{ + let workId = this.props.match.params.workId; + this.initData(workId); + } + + initData = (workId) =>{ + + let url = `/task_banks/${workId}.json`; + axios.get(url).then((result)=>{ + if(result){ + const crumbData={ + title:'编辑', + is_public:result && result.data && result.data.is_public, + crumbArray:[ + {to:`/banks/gtask/${workId}/${this.props.match.params.type}`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + result.data.isEdit = true; + this.setState({ data:result.data}) + this.newWorkFormRef.initValue(result.data); + } + }).catch((error)=>{ + console.log(error) + }) + } + + + doNew = () => { + } + doEdit = (params) => { + const workId = this.props.match.params.workId + const newUrl = `/homework_banks/${workId}.json` + + // const isGroup = this.props.isGroup() + axios.put(newUrl, params) + .then((response) => { + if (response.data.status == 0) { + this.props.showNotification('保存成功') + this.toWorkDetail() + } + }) + .catch(function (error) { + console.log(error); + }); + } + toWorkDetail = () => { + this.props.history.push(`/banks/gtask/${this.props.match.params.workId}/${this.props.match.params.type}`); + this.props.initPublic(undefined); + } + onCancel = () => { + this.toWorkDetail() + } + isGroup = () => { + return this.state.isGroup; + } + render(){ + + const common = { + onCancel:this.onCancel, + isGroup: this.isGroup, + doNew: this.doNew, + doEdit: this.doEdit, + } + return( +
    + + this.newWorkFormRef = ref} + topicId={this.props.match.params.workId} + > +
    + ) + } +} +export default GtaskBanksEdit; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/GtopicBanks.js b/public/react/src/modules/user/usersInfo/banks/GtopicBanks.js new file mode 100644 index 000000000..be7922d90 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/GtopicBanks.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; + + +class GtopicBanks extends Component{ + constructor(props){ + super(props); + } + componentDidMount = () =>{ + let bankId = this.props.match.params.bankId + const crumbData={ + title:'MySQL数据库编程开发实训(基础篇)111', + is_public:true, + crumbArray:[ + {content:'详情'}, + ] + } + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:'/banks/gtopic/1',content:'内容详情'}, + // {to:'/banks/gtopic/1/answer',content:'参考答案'}, + ], + category:'topic',//毕设选题 + id:bankId, + is_public:true, + } + this.props.initPublic(crumbData,menuData); + } + render(){ + return( +
    + +
    + ) + } +} +export default GtopicBanks; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/GtopicBanksEdit.js b/public/react/src/modules/user/usersInfo/banks/GtopicBanksEdit.js new file mode 100644 index 000000000..87be40195 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/GtopicBanksEdit.js @@ -0,0 +1,89 @@ +import React, { Component } from 'react'; +import axios from 'axios' + +import GraduateTopicNewFrom from '../../../courses/graduation/topics/GraduateTopicNewFrom' + +class GtopicBanksEdit extends Component{ + constructor(props){ + super(props); + this.state = { + isPublic:undefined + } + } + componentDidMount = () =>{ + let bankId = this.props.match.params.bankId; + + this.initData(bankId); + } + + initData = (bankId) =>{ + let url = `/gtopic_banks/${bankId}/edit.json`; + axios.get(url).then((result)=>{ + if(result){ + const crumbData={ + title:'编辑', + is_public:result && result.data.selected_data && result.data.selected_data.is_public, + crumbArray:[ + {to:`/banks/gtopic/${bankId}/${this.props.match.params.type}`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + + this.GraduateTopicNewFromRef.initValue(result); + } + }).catch((error)=>{ + console.log(error) + }) + } + + // 编辑保存 + editSave = (param,attachments,bankId) =>{ + const url = `/gtopic_banks/${bankId}.json`; + let params = { + gtopic_bank:param, + attachment_ids:attachments + } + axios.put(url,params).then((result)=>{ + if(result){ + this.props.showNotification('保存成功!'); + this.props.history.push(`/banks/gtopic/${bankId}/${this.props.match.params.type}`); + } + }).catch((error)=>{ + console.log(error); + }) + } + + // 取消 + editCancel = () =>{ + this.props.history.push(`/banks/gtopic/${this.props.match.params.bankId}/${this.props.match.params.type}`); + this.props.initPublic(undefined); + } + + render(){ + let { bankId } = this.props.match.params + const common = { + editSave:this.editSave, + editCancel:this.editCancel + } + return( +
    + + this.GraduateTopicNewFromRef = ref} + topicId={bankId} + > +
    + ) + } +} +export default GtopicBanksEdit; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js b/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js new file mode 100644 index 000000000..fa48361f6 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js @@ -0,0 +1,103 @@ +import React, { Component } from 'react'; +import axios from 'axios' + + +import NewWorkForm from '../../../courses/busyWork/NewWorkForm' + +class HomeworkBanksEdit extends Component { + constructor(props){ + super(props); + this.state = { + isPublic: undefined, + // isGroup: false + } + } + componentDidMount = () =>{ + let workId = this.props.match.params.workId; + + this.initData(workId); + } + + initData = (workId) =>{ + let url = `/homework_banks/${workId}.json`; + axios.get(url).then((result)=>{ + if(result){ + const crumbData={ + title:'编辑', + is_public:result && result.data && result.data.is_public, + crumbArray:[ + {to:`/banks/${this.getModuleName()}/${workId}/${this.props.match.params.type}?tab=0`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + result.data.isEdit = true; + result.data.ref_attachments = result.data.reference_attachments + // this.setState({ isGroup: result.data.min_num || result.data.max_num }) + this.newWorkFormRef.initValue(result.data); + } + }).catch((error)=>{ + console.log(error) + }) + } + + + doNew = () => { + } + doEdit = (params) => { + const workId = this.props.match.params.workId + const newUrl = `/homework_banks/${workId}.json` + + // const isGroup = this.props.isGroup() + axios.put(newUrl, params) + .then((response) => { + if (response.data.status == 0) { + this.props.showNotification('保存成功') + this.toWorkDetail() + } + }) + .catch(function (error) { + console.log(error); + }); + } + getModuleName = () => { + return this.props.isGroup ? 'group' : 'normal' + } + toWorkDetail = () => { + this.props.history.push(`/banks/${this.getModuleName()}/${this.props.match.params.workId}/${this.props.match.params.type}?tab=0`) + this.props.initPublic(undefined); + } + onCancel = () => { + this.toWorkDetail() + } + isGroup = () => { + return this.props.isGroup; + } + render(){ + let { bankId } = this.props.match.params + const common = { + onCancel:this.onCancel, + isGroup: this.isGroup, + doNew: this.doNew, + doEdit: this.doEdit, + } + return( +
    + + this.newWorkFormRef = ref} + > +
    + ) + } +} +export default HomeworkBanksEdit; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js new file mode 100644 index 000000000..e2c2208da --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js @@ -0,0 +1,357 @@ +import React,{ Component } from "react"; +import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Modal } from "antd"; +import axios from 'axios' +import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' +import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; +const $ = window.$; +const MAX_TITLE_LENGTH = 60; +class NewGtaskForms extends Component{ + constructor(props){ + super(props); + this.contentMdRef = React.createRef(); + this.state={ + title_num:0, + description:"", + contentFileList: [], + } + } + + + initValue = (data) => { + if (data.isEdit) { + const contentFileList = data.attachments.map(item => { + return { + id: item.id, + uid: item.id, + name: appendFileSizeToUploadFile(item), + url: item.url, + filesize: item.filesize, + status: 'done' + } + }) + this.setState({ + ...data, + base_on_project: data.group_info.base_on_project, + title_num: parseInt(data.name.length), + min_num: data.group_info.min_number, + max_num: data.group_info.max_number, + contentFileList, + }, () => { + setTimeout(() => { + this.contentMdRef.current.setValue(data.description || '') + }, 2000) + + this.props.form.setFieldsValue({ + title: data.name, + description: data.description || '', + }); + + }) + } else { // new + + } + } + + + // 输入title + changeTitle=(e)=>{ + console.log(e.target.value.length); + this.setState({ + title_num: parseInt(e.target.value.length) + }) + } + handleContentUploadChange = (info) => { + let contentFileList = info.fileList; + this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList) }); + } + deleteAttachment = (file, stateName) => { + // 初次上传不能直接取uid + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { + console.log('--- success') + + this.setState((state) => { + const index = state[stateName].indexOf(file); + const newFileList = state[stateName].slice(); + newFileList.splice(index, 1); + return { + [stateName]: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); + } + + onAttachmentRemove = (file, stateName) => { + if(file.response!=undefined){ + this.props.confirm({ + content: '是否确认删除?', + + onOk: () => { + this.deleteAttachment(file, stateName) + }, + onCancel() { + console.log('Cancel'); + }, + }); + return false; + } + + } + + handleSubmit = () => { + + let {contentFileList,min_num,max_num,base_on_project}=this.state; + let {data}=this.props; + let task_type=data.task_type + let topicId=this.props.topicId + this.props.form.validateFieldsAndScroll((err, values) => { + + const mdContnet = this.contentMdRef.current.getValue().trim(); + + values.description = mdContnet; + + if (!err) { + if (this.state.isEdit) { + let url="/task_banks/"+topicId+".json"; + axios.put(url, { + gtask_bank: { + name: values.title, + description: values.description, + min_num:task_type===1?undefined:min_num, + max_num:task_type===1?undefined:max_num, + base_on_project: task_type===1?undefined:base_on_project===true?1:0 + }, + attachment_ids:contentFileList + } + ).then((response) => { + if(response.data.status===0){ + this.props.showNotification(response.data.message) + }else{ + this.props.showNotification(response.data.message) + } + }).catch((error) => { + console.log(error) + }) + + } else { + + } + + } else { + $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) + } + }) + } + + max_num_change = (val) => { + if (val < 2) { + this.setState({ + max_num: 2, + }) + return; + } + const { min_num } = this.state; + this.setState({ + max_num: val, + min_num: val <= min_num ? val - 1 : min_num + }) + } + + min_num_change = (val) => { + this.setState({ min_num: val }) + } + + base_on_project_change = () => { + this.setState({ base_on_project: !this.state.base_on_project }) + } + + render(){ + const { getFieldDecorator } = this.props.form; + let{ + title_value, contentFileList, answerFileList, max_num, min_num, base_on_project, + init_max_num, init_min_num, + title_num, course_name, category, has_commit, has_project, + isEdit + }=this.state + const uploadProps = { + width: 600, + fileList: contentFileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUrl()}/api/attachments.json`, + onChange: this.handleContentUploadChange, + onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), + beforeUpload: (file) => { + console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 150; + if (!isLt150M) { + message.error('文件大小必须小于150MB!'); + } + return isLt150M; + }, + }; + + + return( +
    + +
    +
    +
    + {this.props.data&&this.props.data.task_type===1?"普通作业":this.props.data&&this.props.data.task_type===2?"分组作业":""} +
    +
    + + {getFieldDecorator('title', { + rules: [{ + required: true, message: '请输入标题' + }], + })( + + )} + + + + + + { + {getFieldDecorator('description', { + rules: [{ + required: true, message: '请输入任务内容说明' + }], + })( + + )} + } + + + (单个文件150M以内) + + {this.props.data&&this.props.data.task_type===2? + + {getFieldDecorator('personNum', { + rules: [{ + required: false + // required: true, message: '请输入最小人数和最大人数' + }], + })( +
    +

    + + {/* max={has_commit ? init_min_num : null } */} + 每组最小人数: 人 + + + + {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} + + 每组最大人数: 人 + +

    学生提交作品时需要关联同组成员,组内成员作品共享
    +

    +

    + + 基于项目(选中,则必须在本平台创建项目,项目管理员可以提交作品;不选中,无需在平台创建项目,任意小组成员均可以提交作品) + +

    +
    + )} +
    :"" + } + +
    + {/* htmlType="submit" */} + + this.props.onCancel()}>取消 +
    +
    + +
    + ) + } +} + + +const NewGtaskForm = Form.create({ name: 'NewGtaskForm' })(NewGtaskForms); +export default NewGtaskForm; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js b/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js new file mode 100644 index 000000000..0fa27c4d7 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js @@ -0,0 +1,67 @@ +import React, { Component } from 'react'; +import axios from 'axios' + +import PollDetailTabThirdInfo from '../../../courses/poll/PollDetailTabThirdInfo' + +class PollBanksContent extends Component{ + constructor(props){ + super(props); + this.state={ + pollDetail:undefined + } + } + + componentDidMount = () =>{ + let bankId=this.props.match.params.bankId; + let url = `/exercise_banks/${bankId}.json` + axios.get(url).then((result)=>{ + if(result){ + let pollDetail = { + poll:{ + id: result.data.poll && result.data.poll.id , + polls_description: result.data.poll && result.data.poll.description, + polls_name: result.data.poll && result.data.poll.name, + is_public:result.data.poll && result.data.poll.is_public + }, + question_types:result.data.question_types, + questions:result.data.questions, + } + const crumbData={ + title:result.data.poll && result.data.poll.name, + is_public:result.data.poll && result.data.poll.is_public, + crumbArray:[ + {content:'详情'}, + ] + } + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/poll/${bankId}/${this.props.match.params.type}`,content:'内容详情'} + ], + category:'poll',//毕设选题 + tos:`/banks/poll/${bankId}/edit/${this.props.match.params.type}`, + id:bankId, + is_public:result.data.poll && result.data.poll.is_public, + type:this.props.match.params.type, + } + this.props.initPublic(crumbData,menuData); + this.setState({ + pollDetail + }) + } + }).catch((error)=>{ + console.log(error); + }) + } + + render(){ + let { pollDetail } = this.state + + return( +
    + +
    + ) + } +} +export default PollBanksContent diff --git a/public/react/src/modules/user/usersInfo/banks/banksMenu.js b/public/react/src/modules/user/usersInfo/banks/banksMenu.js new file mode 100644 index 000000000..82cbf2ef3 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/banksMenu.js @@ -0,0 +1,187 @@ +import React, { Component } from 'react'; + +import { Menu } from 'antd' +import { Link } from 'react-router-dom' +import { WordsBtn } from 'educoder' +import "../usersInfo.css" +import "../../../courses/css/Courses.css" +import "../../../courses/css/busyWork.css" +import SendTopics from '../../../modals/SendTopics'; +import Modals from '../../../modals/Modals'; +import axios from 'axios'; +class BanksMenu extends Component{ + constructor(props){ + super(props); + this.state={ + visible:false, + tab:['0'], + } + } + + //发送至相关 + sendTopics=()=>{ + this.setState({ + visible:true + }) + } + componentDidMount() { + let { banksMenu} = this.props; + this.setState({ + tab:banksMenu && banksMenu.tab?[String(banksMenu.tab)]:['0'], + }) + } + + topicscancelmodel=()=>{ + this.setState({ + Modalstype:false, + Loadtype:false, + visible:false, + Modalstopval:"", + ModalCancel:"", + ModalSave:"", + checkBoxValues:[], + checkedtype:false + }) + } + + //删除相关 + + deletecheckBoxValues=(id,type)=>{ + + this.setState({ + Modalstype:true, + Modalstopval:"是否确认删除?", + ModalCancel:this.topicscancelmodel, + ModalSave:()=>this.topicssavedelete(id,type), + }) + + } + + topicssavedelete=(id,type)=>{ + console.log("删除了"); + console.log(id); + console.log(type); + const url = `/question_banks/multi_delete.json`; + axios.delete(url, { data: { + object_id: [id], + object_type:type + }}) + .then((response) => { + console.log(response); + if(response){ + if(response.data){ + if(response.data.status===0){ + this.props.showNotification(response.data.message) + window.location.href=`/users/${this.props.current_user.login}/topics/personal`; + }else{ + this.props.showNotification(response.data.message) + } + } + } + + }) + .catch(function (error) { + console.log(error); + }); + this.topicscancelmodel() + } + changeTab=(e)=>{ + this.setState({ + tab:e.key + }) + console.log(e.key); + // if(e.key === 0){ + // + // }else{ + // + // + // } + } + render(){ + let { banksMenu} = this.props; + let {visible,tab}=this.state; + // console.log("问卷预览"); + // console.log(visible); + let user_id=this.props.current_user&&this.props.current_user.user_id; + let user_type=this.props.current_user&&this.props.current_user.user_identity; + let targetuserid=this.props.data&&this.props.data.id; + console.log("_____________________________"); + console.log(this.props); + console.log("++++++++++++++++="); + return( +
    + {this.state.Modalstype&&this.state.Modalstype===true?:""} + {/*发送至弹窗*/} + { + visible&&visible===true? + this.topicscancelmodel()} + />:"" + } + { + banksMenu && +
    + + { + banksMenu.menuArray && banksMenu.menuArray.map((item,key)=>{ + console.log("BanksMenu"); + console.log(item); + return( + {item.content} + ) + }) + } + +
    + } + {this.props.isClassManagement() === true? + + this.deletecheckBoxValues(banksMenu&&banksMenu.id,banksMenu&&banksMenu.category)}style="blue" className="ml20 font-16">删除 + 编辑 + this.sendTopics()} style="blue" className="ml20 font-16">发送 + + : + (banksMenu&&banksMenu.type==="publicly"? + ( + banksMenu===undefined? + + this.deletecheckBoxValues(banksMenu&&banksMenu.id,banksMenu&&banksMenu.category)}style="blue" className="ml20 font-16">删除 + 编辑 + this.sendTopics()} style="blue" className="ml20 font-16">发送 + + :banksMenu.is_public===true? + + this.sendTopics()} style="blue" className="ml20 font-16">发送 + + : + + this.deletecheckBoxValues(banksMenu&&banksMenu.id,banksMenu&&banksMenu.category)}style="blue" className="ml20 font-16">删除 + 编辑 + + ) + : + + this.deletecheckBoxValues(banksMenu&&banksMenu.id,banksMenu&&banksMenu.category)}style="blue" className="ml20 font-16">删除 + 编辑 + this.sendTopics()} style="blue" className="ml20 font-16">发送 + + ) + } + +
    + ) + } +} +export default BanksMenu; \ No newline at end of file diff --git a/public/react/src/modules/user/usersInfo/usersInfo.css b/public/react/src/modules/user/usersInfo/usersInfo.css index ab5dd6136..0801e46e2 100644 --- a/public/react/src/modules/user/usersInfo/usersInfo.css +++ b/public/react/src/modules/user/usersInfo/usersInfo.css @@ -226,4 +226,200 @@ content: ''; left:0px; background: #4CACFF; +} + +/* 题库相关 */ +.breadcrumb{ + height: 18px; + line-height: 18px; + margin:10px 0px 0px; +} +.breadcrumb .ant-breadcrumb-separator{ + margin:0px 2px!important; +} +.breadcrumb span.ant-breadcrumb-link{ + cursor: default; +} +.bank_is_public{ + background: #84B6EB; + float: left; + height: 24px; + line-height: 24px; + padding:0px 20px; + color: #fff; + font-size: 16px; + margin-left: 10px; + border-radius:20px; + margin-top:3px; +} +.bank_is_private{ + background: #56B998; + float: left; + height: 24px; + line-height: 24px; + padding:0px 20px; + color: #fff; + font-size: 16px; + margin-left: 10px; + border-radius:20px; + margin-top:3px; +} +.topicsbox{ + width: 1200px; + /*min-height: 216px;*/ + background: rgba(255,255,255,1); + padding: 0px 30px 0px 40px; +} + +.topicstopfont{ + width:64px; + height:16px; + font-size:16px; + font-family:PingFangSC; + font-weight:400; + color: #666 !important; + cursor: pointer; +} + +.topcschild{ + width:1128px; + height:55px; + line-height: 54px; + border-bottom:1px solid rgba(235,235,235,1); +} + +.topcsmid{ + width:1128px; + height:55px; + line-height: 55px; +} + +.topcsactive{ + color: #4CACFF !important; +} + +.topicsmidfont{ + max-width: 56px; + height: 55px; + font-size: 14px; + font-family: PingFangSC; + font-weight: 400; + cursor: pointer; + line-height: 55px; + color: #666; +} + +.alltopisc{ + width:230px; + height:20px; + font-size:14px; + font-family:PingFangSC; + font-weight:400; + color:rgba(153,153,153,1); + line-height:20px; +} + +.alltopiscright{ + /* width: 141px; */ + height: 20px; + font-size: 14px; + font-family: PingFangSC; + font-weight: 400; + color: rgba(153,153,153,1); + line-height: 20px; +} + +.topicsbtn{ + padding: 3px 15px; + border-radius: 2px; + color: #4C4C4C; + cursor: pointer; + display: inline-block; + background-color: #4CACFF!important; + color: #fff!important; +} + +.pd1323{ + padding: 10px 6px 25px 40px; + /*cursor: pointer;*/ +} +.pd1323:hover { + box-shadow: 0px 2px 6px rgba(51,51,51,0.09); + opacity: 1; + border-radius: 2px; +} +.topicswidth600{ + mac-width: 600px; + display: inline-block; +} +.topicswidth300{ + width: 300px; + display: inline-block; +} +.topiscfilterbtn{ + font-size: 14px; + color: #4CACFF !important; + border-radius: 5px; + border: 1px solid #4CACFF !important; + line-height: 23px !important; +} + +.topscisright{ + right: 0px; + top: 45px; + display: block; + position: absolute; +} + +.topsics135{ + max-width: 135px; + display: inline-block; +} + +.professional_certificationbox{ + height:431px; + background:rgba(255,255,255,1); +} + +.pd115200{ + padding: 55px 200px 0px 200px; +} + +.topicsItemimg{ + width:150px; +} + +.topicsItemfont{ + font-size: 18px; + font-family: PingFang-SC; + font-weight: 400; + color: rgba(51,51,51,1); + line-height: 35px; +} + +.topicsItem{ + max-width: 1073px; + max-height: 115px; + overflow-y: auto; +} + +.mb45{ + margin-bottom: 45px!important; +} + +.topsicsmax550{ + max-width: 550px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + position: absolute; + top: -16px; +} + +.topsicrelative{ + position: relative; +} + +.topsicinline{ + display: inline-block; } \ No newline at end of file diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 022030757..91ea604d4 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -3761,8 +3761,3 @@ a.singlepublishtwo{ /*width: auto !important;*/ /*max-width: 600px !important;*/ /*}*/ -.topicsItem{ - max-width: 1138px; - max-height: 110px; - overflow-y: auto; -} \ No newline at end of file diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css index 62e052104..68305cc5b 100644 --- a/public/stylesheets/educoder/edu-main.css +++ b/public/stylesheets/educoder/edu-main.css @@ -103,6 +103,9 @@ a.decoration{text-decoration: underline} .mb0{margin-bottom: 0px!important;}.mb3{ margin-bottom: 3px;}.mb5{ margin-bottom: 5px;}.mb7{ margin-bottom: 7px;}.mb10{ margin-bottom: 10px;}.mb11{ margin-bottom: 11px;}.mb14{ margin-bottom: 14px;}.mb15{ margin-bottom: 15px;}.mb16{ margin-bottom: 16px;}.mb20{ margin-bottom: 20px!important;}.mb25{ margin-bottom: 25px;}.mb26{ margin-bottom: 26px;}.mb28{ margin-bottom: 28px;}.mb30{ margin-bottom: 30px!important;}.mb40{ margin-bottom: 40px!important;}.mb50{ margin-bottom: 50px!important;}.mb60{ margin-bottom: 60px!important;}.mb70{ margin-bottom: 70px!important;}.mb80{ margin-bottom: 80px!important;}.mb90{ margin-bottom: 90px!important;}.mb100{ margin-bottom: 100px!important;}.mb110{ margin-bottom: 110px;} .ml-3{ margin-left: -3px;}.ml1{margin-left: 1px;}.ml2{margin-left: 2px;}.ml3{margin-left: 3px;}.ml4{margin-left: 4px;}.ml5{ margin-left: 5px;}.ml6{ margin-left: 6px;}.ml10{ margin-left: 10px;}.ml12{ margin-left:12px!important;}.ml13{ margin-left:13px!important;}.ml15{ margin-left: 15px;}.ml18{ margin-left: 18px;}.ml20{ margin-left: 20px;}.ml22{ margin-left: 22px;}.ml25{ margin-left: 25px;}.ml29{margin-left: 29px;}.ml30{ margin-left: 30px;}.ml33{ margin-left: 33px;}.ml35{ margin-left:35px;}.ml40{margin-left:40px;}.ml42{margin-left:42px;}.ml45{ margin-left: 45px;}.ml50{ margin-left: 50px;}.ml55{ margin-left: 55px;}.ml60{ margin-left: 60px;}.ml72{ margin-left: 72px;}.ml73{ margin-left: 73px;}.ml75{ margin-left: 75px;}.ml80{ margin-left: 80px;}.ml85{margin-left:85px;}.ml95{ margin-left: 95px;}.ml115{margin-left: 115px}.ml123{ margin-left: 123px;}.ml150{ margin-left: 150px;}.ml180{ margin-left: 180px;}.ml230{ margin-left: 230px;}.ml240{margin-left: 240px;}.ml250{ margin-left: 250px;}.ml290{ margin-left: 290px;} .mr3{margin-right: 3px}.mr4{margin-right: 4px}.mr5{ margin-right: 5px;}.mr8{ margin-right: 8px;}.mr10{ margin-right: 10px;}.mr12{ margin-right:12px!important;}.mr15{ margin-right: 15px;}.mr18{ margin-right: 18px;}.mr20{ margin-right: 20px;}.mr24{ margin-right: 24px;}.mr25{ margin-right: 25px;}.mr30{ margin-right:30px;}.mr35{margin-right:35px;}.mr40{margin-right:40px;}.mr45{margin-right:45px;}.mr50{ margin-right: 50px;}.mr60{ margin-right:60px;}.mr70{ margin-right: 70px;}.mr75{ margin-right: 75px;}.mr80{ margin-right:80px;}.mr90{ margin-right:90px;}.mr100{ margin-right: 100px;}.mr110{ margin-right:110px;}.mr350{ margin-right:350px;} +.ml61{ + margin-left: 61px; +} .pt1{ padding-top:1px;}.pt3{ padding-top:3px!important;}.pt5{ padding-top:5px!important;}.pt10{ padding-top:10px;}.pt15{ padding-top:15px;}.pt17{ padding-top:17px;}.pt20{ padding-top:20px!important;}.pt25{ padding-top:25px;}.pt30{ padding-top:30px;}.pt35{ padding-top:35px;}.pt37{ padding-top:37px;}.pt40{ padding-top:40px;}.pt47{ padding-top:47px;}.pt49{ padding-top:49px;}.pt50{ padding-top:50px;}.pt60{ padding-top:60px;}.pt70{ padding-top:70px;}.pt80{ padding-top:80px;}.pt90{ padding-top:90px;}.pt100{padding-top:100px;}.pt110{ padding-top:110px;}.pt120{ padding-top:120px;}.pt130{padding-top:130px;} .pb3{ padding-bottom:3px!important;}.pb5{ padding-bottom:5px!important;}.pb10{ padding-bottom:10px;}.pb15{ padding-bottom:15px;}.pb20{ padding-bottom:20px;}.pb25{ padding-bottom:20px;}.pb25{ padding-bottom:20px;}.pb30{ padding-bottom:30px;}.pb35{ padding-bottom:35px;}.pb40{ padding-bottom:40px;}.pb47{ padding-bottom:47px;}.pb50{ padding-bottom:50px;}.pb60{ padding-bottom:60px;}.pb70{ padding-bottom:70px;}.pb80{ padding-bottom:80px;}.pb90{ padding-bottom:90px;}.pb100{ padding-bottom:100px;}.pb110{ padding-bottom:110px;}.pb155{ padding-bottom:155px;} @@ -111,7 +114,6 @@ a.decoration{text-decoration: underline} .pl0{ padding-left:0px!important;}.pl2{ padding-left:2px;}.pl5{ padding-left:5px;}.pl7{ padding-left:7px;}.pl8{ padding-left:8px;}.pl10{ padding-left:10px;}.pl15{ padding-left:15px;}.pl20{ padding-left:20px;}.pl22{ padding-left:22px;}.pl25{ padding-left:25px;}.pl28{ padding-left:28px;}.pl30{ padding-left:30px !important;}.pl33{padding-left: 33px}.pl35{ padding-left:35px;}.pl40{ padding-left:40px;}.pl42{ padding-left:42px;}.pl45{ padding-left:45px;}.pl50{ padding-left:50px;}.pl60{ padding-left:60px;}.pl70{padding-left:70px;}.pl75{padding-left:75px;}.pl80{padding-left:80px;}.pl88{ padding-left:88px;}.pl92{padding-left:92px;}.pl100{ padding-left:100px;} .pr2{ paddding-right:2px;}.pr5{ padding-right:5px;}.pr7{ padding-right:7px;}.pr10{ padding-right:10px;}.pr15{ padding-right:15px;}.pr20{ padding-right:20px!important;}.pr25{ padding-right:25px!important;}.pr30{ padding-right:30px!important;}.pr40{ padding-right:40px;}.pr42{ padding-right:42px;}.pr45{ padding-right:45px;}.pr60{padding-right:60px;}.pr75{padding-right:75px;} - .padding5-10{padding:5px 10px;box-sizing: border-box} .padding5-20{padding:5px 20px;box-sizing: border-box} .padding10{padding: 10px;box-sizing: border-box} @@ -170,7 +172,7 @@ input::-ms-clear{display:none;} .newContainer{ min-height:100%; height: auto !important; height: 100%; /*IE6不识别min-height*/position: relative;} .educontent{width: 1200px;margin:0px auto;box-sizing: border-box}/*中间部分宽度固定为1200*/ .newMain{ margin: 0 auto; padding-bottom: 235px; min-width:1200px;}/*padding-bottom根据底部的高度而定*/ -.newMain{ padding-bottom: 120px !important; } +.newMain{ padding-bottom: 124px !important; } /*高度*/ .height-100{height: 100%;}