Skip to content

Commit 7c0fa9f

Browse files
authored
Merge pull request #44 from internetee/add-practical-tests
Add practical tests
2 parents c1a75b6 + 9cc19f7 commit 7c0fa9f

File tree

93 files changed

+3717
-1235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3717
-1235
lines changed

Gemfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ gem 'positioning'
9090

9191
gem 'friendly_id', '~> 5.4.0'
9292

93-
# Security updates
94-
gem 'nokogiri', '>= 1.18.9'
95-
gem 'thor', '>= 1.4.0'
93+
gem 'mustache', '~> 1.0'
94+
95+
gem 'simpleidn'
96+
97+
gem 'faker'
98+

Gemfile.lock

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ GEM
124124
erubi (1.13.1)
125125
et-orbi (1.2.11)
126126
tzinfo
127+
faker (3.5.2)
128+
i18n (>= 1.8.11, < 2)
127129
faraday (2.13.2)
128130
faraday-net_http (>= 2.0, < 3.5)
129131
json
@@ -189,6 +191,7 @@ GEM
189191
mini_mime (1.1.5)
190192
minitest (5.25.5)
191193
msgpack (1.8.0)
194+
mustache (1.1.1)
192195
net-http (0.6.0)
193196
uri
194197
net-imap (0.5.10)
@@ -317,13 +320,7 @@ GEM
317320
rexml (~> 3.2, >= 3.2.5)
318321
rubyzip (>= 1.2.2, < 3.0)
319322
websocket (~> 1.0)
320-
simplecov (0.22.0)
321-
docile (~> 1.1)
322-
simplecov-html (~> 0.11)
323-
simplecov_json_formatter (~> 0.1)
324-
simplecov-html (0.13.2)
325-
simplecov-lcov (0.9.0)
326-
simplecov_json_formatter (0.1.4)
323+
simpleidn (0.2.3)
327324
solid_cable (3.0.11)
328325
actioncable (>= 7.2)
329326
activejob (>= 7.2)
@@ -392,14 +389,15 @@ DEPENDENCIES
392389
dartsass-rails (~> 0.5.1)
393390
debug
394391
devise
392+
faker
395393
faraday
396394
figaro
397395
font-awesome-sass (~> 5.15.1)
398396
friendly_id (~> 5.4.0)
399397
importmap-rails
400398
jbuilder
401399
kamal
402-
nokogiri (>= 1.18.9)
400+
mustache (~> 1.0)
403401
pagy (~> 9.3)
404402
pg (~> 1.1)
405403
positioning
@@ -409,8 +407,7 @@ DEPENDENCIES
409407
ransack
410408
rspec-rails (~> 8.0.0)
411409
selenium-webdriver
412-
simplecov
413-
simplecov-lcov
410+
simpleidn
414411
solid_cable
415412
solid_cache
416413
solid_queue

app/assets/images/html-pattern.png

200 KB
Loading

app/assets/stylesheets/components/quicklinks.scss

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,39 @@
44
position: relative;
55
z-index: 1;
66
margin-top: -40px;
7-
padding: 100px 50px 80px 50px;
7+
padding: 100px 50px 50px 50px;
88
color: #fff;
99
text-align: center;
10-
background: variables.$orange url("html-pattern.png") no-repeat 50% 50% / 728px auto;
10+
background: variables.$purple url("html-pattern.png") no-repeat 50% 50% / 728px auto;
1111
h2 {
12-
margin-bottom: 40px;
12+
margin-bottom: 20px;
1313
}
1414
.bills {
15+
max-width: 780px;
16+
margin: 0 auto;
17+
1518
p {
16-
margin-bottom: 20px;
17-
font-size: 20px;
19+
margin-bottom: 12px;
20+
font-size: 18px;
21+
1822
strong {
19-
display: block;
20-
font-size: 40px;
21-
line-height: 40px;
22-
font-weight: 900;
23+
display: inline-block;
24+
margin-right: 8px;
25+
font-size: 24px;
26+
line-height: 28px;
27+
font-weight: 800;
28+
}
29+
}
30+
31+
.status {
32+
margin-top: 8px;
33+
font-weight: 700;
34+
35+
&--ok {
36+
color: #b6ffb6;
37+
}
38+
&--expired {
39+
color: #ffd6d6;
2340
}
2441
}
2542
}

app/assets/stylesheets/general/general.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,24 @@ h4 {
345345
opacity: 0.5;
346346
}
347347

348+
/* Test Form Conditional Display */
349+
.hidden {
350+
display: none !important;
351+
}
352+
353+
.info-box {
354+
background-color: variables.$gray-light;
355+
border: 1px solid variables.$gray;
356+
border-radius: 4px;
357+
padding: 16px;
358+
margin: 8px 0;
359+
360+
p {
361+
margin: 0 0 8px 0;
362+
363+
&:last-child {
364+
margin-bottom: 0;
365+
}
366+
}
367+
}
368+

app/assets/stylesheets/general/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $green: #48A23F;
1414
$orange: #FF6E00;
1515
$grey: #A7A8AA;
1616
$red: #df0a0a;
17+
$purple: #7d35a1;
1718

