-
Notifications
You must be signed in to change notification settings - Fork 31
Adds Survey to Rate Challenges After Correct Flag Submission #224 #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sesheikholeslam
wants to merge
18
commits into
mitre-cyber-academy:master
Choose a base branch
from
sesheikholeslam:rate-challenges-after-submission-#224
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8a01042
Adds Survey to Rate Challenges After Correct Flag Submission
sesheikholeslam 3616561
Fix Unscoped Find Call
sesheikholeslam b28d472
Removed Redundent Semicolon
sesheikholeslam 33193ec
Adds Coverage Tests and Cleanup
sesheikholeslam c136e77
Enhancements and Integration Test
sesheikholeslam 5845440
Merge branch 'master' into rate-challenges-after-submission-#224
sesheikholeslam d1cb280
Merge branch 'master' into rate-challenges-after-submission-#224
camdenmoors fd5c689
Removing JavaScript dependency
camdenmoors 8d54afb
Removing JavaScript dependency
camdenmoors 22e3c7f
Removing JavaScript dependency
camdenmoors 5e2a687
Use faker for survey factories
camdenmoors 93e7218
Disable Cop AbcSize on challenge update
camdenmoors 9414eb4
Merge branch 'master' into rate-challenges-after-submission-#224
camdenmoors 3d37438
Merge branch 'rate-challenges-after-submission-#224' of https://githu…
camdenmoors 5ec3bc0
Sync progress to transfer
camdenmoors 6561cb9
Merge branch 'master' into rate-challenges-after-submission-#224
camdenmoors 54cef79
Show flag submission box on update when incorrect
camdenmoors 45a2187
Merge branch 'master' into rate-challenges-after-submission-#224
camdenmoors File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. | ||
|
||
function setRating(id, rating) { | ||
document.getElementById(id).value = rating; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Place all the styles related to the Surveys controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ | ||
|
||
.star-cb-group { | ||
/* remove inline-block whitespace */ | ||
font-size: 0; | ||
/* flip the order so we can use the + and ~ combinators */ | ||
unicode-bidi: bidi-override; | ||
direction: rtl; | ||
/* the hidden clearer */ | ||
} | ||
.star-cb-group * { | ||
font-size: 1rem; | ||
} | ||
.star-cb-group > input { | ||
display: none; | ||
} | ||
.star-cb-group > input + label { | ||
/* only enough room for the star */ | ||
display: inline-block; | ||
overflow: hidden; | ||
text-indent: 9999px; | ||
width: 1em; | ||
white-space: nowrap; | ||
cursor: pointer; | ||
} | ||
.star-cb-group > input + label:before { | ||
display: inline-block; | ||
text-indent: -9999px; | ||
content: "☆"; | ||
color: #888; | ||
} | ||
.star-cb-group > input:checked ~ label:before, .star-cb-group > input + label:hover ~ label:before, .star-cb-group > input + label:hover:before { | ||
content: "★"; | ||
color: rgb(238, 206, 24); | ||
text-shadow: 0 0 1px #333; | ||
} | ||
.star-cb-group > .star-cb-clear + label { | ||
text-indent: -9999px; | ||
width: .5em; | ||
margin-left: -.5em; | ||
} | ||
.star-cb-group > .star-cb-clear + label:before { | ||
width: .5em; | ||
} | ||
.star-cb-group:hover > input + label:before { | ||
content: "☆"; | ||
color: #888; | ||
text-shadow: none; | ||
} | ||
.star-cb-group:hover > input + label:hover ~ label:before, .star-cb-group:hover > input + label:hover:before { | ||
content: "★"; | ||
color: rgb(238, 206, 24); | ||
text-shadow: 0 0 1px #333; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SurveysController < ApplicationController | ||
def create | ||
@survey = Survey.new(survey_params) | ||
|
||
redirect_to '/game', notice: I18n.t('surveys.submitted') if @survey.save | ||
end | ||
|
||
private | ||
|
||
def survey_params | ||
params.require(:survey).permit(:difficulty, :realism, :interest, :comment, :submitted_flag_id) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
module SurveysHelper | ||
end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Survey < ApplicationRecord | ||
belongs_to :submitted_flag, optional: true | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
= form_for @survey, html: { class: "well form-inline", style: "margin-bottom:40px;" } do |f| | ||
- if @survey.errors.any? | ||
#error_explanation | ||
%h2= "#{pluralize(@survey.errors.count, "error")} prohibited this survey from being saved:" | ||
%ul | ||
- @survey.errors.full_messages.each do |message| | ||
%li= message | ||
|
||
%h3= t('surveys.new.header') | ||
|
||
.field | ||
= f.label :difficulty | ||
= render partial: "surveys/star_rating", locals: { | | ||
star_5: "rating_difficulty_5", | | ||
star_4: "rating_difficulty_4", | | ||
star_3: "rating_difficulty_3", | | ||
star_2: "rating_difficulty_2", | | ||
star_1: "rating_difficulty_1", | | ||
star_0: "rating_difficulty_0", | | ||
sesheikholeslam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
category: :difficulty, | | ||
f: f | | ||
} | | ||
= f.hidden_field :difficulty | ||
.field | ||
= f.label :realism | ||
= render partial: "surveys/star_rating", locals: { | | ||
star_5: "rating_realism_5", | | ||
star_4: "rating_realism_4", | | ||
star_3: "rating_realism_3", | | ||
star_2: "rating_realism_2", | | ||
star_1: "rating_realism_1", | | ||
star_0: "rating_realism_0", | | ||
category: :realism, | | ||
f: f | | ||
} | | ||
= f.hidden_field :realism | ||
.field | ||
= f.label :interest | ||
= render partial: "surveys/star_rating", locals: { | | ||
star_5: "rating_interest_5", | | ||
star_4: "rating_interest_4", | | ||
star_3: "rating_interest_3", | | ||
star_2: "rating_interest_2", | | ||
star_1: "rating_interest_1", | | ||
star_0: "rating_interest_0", | | ||
category: :interest, | | ||
f: f | | ||
} | | ||
= f.hidden_field :interest | ||
.field | ||
= f.label :comment | ||
= f.text_area :comment | ||
.field | ||
= f.hidden_field :submitted_flag_id | ||
.field | ||
= f.submit t('surveys.new.submit_btn'), class: "btn btn-primary" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%span.star-cb-group | ||
= f.radio_button category, 5, { :name => "#{category}", :id => "#{star_5}", :onclick => "setRating('survey_#{category}', '5')" } | ||
%label{:for => "#{star_5}"} 5 | ||
= f.radio_button category, 4, { :name => "#{category}", :id => "#{star_4}", :onclick => "setRating('survey_#{category}', '4')" } | ||
%label{:for => "#{star_4}"} 4 | ||
= f.radio_button category, 3, { :name => "#{category}", :id => "#{star_3}", :onclick => "setRating('survey_#{category}', '3')" } | ||
%label{:for => "#{star_3}"} 3 | ||
= f.radio_button category, 2, { :name => "#{category}", :id => "#{star_2}", :onclick => "setRating('survey_#{category}', '2')" } | ||
%label{:for => "#{star_2}"} 2 | ||
= f.radio_button category, 1, { :name => "#{category}", :id => "#{star_1}", :onclick => "setRating('survey_#{category}', '1')" } | ||
%label{:for => "#{star_1}"} 1 | ||
= f.radio_button category, 0, { :name => "#{category}", :id => "#{star_0}", :class => "star-cb-clear", :onclick => "setRating('survey_#{category}', '0')", :checked => true } | ||
%label{:for => "#{star_0}"} 0 | ||
sesheikholeslam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateSurveys < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :surveys do |t| | ||
t.integer :difficulty, default: 0, null: false | ||
t.integer :realism, default: 0, null: false | ||
t.integer :interest, default: 0, null: false | ||
t.text :comment, default: "", null: true | ||
t.integer :submitted_flag_id, null: false | ||
t.timestamps | ||
end | ||
add_foreign_key "surveys", "submitted_flags" | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.