- <% question_list = @exercise.exercise_questions.includes(:exercise_shixun_answers, :exercise_choices => [:exercise_answers]) %>
+ <% question_list = exercise_questions.includes(:exercise_shixun_answers, :exercise_choices => [:exercise_answers]) %>
<% question_list.each do |exercise_question| %>
diff --git a/db/migrate/20190417024319_create_exercise_level_settings.rb b/db/migrate/20190417024319_create_exercise_level_settings.rb
new file mode 100644
index 00000000..6aaa349f
--- /dev/null
+++ b/db/migrate/20190417024319_create_exercise_level_settings.rb
@@ -0,0 +1,19 @@
+class CreateExerciseLevelSettings < ActiveRecord::Migration
+ def change
+ create_table :exercise_level_settings do |t|
+ t.references :exercise
+ t.integer :level, default: 1
+ t.integer :score, default: 0
+ t.integer :num, default: 0
+
+ t.timestamps
+ end
+ add_index :exercise_level_settings, :exercise_id
+
+ Exercise.find_each do |exercise|
+ shixun_questions = exercise.exercise_questions.where(question_type: 5)
+ exercise.exercise_level_settings << ExerciseLevelSetting.new(level: 1, score: shixun_questions.map(&:question_score).min,
+ num: shixun_questions.count)
+ end
+ end
+end
diff --git a/db/migrate/20190417024510_add_exercise_level_setting_to_question.rb b/db/migrate/20190417024510_add_exercise_level_setting_to_question.rb
new file mode 100644
index 00000000..33611a73
--- /dev/null
+++ b/db/migrate/20190417024510_add_exercise_level_setting_to_question.rb
@@ -0,0 +1,12 @@
+class AddExerciseLevelSettingToQuestion < ActiveRecord::Migration
+ def change
+ add_column :exercise_questions, :exercise_level_setting_id, :integer, default: 0
+ add_column :exercise_questions, :level, :integer, default: 1
+
+ add_index :exercise_questions, :exercise_level_setting_id
+
+ ExerciseQuestion.where(question_type: 5).find_each do |question|
+ question.update_attributes(exercise_level_setting_id: question.exercise.exercise_level_settings.first.try(:id)) if question.exercise.present?
+ end
+ end
+end
diff --git a/db/migrate/20190417024736_create_question_count.rb b/db/migrate/20190417024736_create_question_count.rb
new file mode 100644
index 00000000..6653a929
--- /dev/null
+++ b/db/migrate/20190417024736_create_question_count.rb
@@ -0,0 +1,13 @@
+class CreateQuestionCount < ActiveRecord::Migration
+ def up
+ add_column :exercise_level_settings, :exercise_questions_count, :integer, :default => 0
+
+ ExerciseLevelSetting.reset_column_information
+ ExerciseLevelSetting.find_each do |s|
+ ExerciseLevelSetting.reset_counters s.id, :exercise_questions
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20190417033935_create_exercise_user_questions.rb b/db/migrate/20190417033935_create_exercise_user_questions.rb
new file mode 100644
index 00000000..950f2ab7
--- /dev/null
+++ b/db/migrate/20190417033935_create_exercise_user_questions.rb
@@ -0,0 +1,14 @@
+class CreateExerciseUserQuestions < ActiveRecord::Migration
+ def change
+ create_table :exercise_user_questions do |t|
+ t.references :exercise
+ t.references :exercise_user
+ t.references :exercise_question
+
+ t.timestamps
+ end
+ add_index :exercise_user_questions, :exercise_id
+ add_index :exercise_user_questions, :exercise_user_id
+ add_index :exercise_user_questions, :exercise_question_id
+ end
+end
diff --git a/spec/factories/exercise_level_settings.rb b/spec/factories/exercise_level_settings.rb
new file mode 100644
index 00000000..a412882c
--- /dev/null
+++ b/spec/factories/exercise_level_settings.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :exercise_level_setting do
+ exercise nil
+ level 1
+ score 1
+ num 1
+ end
+end
diff --git a/spec/factories/exercise_user_questions.rb b/spec/factories/exercise_user_questions.rb
new file mode 100644
index 00000000..493cdb0d
--- /dev/null
+++ b/spec/factories/exercise_user_questions.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :exercise_user_question do
+ exercise nil
+ exercise_user nil
+ exercise_question nil
+ end
+end
diff --git a/spec/models/exercise_level_setting_spec.rb b/spec/models/exercise_level_setting_spec.rb
new file mode 100644
index 00000000..ea20df40
--- /dev/null
+++ b/spec/models/exercise_level_setting_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ExerciseLevelSetting, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/exercise_user_question_spec.rb b/spec/models/exercise_user_question_spec.rb
new file mode 100644
index 00000000..00e111c3
--- /dev/null
+++ b/spec/models/exercise_user_question_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ExerciseUserQuestion, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
From 18466876754ffef214ad18ed6a586e58ee4ab3a8 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 17 Apr 2019 16:23:33 +0800
Subject: [PATCH 7/9] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 7 ++-
app/helpers/exercise_helper.rb | 4 +-
.../_new_shixun_exercise_list.html.erb | 59 +++++++++++++++++--
public/javascripts/edu/course.js | 3 +-
4 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 2dfc2601..15998dbf 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -149,11 +149,14 @@ class ExerciseController < ApplicationController
end
@shixuns = Shixun.where("status = 2 and challenges_count = 1 and id not in (#{none_shixun_ids.join(",")})").
where("name like ?", "%#{search}%").select{|shixun| shixun.challenges.where(:st => 1).count == 0}
- @limit = 8
+ @limit = 10
+ @total_pages = (@shixuns.count / 10.0).ceil
@shixuns = paginateHelper @shixuns, @limit
respond_to do |format|
format.js
- render json: exercise_shixun_json_data(@shixuns)
+ format.json {
+ render json: exercise_shixun_json_data(@shixuns)
+ }
end
end
diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb
index cdea7b88..b0ebedcf 100644
--- a/app/helpers/exercise_helper.rb
+++ b/app/helpers/exercise_helper.rb
@@ -5,11 +5,13 @@ module ExerciseHelper
shixun_owner = shixun.owner.try(:show_name)
shixun_path = shixun_path(shixun)
shixun_level = shixun.shixun_level
+ owner_path = user_path(shixun.owner)
shixun.attributes.dup.except("gpid", "identifier", "major_id", "webssh", "homepage_show", "fork_from", "git_url",
"mirror_script_id", "repo_name", "pod_life").merge({
shixun_owner: shixun_owner,
shixun_level: shixun_level,
- shixun_path: shixun_path
+ shixun_path: shixun_path,
+ owner_path: owner_path
})
end
end
diff --git a/app/views/exercise/_new_shixun_exercise_list.html.erb b/app/views/exercise/_new_shixun_exercise_list.html.erb
index a397a0f6..84887695 100644
--- a/app/views/exercise/_new_shixun_exercise_list.html.erb
+++ b/app/views/exercise/_new_shixun_exercise_list.html.erb
@@ -4,19 +4,19 @@
实训名称
创建者
- 学员数
+ 级别
-
+
<% @shixuns.each do |shixun| %>
-
-
+
+
<%= link_to shixun.name, shixun_path(shixun), :class => "edu-info-dark task-hide mt3 ml20",:style=> "text-align:left", :target => "_blank" %>
<%= link_to shixun.owner.try(:show_name), user_path(shixun.owner), :class => "edu-txt-w140 mt3 task-hide" %>
- <%= shixun.myshixuns.count %>
+ <%= shixun.shixun_level %>
<% end %>
@@ -36,6 +36,55 @@
+
+
-
\ No newline at end of file
diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css
index 583e4a15..5dea2622 100644
--- a/public/stylesheets/educoder/edu-main.css
+++ b/public/stylesheets/educoder/edu-main.css
@@ -230,6 +230,8 @@ input::-ms-clear{display:none;}
.color-grey-B4{color: #B4B4B4!important;}
.color-grey-74{color: #747A7F!important;}
.color-f5f5f5{color: #f5f5f5!important;}
+.color-afafaf{color: #afafaf!important;}
+
a.color-grey-name:hover,a.color-dark:hover,a.color-grey-6:hover,a.color-grey-3:hover{color: #4cacff!important;}
a.color-grey-9:hover,a.color-grey-8:hover,a.color-grey-c:hover{color: #111C24!important;}
/*蓝色*/
@@ -890,7 +892,7 @@ html>body #ajax-indicator { position: fixed; }
.practicalTemp{
width:1200px;
- height:950px;
+ min-height:950px;
background:rgba(255,255,255,1);
border:1px solid rgba(238,238,238,1);
}
@@ -901,7 +903,7 @@ html>body #ajax-indicator { position: fixed; }
font-weight:400;
color:rgba(102,102,102,1);
width: 1200px;
- height: 60px;
+ min-height: 60px;
line-height: 25px;
padding-left: 10px;
border-bottom: 1px solid rgba(238,238,238,1);
@@ -915,7 +917,7 @@ html>body #ajax-indicator { position: fixed; }
.Titlefont{
width: 48px;
- height: 30px;
+ min-height: 30px;
font-size: 15px;
font-family: MicrosoftYaHei;
font-weight: 400;
@@ -936,6 +938,59 @@ html>body #ajax-indicator { position: fixed; }
margin-left: 117px;
}
+.colorFF8121sum{
+ color: #FF8121;
+ font-size: 12px;
+ text-align: left;
+ width: 160px;
+ margin-left: 62px;
+}
+
+
.borderFF8121{
border:1px solid #FF8121
+}
+
+.shixunsbox{
+ width: 1180px;
+ padding-left: 20px;
+ padding-bottom: 20px;
+ border-bottom: 1px solid rgba(238,238,238,1);
+}
+
+.shixunsboxfont{
+ width:1060px;
+ min-height:12px;
+ font-size:4px;
+ font-family:MicrosoftYaHei;
+ font-weight:400;
+ color:rgba(122,122,122,1);
+ display: inline-block;
+}
+
+.shixundelect{
+ font-size: 18px;
+}
+
+.shixundelect:hover .color-afafaf{
+ color:#5b5b5b !important;
+}
+.block{
+ display: block;
+}
+
+.over300{
+ max-height: 300px;
+ overflow-y: auto;
+ display: block;
+}
+.width100p{
+ width:100px;
+}
+.width425p{
+ width:425px;
+}
+
+.width420p{
+ width:420px;
}
\ No newline at end of file
From 73d4fd9c18be93f30b5b3c03deb238bd1ff52c58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 17 Apr 2019 17:07:31 +0800
Subject: [PATCH 9/9] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A1=B5=E9=9D=A2=20?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/exercise/_edit_shixun.html.erb | 132 +++++++++++------------
app/views/exercise/_new_shixun.html.erb | 72 ++++++++++++-
public/stylesheets/educoder/edu-main.css | 26 +++++
3 files changed, 157 insertions(+), 73 deletions(-)
diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb
index 3dd10e76..23396e40 100644
--- a/app/views/exercise/_edit_shixun.html.erb
+++ b/app/views/exercise/_edit_shixun.html.erb
@@ -39,83 +39,75 @@
-
实训题
-
-
-
-
-
-
初级题
-
-
-
* 分值:
分/题
-
*大于等于0,且不能大于100
-
*不能为空
-
*必须大于等于0
-
*不能大于100
-
-
-
-
*
- 随机出题量:
题
-
*不能为空
-
*必须为正整数
-
*不能大于可用题数
-
-
-
- 3
- 题可用
-
-
-
-
-
-
-
-
命令加密ZPI压缩文件解压
-
+ 实训题
+
+
+
+
初级题
+
+
+
* 分值:
分/题
+
*大于等于0,且不能大于100
+
*不能为空
+
*必须大于等于0
+
*不能大于100
+
+
+
+
*
+ 随机出题量:
题
+
*不能为空
+
*必须为正整数
+
*不能大于可用题数
+
+
+
+ 3
+ 题可用
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ 保存
+ 取消
+
+ 温馨提示: [实训题]属于客观题将由系统自动评分
+
+
+
-
-
\ No newline at end of file
+
diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb
index 389a4b67..36a7789b 100644
--- a/app/views/exercise/_new_shixun.html.erb
+++ b/app/views/exercise/_new_shixun.html.erb
@@ -41,12 +41,78 @@
diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css
index 5dea2622..363ee3e8 100644
--- a/public/stylesheets/educoder/edu-main.css
+++ b/public/stylesheets/educoder/edu-main.css
@@ -958,6 +958,12 @@ html>body #ajax-indicator { position: fixed; }
border-bottom: 1px solid rgba(238,238,238,1);
}
+.shixunsboxs{
+ width: 1180px;
+ padding-left: 20px;
+ padding-bottom: 20px;
+}
+
.shixunsboxfont{
width:1060px;
min-height:12px;
@@ -993,4 +999,24 @@ html>body #ajax-indicator { position: fixed; }
.width420p{
width:420px;
+}
+.newshixunbox{
+ width: 303px;
+ height: 40px;
+ background: rgba(255,255,255,1);
+ border: 1px solid rgba(255,104,0,1);
+ border-radius: 2px;
+ line-height: 40px;
+ margin: 0 auto;
+ margin-top: 20px;
+}
+
+.newshixunboxfont{
+ width:71px;
+ height:12px;
+ font-size:4px;
+ font-family:MicrosoftYaHei;
+ font-weight:400;
+ color:rgba(255,104,0,1);
+ margin: 0 auto;
}
\ No newline at end of file