Coder Social home page Coder Social logo

student_enrollments_ar's Introduction

Student Enrollments

Complex Queries

This repository is a reworking of the Complex Queries workshop that can be completed as SQL-only; this repository will ask the same questions but should be completed using ActiveRecord and models.

RSpec, Shoulda-Matchers, and SimpleCov have been set up for you.

This repository has been tested with Ruby 3.2.2 and Rails 7.1.2.

Setup

  1. bundle install
  2. rails db:{drop,create}

You will need to create all migrations.

Instructions

We are creating an application to track student enrollments in our school. To do this, we'll need to track Students, Courses, Teachers, and Enrollments.

Students have a name. Teachers have a name and room_number. Courses have a name and teacher_id. Enrollments have a student_id, class_id, and a grade (integer).

Courses have one Teacher. Students can be enrolled in many Courses. Courses have many Students. (The join table in this case can be called "enrollments".)

Data Setup

  • First, write migrations to fulfill the above model descriptions.
  • Then, write model tests to set up associations between each model. Make sure your model tests are always at 100% coverage.

User Stories

Note: these user stories are focused on writing AR queries. If you're still working on writing efficient AR, try writing in SQL first, then translate them to AR as you go. Remember to write model tests to prove the queries work correctly!

1. Student Show Page

As a user
When I visit a Student show page (/student/:id)
I see the name of the student
And I see the names of all Courses that this student enrolled in
As well as a numeric count of the number of Courses the student is currently enrolled in
And I see the average grade across all classes that this student is enrolled in. 
2. Teacher Index Page

As a user
When I visit the Teachers index page (/teachers)
I see a list of all teachers and their room number
And underneath each teacher's name I see a list of the students that are enrolled in their classes
And each student's name is a link to their specific show page. 
3. Student Show Page

As a user
When I visit a student show page (/student/:id)
At the bottom of the page I see a list of all teachers that this student has, based on class enrollment. 
4. Class Show Page

As a user
When I visit a class show page (/class/:id)
I see the average student grade for this class
And I see the names of all students whose grade is lower than the average for this class
And next to the students' names, I see their average grade for this class. 

(Ex: 
Average grade: 82.5
   Students below this average: 
      - John Smith: 81
      - Sally Field: 79
)

Extensions

  1. Refactor any queries used in user stories to only one query per story.

(Under construction)

student_enrollments_ar's People

Contributors

abdulredd avatar cjsim89 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.