diff --git a/Gemfile.lock b/Gemfile.lock index 9cca8ef5d..3ebe264d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -313,6 +315,7 @@ PLATFORMS arm64-darwin-22 arm64-darwin-23 x64-mingw-ucrt + x86_64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/app/controllers/api/v1/assignments_controller.rb b/app/controllers/api/v1/assignments_controller.rb index fdaf9bc75..a5fefecc5 100644 --- a/app/controllers/api/v1/assignments_controller.rb +++ b/app/controllers/api/v1/assignments_controller.rb @@ -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]) @@ -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) diff --git a/config/database.yml b/config/database.yml index b9f5aa055..08f1c8948 100644 --- a/config/database.yml +++ b/config/database.yml @@ -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?') %> \ No newline at end of file + database: reimplementation_production + username: reimplementation + password: <%= ENV["REIMPLEMENTATION_DATABASE_PASSWORD"] %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 33df803e7..0e5b77f59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 @@ -62,6 +63,8 @@ end end + + resources :questionnaires do collection do post 'copy/:id', to: 'questionnaires#copy', as: 'copy' @@ -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' diff --git a/db/seeds.rb b/db/seeds.rb index b6de376f2..02ffe7a49 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,7 +10,7 @@ email: 'admin2@example.com', password: 'password123', full_name: 'admin admin', - institution_id: 1, + institution_id: inst_id, role_id: 1 ) diff --git a/docker-compose.yml b/docker-compose.yml index 85edfda55..dcb7c5838 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.1' services: app: @@ -6,7 +5,7 @@ services: 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" @@ -22,6 +21,7 @@ services: environment: MYSQL_USER: dev MYSQL_PASSWORD: expertiza + MYSQL_DATABASE: reimplementation_development MYSQL_ROOT_PASSWORD: expertiza ports: - "3307:3306"