Added courses and course entity pages.
This commit is contained in:
parent
16bf623a06
commit
d49419146a
|
@ -0,0 +1,23 @@
|
||||||
|
package nl.andrewlalis.teaching_assistant_assistant.controllers;
|
||||||
|
|
||||||
|
import nl.andrewlalis.teaching_assistant_assistant.model.repositories.CourseRepository;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class Courses {
|
||||||
|
|
||||||
|
private CourseRepository courseRepository;
|
||||||
|
|
||||||
|
protected Courses(CourseRepository courseRepository) {
|
||||||
|
this.courseRepository = courseRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/courses")
|
||||||
|
public String get(Model model) {
|
||||||
|
model.addAttribute("courses", courseRepository.findAll());
|
||||||
|
return "courses";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ package nl.andrewlalis.teaching_assistant_assistant.controllers;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class RootController {
|
public class RootController {
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package nl.andrewlalis.teaching_assistant_assistant.controllers.courses;
|
||||||
|
|
||||||
|
import nl.andrewlalis.teaching_assistant_assistant.model.Course;
|
||||||
|
import nl.andrewlalis.teaching_assistant_assistant.model.repositories.CourseRepository;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class Entity {
|
||||||
|
|
||||||
|
private CourseRepository courseRepository;
|
||||||
|
|
||||||
|
protected Entity(CourseRepository courseRepository) {
|
||||||
|
this.courseRepository = courseRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/courses/{id}")
|
||||||
|
public String get(@PathVariable Long id, Model model) {
|
||||||
|
Optional<Course> courseOptional = this.courseRepository.findById(id);
|
||||||
|
courseOptional.ifPresent(course -> model.addAttribute("course", course));
|
||||||
|
|
||||||
|
return "courses/entity";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -76,4 +76,27 @@ public class Course extends BasicEntity {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Getters and Setters
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TeachingAssistant> getTeachingAssistants() {
|
||||||
|
return teachingAssistants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Student> getStudents() {
|
||||||
|
return students;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Assignment> getAssignments() {
|
||||||
|
return assignments;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class AssignmentGrade extends BasicEntity {
|
||||||
fetch = FetchType.EAGER,
|
fetch = FetchType.EAGER,
|
||||||
orphanRemoval = true
|
orphanRemoval = true
|
||||||
)
|
)
|
||||||
@JoinColumn(name = "assignmentGrade_id")
|
@JoinColumn(name = "assignment_grade_id")
|
||||||
private List<SectionGrade> sectionGrades;
|
private List<SectionGrade> sectionGrades;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.*;
|
||||||
@Inheritance(
|
@Inheritance(
|
||||||
strategy = InheritanceType.JOINED
|
strategy = InheritanceType.JOINED
|
||||||
)
|
)
|
||||||
public abstract class Feedback extends BasicEntity {
|
public class Feedback extends BasicEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The graded section to which this feedback belongs.
|
* The graded section to which this feedback belongs.
|
||||||
|
@ -22,6 +22,7 @@ public abstract class Feedback extends BasicEntity {
|
||||||
)
|
)
|
||||||
private SectionGrade assignmentSection;
|
private SectionGrade assignmentSection;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String text;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class TeachingAssistant extends Person {
|
||||||
* The list of all feedback given by a teaching assistant.
|
* The list of all feedback given by a teaching assistant.
|
||||||
*/
|
*/
|
||||||
@OneToMany
|
@OneToMany
|
||||||
@JoinColumn(name = "teachingAssistant_id")
|
@JoinColumn(name = "teaching_assistant_id")
|
||||||
private List<SectionGrade> sectionGrades;
|
private List<SectionGrade> sectionGrades;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background-color: whitesmoke;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_bar {
|
||||||
|
background-color: green;
|
||||||
|
width: 100%;
|
||||||
|
color: whitesmoke;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_title {
|
||||||
|
margin-top: auto;
|
||||||
|
margin-bottom: auto;
|
||||||
|
padding: 10px;
|
||||||
|
width: 25%;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_link_list {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 75%;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_link_list li {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_link_list a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
background-color: darkgreen;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_link_list a:hover {
|
||||||
|
background-color: darkgray;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{layouts/basic_page :: layout (~{::title}, ~{::section})}">
|
||||||
|
<head>
|
||||||
|
<title>Courses</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Code</th>
|
||||||
|
</tr>
|
||||||
|
<tr th:each="course: ${courses}">
|
||||||
|
<td>
|
||||||
|
<a th:href="@{/courses/{id}(id=${course.getId()})}" th:text="${course.getName()}"></a>
|
||||||
|
</td>
|
||||||
|
<td th:text="${course.getCode()}"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:replace="~{layouts/basic_page :: layout (~{::title}, ~{::section})}">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title th:text="${course.getName()}"></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h1 th:text="${course.getName()}"></h1>
|
||||||
|
<h3 th:text="${course.getCode()}"></h3>
|
||||||
|
<h3>Created on: <span th:text="${course.getCreatedOn()}"></span></h3>
|
||||||
|
<h3>Id: <span th:text="${course.getId()}"></span></h3>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -2,21 +2,18 @@
|
||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Title</title>
|
<title>Teaching Assistant Assistant</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav th:fragment="header">
|
|
||||||
<ul>
|
<nav th:fragment="header" class="header_bar">
|
||||||
<li>
|
<link rel="stylesheet" href="../../../resources/static/css/header.css" th:href="@{/css/header.css}"/>
|
||||||
<a href="#" th:href="@{/}">Home</a>
|
<h1 class="header_title">Teaching Assistant Assistant</h1>
|
||||||
</li>
|
<ul class="header_link_list">
|
||||||
<li>
|
<li><a href="/" th:href="@{/}">Home</a>
|
||||||
<a href="#" th:href="@{/courses}">Courses</a>
|
<li><a href="/courses" th:href="@{/courses}">Courses</a>
|
||||||
</li>
|
<li><a href="/students" th:href="@{/students}">Students</a>
|
||||||
<li>
|
|
||||||
<a href="#" th:href="@{/students}">Students</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{layouts/basic_page :: layout (~{::title}, ~{::section})}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<title>Homepage</title>
|
||||||
<title>Title</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div th:replace="~{fragments/header :: header}"> </div>
|
<div th:replace="~{fragments/header :: header}"> </div>
|
||||||
|
|
||||||
<div>
|
<section>
|
||||||
<p>
|
<p>
|
||||||
Welcome to the home page.
|
Welcome to the home page.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" th:fragment="layout (title, content)" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title th:replace="${title}">basic_page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{fragments/header :: header}"> </div>
|
||||||
|
|
||||||
|
<div th:replace="${content}">
|
||||||
|
<p>
|
||||||
|
Basic page content block.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue