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

adding course year to backend #225

Merged
merged 13 commits into from
Apr 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ public class CourseJson{

private Boolean isArchived;

public CourseJson(String name, String description, Boolean isArchived) {
private int courseYear;

public CourseJson(String name, String description, Boolean isArchived, int courseYear) {
this.name = name;
this.description = description;
this.isArchived = isArchived;
this.courseYear = courseYear;
}

public String getName() {
Expand All @@ -37,5 +40,13 @@ public Boolean getArchived() {
public void setArchived(Boolean isArchived) {
this.isArchived = isArchived;
}

public int getCourseYear() {
return courseYear;
}

public void setCourseYear(int courseYear) {
this.courseYear = courseYear;
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;
import jakarta.persistence.criteria.CriteriaBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze import lijkt overbodig


import java.time.OffsetDateTime;

Expand All @@ -18,6 +19,10 @@ public class CourseEntity {
@Column(name = "description", nullable=false)
private String description;

@Column(name = "course_year", nullable = true)
private int courseYear;


@Column(name = "created_at")
private OffsetDateTime createdAt;

Expand Down Expand Up @@ -71,6 +76,7 @@ public void setDescription(String description) {
}



public OffsetDateTime getCreatedAt() {
return createdAt;
}
Expand All @@ -86,4 +92,14 @@ public OffsetDateTime getArchivedAt() {
public void setArchivedAt(OffsetDateTime archivedAt) {
this.archivedAt = archivedAt;
}

public int getCourseYear() {
return courseYear;
}
public void setCourseYear(int courseYear){
this.courseYear = courseYear;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void testCheckJoinLink() throws Exception {

@Test
public void testCheckCourseJson() throws Exception {
CourseJson courseJson = new CourseJson("name", "description", null);
CourseJson courseJson = new CourseJson("name", "description", null,2023);
CheckResult<Void> result = courseUtil.checkCourseJson(courseJson, user, null);
assertEquals(HttpStatus.OK, result.getStatus());

Expand Down
12 changes: 6 additions & 6 deletions backend/database/populate_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ INSERT INTO users (name, surname, email, azure_id, role) VALUES
('Charlie', 'Davis', '[email protected]', 'token_5', 'teacher');

-- Inserting into `courses`
INSERT INTO courses (course_id,course_name, description) VALUES
(1,'Math 101', 'Introduction to Mathematics'),
(2,'Science 101', 'Basics of Scientific Method'),
(3,'History 101', 'World History Overview'),
(4,'Computer Science 101', 'Introduction to Computing'),
(5,'English 101', 'English Literature');
INSERT INTO courses (course_id,course_name, description, coures_year) VALUES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typfout, ik pas het aan

(1,'Math 101', 'Introduction to Mathematics',2023),
(2,'Science 101', 'Basics of Scientific Method',2023),
(3,'History 101', 'World History Overview',2023),
(4,'Computer Science 101', 'Introduction to Computing',2023),
(5,'English 101', 'English Literature',2023);

-- Inserting into `course_users`
-- Assume course_id and user_id start from 1 and match accordingly
Expand Down
1 change: 1 addition & 0 deletions backend/database/start_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CREATE TABLE courses (
course_id SERIAL PRIMARY KEY,
course_name VARCHAR(100) NOT NULL,
description TEXT,
course_year INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
archived_at TIMESTAMP WITH TIME ZONE DEFAULT NULL,
join_key TEXT
Expand Down