From 0bf70f145e22d5dae13312c1c864417cdb892331 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 26 Jul 2017 18:50:52 +0800 Subject: [PATCH 01/29] =?UTF-8?q?=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E7=BC=96=E8=BE=91/=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 33 ++++++++--- app/models/challenge.rb | 12 ++++ app/models/challenge_question.rb | 3 +- app/views/challenges/_content_list.html.erb | 8 +-- app/views/challenges/_edit_task_pass.html.erb | 58 +++++++++---------- app/views/challenges/_task_pass_form.html.erb | 52 ++++++++++++----- 6 files changed, 107 insertions(+), 59 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 87fe18a96..efd05a66d 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -14,7 +14,7 @@ class ChallengesController < ApplicationController def new # 顶部导航 - @st = params[:st] + @st = params[:st].to_i @project_menu_type = 11 respond_to do |format| format.html { render :action => 'new', :layout => 'base_shixun' } @@ -29,17 +29,18 @@ class ChallengesController < ApplicationController @challenge.position = challenge_count + 1 @challenge.shixun = @shixun @challenge.user = User.current - # @challenge.st = params[:st] + @challenge.st = params[:st].to_i if @challenge.save! - # 创建选项 - # params[:question].each do |test| - # ChallengeQuestion.where(:option_name => option_name,:challenges => challenge_id, :positon => 1, :right_key => true) - # end + #创建选项 + params[:question][:cnt].each_with_index do |test, index| + answer = params[:choice][:answer][index] == "0" ? false : true + ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) + end end redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) rescue Exception => e flash[:error] = "#{e.message}" - redirect_to new_shixun_challenge_path(:shixun_id => @shixun) + redirect_to new_shixun_challenge_path(:shixun_id => @shixun, :st => params[:st].to_i) raise ActiveRecord::Rollback end end @@ -103,6 +104,7 @@ class ChallengesController < ApplicationController end def edit + @st = @challenge.st challenge_num = Challenge.where(:shixun_id => @shixun).count challenge_pos = @challenge.position if challenge_pos < challenge_num @@ -120,8 +122,21 @@ class ChallengesController < ApplicationController end def update - @challenge.update_attributes(params[:challenge]) - redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + ActiveRecord::Base.transaction do + @challenge.update_attributes(params[:challenge]) + begin + @challenge.challenge_questions.delete_all + params[:question][:cnt].each_with_index do |test, index| + answer = params[:choice][:answer][index] == "0" ? false : true + ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) + end + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + rescue Exception => e + flash[:error] = "#{e.message}" + format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} + raise ActiveRecord::Rollback + end + end =begin respond_to do |format| ActiveRecord::Base.transaction do diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 6779b345e..3ec4901a2 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -8,6 +8,7 @@ class Challenge < ActiveRecord::Base has_many :test_sets, :dependent => :destroy has_many :challenge_tags, :dependent => :destroy has_many :games, :dependent => :destroy + has_many :challenge_questions, :dependent => :destroy validates_presence_of :subject # validates_presence_of :score @@ -43,4 +44,15 @@ class Challenge < ActiveRecord::Base myshixun = Myshixun.where(:shixun_id => self.shixun.id, :user_id => User.current.id).first game = Game.where(:myshixun_id => myshixun.id, :challenge_id => self.id).first end + + # 正确答案 + def right_answers + answer = "" + self.challenge_questions.each do |ans| + if ans.right_key + answer << (ans.position + 65).chr + end + end + return answer + end end diff --git a/app/models/challenge_question.rb b/app/models/challenge_question.rb index bda6780ce..eb835c32e 100644 --- a/app/models/challenge_question.rb +++ b/app/models/challenge_question.rb @@ -1,3 +1,4 @@ class ChallengeQuestion < ActiveRecord::Base - attr_accessible :challenge_id, :option, :position, :right_key + belongs_to :challenge + attr_accessible :challenge_id, :option_name, :position, :right_key end diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 7a36fa413..1145b27a1 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -5,10 +5,10 @@ <%= @challenges.count %> <% end %> <% if User.current.manager_of_shixun?(@shixun) && @shixun.status == 0 %> - +单选任务 - +多选任务 - +编程任务 - + +单选任务 + +多选任务 + +编程任务 + <% end %>
+ <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +
+
+ <%= link_to image_tag(url_to_avatar(dis.user), :alt => "头像", :width => 60, :height => 60), user_path(dis.user),:class => "fl mt5", :target => '_blank' %> +
<%= link_to dis.user.show_name, user_path(dis.user), :class => "fl link-color-grey" %> <%= render :partial => "discusses/dis_praise", :locals => {:discuss => dis} %>
-<%= dis.content %>
-+
<%= dis.content %>
+<%= time_from_now dis.created_at %>
-+
<% if User.current.manager_of_shixun?(@shixun) && dis.children.count == 0 %> 回复 <% end %> diff --git a/public/stylesheets/css/taskstyle.css b/public/stylesheets/css/taskstyle.css index dde38cb05..f8e7c08c6 100644 --- a/public/stylesheets/css/taskstyle.css +++ b/public/stylesheets/css/taskstyle.css @@ -176,7 +176,7 @@ input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f .-task-widht-90{ width: 90%;} .-task-widht-100{ width: 100%;} .-footer-left{min-height:48px;background:#f5f5f5;} -.-footer-left ul { margin-top:10px;width: 100%} +.-footer-left ul {width: 100%} .-footer-left ul li{ cursor: pointer; color:#666;} .-footer-left ul li:hover{ color:#888;} .-bg-black{ background:#2b2b2b; color:#f4f1ed;} @@ -326,13 +326,13 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh .tab_color{color: #bfbfbf!important;} /*_game_show.html.erb页面新增的一个tab*/ -.comments_item_content img{width: 9%;border-radius: 50%;margin-right: 5px} -.comment_item_one{width: 90%} +.comments_item_content img{border-radius: 50%;margin-right: 5px} +.comment_item_one{width: 87%} .comment_item_bottom{border-bottom: 1px solid #efefef} .comment_item_top{border-top: 1px solid #efefef} .comment_item_left_green{border-left: 3px solid #29bd8b} .return_item{height: 20px;line-height: 20px;margin-top: 5px;} -.comment-input{width: 90%;padding: 0px 10px;} +.comment-input{left:90px;position: absolute;right: 50px;top:10px} .comment-input textarea{border: none !important;width:86%; outline: none;height: 30px;border-radius: 4px;margin-right: 10px;padding-left: 5px;float:left} .comment_position{ position: absolute;bottom: 8px;} @@ -344,3 +344,41 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh .add-option-input{padding: 5px;width: 90%;height: 40px;min-width: 700px;border: 1px dashed #e2e2e2;} .add-option-input a{display: block;width: 100%;height: 100%;cursor: pointer} .position-delete{position: absolute;right: -17px;top: 12px;cursor: pointer} + +/*--------TPI的答案选项卡------*/ +.quiz-task-options:not(.-compact) { + padding:30px 10px; +} +.card { + position: relative; + background: #515151; + border-radius: 2px; + overflow: hidden; +} +.card:hover{ + background: #3f3f3f; +} +.card-check{background: #3498db!important;} +.-justify { + justify-content: space-between; +} +.-center { + align-items: center; +} +.markdown { + letter-spacing: 0; + line-height: 1.6; + word-wrap: break-word; + word-break: break-word; +} +.markdown code { + padding: 0.2em 0; + margin: 0; + font-family: "微软雅黑","宋体"; +} + + + + + + From 12dea63148e0e5211f18871d1d308dc38497c563 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jul 2017 14:30:26 +0800 Subject: [PATCH 10/29] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPM=E5=8F=82=E8=80=83?= =?UTF-8?q?=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 40f628967..69172be8b 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -128,17 +128,21 @@ class ChallengesController < ApplicationController else ActiveRecord::Base.transaction do @challenge.update_attributes(params[:challenge]) - begin - @challenge.challenge_questions.delete_all - params[:question][:cnt].each_with_index do |test, index| - answer = params[:choice][:answer][index] == "0" ? false : true - ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) + if params[:tab] == "1" || params[:tab].nil? + begin + @challenge.challenge_questions.delete_all + params[:question][:cnt].each_with_index do |test, index| + answer = params[:choice][:answer][index] == "0" ? false : true + ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) + end + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + rescue Exception => e + flash[:error] = "#{e.message}" + format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} + raise ActiveRecord::Rollback end + else redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) - rescue Exception => e - flash[:error] = "#{e.message}" - format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} - raise ActiveRecord::Rollback end end end From e073a618e9a092acaa7c6e33e2e492de0bf0c2b3 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 27 Jul 2017 14:44:24 +0800 Subject: [PATCH 11/29] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_game_results.html.erb | 44 -------------- app/views/games/_game_show.html.erb | 73 ++++++++++++++++++++---- app/views/homework_common/index.html.erb | 2 +- public/stylesheets/css/edu-common.css | 17 +++--- public/stylesheets/css/edu-public.css | 4 +- 5 files changed, 74 insertions(+), 66 deletions(-) diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 71524c16c..98d99696a 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -8,9 +8,6 @@