1819
//## Gray and brand colors for use across Bootstrap.
1920
$gray-base: #000 !default;

app/assets/stylesheets/views/test_question.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
border-color: #28a745;
3737
}
3838

39-
.question-nav-circle.correct {
39+
.question-nav-circle.correct, .question-nav-circle.passed {
4040
background: #28a745;
4141
color: white;
4242
}
4343

44-
.question-nav-circle.incorrect {
44+
.question-nav-circle.incorrect, .question-nav-circle.failed {
4545
background: #dc3545;
4646
color: white;
4747
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class Admin::PracticalTaskResultsController < Admin::BaseController
2+
before_action :set_test
3+
before_action :set_practical_task, only: %i[index show]
4+
before_action :set_practical_task_result, only: %i[show update]
5+
6+
def index
7+
@practical_task_results = @practical_task.practical_task_results
8+
.includes(:test_attempt, :user)
9+
.order(created_at: :desc)
10+
11+
@pagy, @practical_task_results = pagy(@practical_task_results, limit: session[:page_size], page: @page)
12+
end
13+
14+
def show
15+
@test_attempt = @practical_task_result.test_attempt
16+
@user = @test_attempt.user
17+
end
18+
19+
def update
20+
if @practical_task_result.update(practical_task_result_params)
21+
redirect_to admin_test_practical_task_practical_task_result_path(@test, @practical_task, @practical_task_result),
22+
notice: t('admin.practical_task_results.updated')
23+
else
24+
render :show, status: :unprocessable_entity
25+
end
26+
end
27+
28+
private
29+
30+
def set_test
31+
@test = Test.friendly.find(params[:test_id])
32+
end
33+
34+
def set_practical_task
35+
@practical_task = @test.practical_tasks.find(params[:practical_task_id])
36+
end
37+
38+
def set_practical_task_result
39+
@practical_task_result = @practical_task.practical_task_results.find(params[:id])
40+
end
41+
42+
def practical_task_result_params
43+
params.require(:practical_task_result).permit(:status, :score, :feedback, :response_data)
44+
end
45+
end
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
class Admin::PracticalTasksController < Admin::BaseController
2+
before_action :set_test
3+
before_action :set_practical_task, only: %i[show edit update destroy activate deactivate]
4+
5+
def show
6+
end
7+
8+
def new
9+
@practical_task = @test.practical_tasks.build
10+
end
11+
12+
def create
13+
@practical_task = @test.practical_tasks.build(practical_task_params)
14+
@practical_task.display_order = @test.practical_tasks.maximum(:display_order).to_i + 1
15+
16+
respond_to do |format|
17+
if @practical_task.save
18+
format.html { redirect_to admin_test_path(@test), notice: t('admin.practical_tasks.created') }
19+
else
20+
flash[:alert] = @practical_task.errors.full_messages.join(', ')
21+
format.html { redirect_back_or_to root_path }
22+
format.turbo_stream {
23+
render turbo_stream: turbo_stream.update_all('.dialog_flash', partial: 'common/dialog_flash')
24+
}
25+
end
26+
end
27+
end
28+
29+
def edit
30+
end
31+
32+
def update
33+
respond_to do |format|
34+
if @practical_task.update(practical_task_params)
35+
format.html { redirect_to admin_test_path(@test), notice: t('admin.practical_tasks.updated') }
36+
else
37+
flash[:alert] = @practical_task.errors.full_messages.join(', ')
38+
format.html { redirect_back_or_to root_path }
39+
format.turbo_stream {
40+
render turbo_stream: turbo_stream.update_all('.dialog_flash', partial: 'common/dialog_flash')
41+
}
42+
end
43+
end
44+
end
45+
46+
def destroy
47+
@practical_task.destroy
48+
redirect_to admin_test_path(@test), notice: t('admin.practical_tasks.destroyed')
49+
end
50+
51+
def activate
52+
@practical_task.update!(active: true)
53+
redirect_to admin_test_practical_task_path(@test, @practical_task), notice: t('admin.practical_tasks.activated')
54+
end
55+
56+
def deactivate
57+
@practical_task.update!(active: false)
58+
redirect_to admin_test_practical_task_path(@test, @practical_task), notice: t('admin.practical_tasks.deactivated')
59+
end
60+
61+
private
62+
63+
def set_test
64+
@test = Test.friendly.find(params[:test_id])
65+
end
66+
67+
def set_practical_task
68+
@practical_task = @test.practical_tasks.find(params[:id])
69+
end
70+
71+
def practical_task_params
72+
params.require(:practical_task).permit(
73+
:title_et, :title_en, :body_et, :body_en,
74+
:validator, :display_order, :active
75+
)
76+
end
77+
end

app/controllers/admin/questions_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ def set_question
9696

9797
def question_params
9898
params.require(:question).permit(
99-
:text_et, :text_en, :help_text_et, :help_text_en,
100-
:question_type, :active,
101-
:practical_task_data,
99+
:text_et, :text_en, :help_text_et, :help_text_en, :active,
102100
answers_attributes: %i[id text_et text_en display_order correct _destroy]
103101
)
104102
end

0 commit comments

Comments
 (0)