Skip to content
Open
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
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ GEM
racc (~> 1.4)
nokogiri (1.15.2-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.15.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.2-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
Expand Down Expand Up @@ -313,6 +315,7 @@ PLATFORMS
arm64-darwin-22
arm64-darwin-23
x64-mingw-ucrt
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down
25 changes: 23 additions & 2 deletions app/controllers/api/v1/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@ class Api::V1::AssignmentsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :not_found

# GET /api/v1/assignments
# def index
# assignments = Assignment.all
# render json: assignments
# end

def index
assignments = Assignment.all
if params[:course_id]
assignments = Assignment.where(course_id: params[:course_id])
else
assignments = Assignment.all
end
render json: assignments
end

def index_by_course
course = Course.find_by(id: params[:course_id])
if course
assignments = course.assignments.select(:id, :name, :created_at, :updated_at)
render json: { data: assignments }, status: :ok
else
render json: { error: "Course not found" }, status: :not_found
end
end


# GET /api/v1/assignments/:id
def show
assignment = Assignment.find(params[:id])
Expand Down Expand Up @@ -213,8 +233,9 @@ def varying_rubrics_by_round?
private
# Only allow a list of trusted parameters through.
def assignment_params
params.require(:assignment).permit(:title, :description)
params.require(:assignment).permit(:title, :description, :instructor_id, :course_id)
end


# Helper method to determine staggered_and_no_topic for the assignment
def get_staggered_and_no_topic(assignment)
Expand Down
47 changes: 43 additions & 4 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
# MySQL. Versions 5.5.8 and up are supported.
#
# Install the MySQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem "mysql2"
#
# And be sure to use new-style password hashing:
# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
#
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: dev
password: expertiza
host: db
port: 3306
socket: /var/run/mysqld/mysqld.sock


development:
<<: *default
url: <%= ENV['DATABASE_URL'].gsub('?', '_development?') %>
database: reimplementation_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
url: <%= ENV['DATABASE_URL'].gsub('?', '_test?') %>
database: reimplementation_test

# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
# the values provided in this file. Alternatively, you can specify a connection
# URL environment variable explicitly:
#
# production:
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
#
production:
<<: *default
url: <%= ENV['DATABASE_URL'].gsub('?', '_production?') %>
database: reimplementation_production
username: reimplementation
password: <%= ENV["REIMPLEMENTATION_DATABASE_PASSWORD"] %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Defines the root path route ("/")
# root "articles#index"
post '/login', to: 'authentication#login'
root 'home#index'
namespace :api do
namespace :v1 do
resources :institutions
Expand Down Expand Up @@ -62,6 +63,8 @@
end
end



resources :questionnaires do
collection do
post 'copy/:id', to: 'questionnaires#copy', as: 'copy'
Expand Down Expand Up @@ -112,6 +115,7 @@

resources :participants do
collection do
get '/student_tasks', to: 'participants#student_tasks'
get '/user/:user_id', to: 'participants#list_user_participants'
get '/assignment/:assignment_id', to: 'participants#list_assignment_participants'
get '/:id', to: 'participants#show'
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
email: '[email protected]',
password: 'password123',
full_name: 'admin admin',
institution_id: 1,
institution_id: inst_id,
role_id: 1
)

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
version: '3.1'

services:
app:
build: .
command: tail -f /dev/null
environment:
RAILS_ENV: development
DATABASE_URL: mysql2://root:expertiza@db:3306/reimplementation?
DATABASE_URL: mysql2://dev:expertiza@db:3306/reimplementation_development
CACHE_STORE: redis://redis:6380/0
ports:
- "3002:3002"
Expand All @@ -22,6 +21,7 @@ services:
environment:
MYSQL_USER: dev
MYSQL_PASSWORD: expertiza
MYSQL_DATABASE: reimplementation_development
MYSQL_ROOT_PASSWORD: expertiza
ports:
- "3307:3306"
Expand Down