Skip to content
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

Seed all questions in the survey #49

Merged
merged 7 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rails_root/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ gem 'jbuilder'
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[windows jruby]
gem 'tzinfo-data'#, platforms: %i[windows jruby]

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
Expand Down
17 changes: 2 additions & 15 deletions rails_root/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.0)
nokogiri (1.16.2-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
Expand Down Expand Up @@ -304,8 +298,6 @@ GEM
sorbet (0.5.11284)
sorbet-static (= 0.5.11284)
sorbet-runtime (0.5.11284)
sorbet-static (0.5.11284-aarch64-linux)
sorbet-static (0.5.11284-universal-darwin)
sorbet-static (0.5.11284-x86_64-linux)
sorbet-static-and-runtime (0.5.11284)
sorbet (= 0.5.11284)
Expand All @@ -322,9 +314,6 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.7.2-aarch64-linux)
sqlite3 (1.7.2-arm64-darwin)
sqlite3 (1.7.2-x86_64-darwin)
sqlite3 (1.7.2-x86_64-linux)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
Expand All @@ -350,6 +339,8 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2024.1)
tzinfo (>= 1.0.0)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
Expand All @@ -370,10 +361,6 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
aarch64-linux
arm64-darwin
universal-darwin
x86_64-darwin
x86_64-linux

DEPENDENCIES
Expand Down
15 changes: 14 additions & 1 deletion rails_root/app/controllers/survey_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,21 @@ def set_survey_sections
prompt: 'To what extent do you agree the following behaviors reflect your personal leadership behaviors?'
},
{
title: 'Part 2: Leadership Behavior - Interpersonal',
title: 'Part 1: Leadership Behavior - Interpersonal',
prompt: 'To what extent do you agree the following behaviors reflect your personal leadership behaviors?'
},
{
title: 'Part 2. External Forces',
prompt: 'To what extent do you believe your board or immediate superior agrees to the importance of the following?'
},
{
title: 'Part 3. Organizational Structure',
prompt: 'To what extent do you agree the following characteristics apply to your organization?'
},
{
title: 'Part 4. Values, Attitudes, and Beliefs',
prompt: '#84-91. To what extent do you agree the following characteristics apply to you as the leader? #92-96. To what extent do you agree the following apply to your external community
(board, management, citizens)?'
}
]
end
Expand Down
16 changes: 11 additions & 5 deletions rails_root/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# MovieGenre.find_or_create_by!(name: genre_name)
# end

require 'json'

# seed data for the survey_profiles table

SurveyProfile.create!([
Expand All @@ -27,13 +29,17 @@
SurveyResponse.create!(profile: survey_profile, share_code: "debug#{survey_profile.user_id}")
end

question = SurveyQuestion.create!(text: 'Leads by Example', explanation: 'This is a placeholder.', section: 0)
SurveyQuestion.create!(text: 'Empowers Others', explanation: 'This is a placeholder.', section: 1)
SurveyQuestion.create!(text: 'Builds Relationships', explanation: 'This is a placeholder.', section: 2)
SurveyQuestion.create!(text: 'Communicates Effectively', explanation: 'This is a placeholder.', section: 3)

file_path = Rails.root.join('db', 'seeds', 'questionnaire.json')
data = JSON.parse(File.read(file_path))
data.each do |item|
SurveyQuestion.create!(text: item['text'], explanation: item['explanation'], section: item['section'])
end


SurveyResponse.all.each_with_index do |response, idx|
SurveyAnswer.create!(choice: idx, question:, response:)
SurveyAnswer.create!(choice: idx, question: SurveyQuestion.first, response: response)

end

# Path: csce606-ELRC-Synergistic-Leadership-Theory/rails_root/db/schema.rb
Expand Down
96 changes: 96 additions & 0 deletions rails_root/db/seeds/explanations

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions rails_root/db/seeds/q.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Paths to the files you want to open
file_path1 = 'questions'
file_path2 = 'explanations'
file_path3 = 'questionnaire.json'
with open(file_path3, 'w') as file:
file.write("[\n")

q_count = 1
q_threshold = [30,54,71,83]
with open(file_path1, 'r') as file1, open(file_path2, 'r') as file2, open(file_path3, 'a') as file3:
for line1, line2 in zip(file1, file2):
section = 0
for th in q_threshold:
if q_count>th:
section+=1
file3.write('\t{\n')
file3.write('\t\t\"text\": "'+line1[:-1]+'",\n')
file3.write('\t\t\"explanation\": "'+line2[:-1]+'",\n')
file3.write('\t\t\"section\": '+str(section)+'\n')
if q_count == 96:
file3.write('\t}\n')
else:
file3.write('\t},\n')

q_count+=1



with open(file_path3, 'a') as file:
file.write("]")
Loading
Loading