esoe
4 days ago
17 changed files with 437 additions and 23 deletions
@ -0,0 +1,37 @@ |
|||||||
|
package gsp.technologies.main.core.answer; |
||||||
|
|
||||||
|
import org.hibernate.annotations.OnDelete; |
||||||
|
import org.hibernate.annotations.OnDeleteAction; |
||||||
|
|
||||||
|
import gsp.technologies.main.core.question.QuestionEntity; |
||||||
|
import jakarta.persistence.Entity; |
||||||
|
import jakarta.persistence.FetchType; |
||||||
|
import jakarta.persistence.GeneratedValue; |
||||||
|
import jakarta.persistence.GenerationType; |
||||||
|
import jakarta.persistence.Id; |
||||||
|
import jakarta.persistence.JoinColumn; |
||||||
|
import jakarta.persistence.ManyToOne; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
|
||||||
|
@Data |
||||||
|
@AllArgsConstructor |
||||||
|
@NoArgsConstructor |
||||||
|
@Builder |
||||||
|
@Entity |
||||||
|
public class AnswerEntity { |
||||||
|
@Id |
||||||
|
@GeneratedValue(strategy=GenerationType.AUTO) |
||||||
|
private Long id; |
||||||
|
private String body; |
||||||
|
private Boolean correct; |
||||||
|
private String description; |
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER, optional = false) |
||||||
|
@JoinColumn(name = "question", referencedColumnName = "id") |
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE) |
||||||
|
private QuestionEntity question; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package gsp.technologies.main.core.answer; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||||
|
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
|
@Repository |
||||||
|
public interface AnswerRepository extends JpaRepository<AnswerEntity, Long> { |
||||||
|
|
||||||
|
Collection<AnswerEntity> findAllByQuestionId(Long qid); |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package gsp.technologies.main.core.answer; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class AnswerService { |
||||||
|
private final AnswerRepository repo; |
||||||
|
|
||||||
|
public AnswerService(AnswerRepository repository) { |
||||||
|
this.repo = repository; |
||||||
|
} |
||||||
|
|
||||||
|
public AnswerEntity save(AnswerEntity entity) { |
||||||
|
return repo.save(entity); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public Collection<AnswerEntity> findAllByQuestionId(Long qid) { |
||||||
|
return repo.findAllByQuestionId(qid); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,9 +1,13 @@ |
|||||||
package gsp.technologies.main.core.question; |
package gsp.technologies.main.core.question; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository; |
import org.springframework.data.jpa.repository.JpaRepository; |
||||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
@Repository |
@Repository |
||||||
public interface QuestionRepository extends JpaRepository<QuestionEntity, Long> { |
public interface QuestionRepository extends JpaRepository<QuestionEntity, Long> { |
||||||
|
|
||||||
|
Collection<QuestionEntity> findQuestionsByCourseId(Long id); |
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,23 @@ |
|||||||
|
package gsp.technologies.main.face.supplier; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
|
||||||
|
import gsp.technologies.main.core.answer.AnswerService; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(path = "/supplier") |
||||||
|
public class SupAnswerController { |
||||||
|
private static final Logger log = LoggerFactory.getLogger(SupAnswerController.class); |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private AnswerService answerService; |
||||||
|
|
||||||
|
public SupAnswerController(AnswerService answerService) { |
||||||
|
this.answerService = answerService; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
# Дефектоскопист. Разрушающий контроль |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
||||||
|
|
||||||
|
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus. |
@ -0,0 +1,34 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" |
||||||
|
xmlns:th="http://www.thymeleaf.org"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>exam-answers</title> |
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script> |
||||||
|
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script> |
||||||
|
</head> |
||||||
|
<header> |
||||||
|
<!-- Кнопки навигации --> |
||||||
|
<div th:insert="~{shards/navi :: supplier}"></div> |
||||||
|
</header> |
||||||
|
|
||||||
|
<body> |
||||||
|
<!-- Курс --> |
||||||
|
<!-- Вопрос --> |
||||||
|
<div th:insert="~{shards/answers :: info(question=${question})}"></div> |
||||||
|
<!-- Добавить ответ --> |
||||||
|
<div th:insert="~{shards/answers :: create(question=${question})}"></div> |
||||||
|
|
||||||
|
<!-- Список ответов --> |
||||||
|
<ul> |
||||||
|
<li th:each="answer : ${answers}"> |
||||||
|
<div th:insert="~{shards/answers :: answer(answer=${answer})}"></div> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
</body> |
||||||
|
|
||||||
|
<footer> |
||||||
|
<div th:insert="~{shards/footer :: copy}"></div> |
||||||
|
</footer> |
||||||
|
</html> |
@ -0,0 +1,98 @@ |
|||||||
|
<!-- Коллекция фрагментов для построения страницы организаций --> |
||||||
|
<!DOCTYPE html> |
||||||
|
<html xmlns:th="http://www.thymeleaf.org"> |
||||||
|
|
||||||
|
<body> |
||||||
|
<div th:fragment="info(question)"> |
||||||
|
<hr> |
||||||
|
<h2>Курс: <span th:text="${question.course.name}"></span></h2> |
||||||
|
<h2>Вопрос: <span th:text="${question.body}"></span></h2> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Единичный ответ --> |
||||||
|
<div th:fragment="answer(answer)"> |
||||||
|
<hr> |
||||||
|
<h2>Ответ:</h2> |
||||||
|
<p th:text="${answer.body}"></p> |
||||||
|
<p>----------------</p> |
||||||
|
<p><b>Статус ответа: </b><span th:text="${answer.correct}"></span></p> |
||||||
|
<p>----------------</p> |
||||||
|
<p><b>Пояснения к ответу: </b><span th:text="${answer.description}"></span></p> |
||||||
|
<!-- редактировать --> |
||||||
|
<!-- удалить --> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Добавление нового ответа --> |
||||||
|
<div th:fragment="create"> |
||||||
|
<hr> |
||||||
|
<h2>Добавление нового ответа:</h2> |
||||||
|
<form th:action="@{/supplier/courses/{id}/questions/{qid}/answers(id=${question.course.id}, qid=${question.id})}" th:method="post"> |
||||||
|
<label for="body">Содержание ответа: </label> |
||||||
|
<br> |
||||||
|
<textarea rows="5" cols="66" id="body" name="body" placeholder="введите текст ответа тут..." required></textarea> |
||||||
|
<br> |
||||||
|
<p><input type="checkbox" name="correct" value="true"> Верный ответ</p> |
||||||
|
<label for="description">Обоснование верного ответа, ссылки на источники:</label> |
||||||
|
<br> |
||||||
|
<textarea rows="5" cols="66" id="description" name="description" placeholder="укажите пояснения к ответу тут ..." ></textarea> |
||||||
|
<br> |
||||||
|
<br> |
||||||
|
<input type="submit" value="Добавить"> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
|
||||||
|
<!-- Смена текущего курса --> |
||||||
|
<!-- <div th:fragment="course-select(courses)"> |
||||||
|
<hr> |
||||||
|
<label for="course-select"><b>Сменить текущий курс: </b></label> |
||||||
|
<select id="course-select" name="courseid"> |
||||||
|
<option value="0" disabled selected>курс</option> |
||||||
|
<option th:each="option : ${courses}" th:value="${option.id}" th:text="${option.name}"></option> |
||||||
|
</select> |
||||||
|
<br> |
||||||
|
</div> --> |
||||||
|
|
||||||
|
<!-- Перечень вопросов --> |
||||||
|
<!-- <div th:fragment="list(questions)"> |
||||||
|
<hr> |
||||||
|
<h2>Список вопросов:</h2> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>Название курса</th> |
||||||
|
<th>Содержание вопроса</th> |
||||||
|
<th>Действия</th> |
||||||
|
<th>Ответы</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr th:each="question : ${questions}"> |
||||||
|
<td th:text="${question.course.name}"></td> |
||||||
|
<td th:text="${question.body}"></td> |
||||||
|
<td> |
||||||
|
<a th:href="@{/supplier/courses/{id}/questions/{qid}/delete(id=${question.course.id}, qid=${question.id})}">Удалить вопрос</a> |
||||||
|
<a th:href="@{/supplier/courses/{id}/questions/{qid}/answers(id=${question.course.id}, qid=${question.id})}">Добавить ответ</a> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> --> |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Редактирование организации --> |
||||||
|
<!-- <div th:fragment="edit(organization)"> |
||||||
|
<hr> |
||||||
|
<h2>Редактирование организации: <span th:text="${organization.name}"></span></h2> |
||||||
|
<form th:action="@{/supplier/organizations/{id}/edit(id=${organization.id})}" th:method="post"> |
||||||
|
<label for="name" >Название организации: </label> |
||||||
|
<input type="text" th:name="name" th:value="${organization.name}"> |
||||||
|
<br> |
||||||
|
<input type="submit" value="Сохранить"> |
||||||
|
</form> |
||||||
|
</div> --> |
||||||
|
</body> |
||||||
|
</html> |
Loading…
Reference in new issue