Compare commits
110 Commits
Author | SHA1 | Date |
---|---|---|
|
ab210babea | |
|
a1948252fd | |
|
4b87bf216c | |
|
eeef8c49f6 | |
|
4b27eceaa9 | |
|
a468cc8031 | |
|
50aaf3c131 | |
|
d690040b1d | |
|
d4204ba705 | |
|
900f8a70c2 | |
|
70678e2233 | |
|
30d5eb5dec | |
|
2971264e0a | |
![]() |
b48cb658d4 | |
![]() |
e11a52583f | |
|
0d9e21e2cf | |
|
32e767475c | |
|
18a8416820 | |
|
d55f5bd725 | |
![]() |
4de7f29290 | |
![]() |
2069792762 | |
|
9637e86a43 | |
|
3d2f6cc07f | |
![]() |
c3dcf6e656 | |
![]() |
c03d1da842 | |
|
b1eee19e95 | |
|
3107e7720c | |
|
9c3691e6bd | |
![]() |
cb4d85fd89 | |
![]() |
0d221aedba | |
|
f55a6c690a | |
|
88c5a9e9f3 | |
|
49e5bf13d9 | |
|
ece82d64cc | |
|
efdc612c84 | |
|
c1d0f977e2 | |
|
0dfe602ac7 | |
|
cd33d8d7a9 | |
|
1c6e435121 | |
![]() |
85c01c2502 | |
![]() |
7665ad4c68 | |
|
eafec9a32d | |
|
4c1a82a12e | |
![]() |
e91163f84c | |
![]() |
84819400d4 | |
![]() |
1b7cbaa01a | |
![]() |
28c5bbfabb | |
|
72a4570253 | |
|
ac3b209aa0 | |
|
1d6b848fcc | |
|
e98aa9cf82 | |
|
c6fa887390 | |
|
447e2cf322 | |
|
5a6053aa14 | |
|
3689a9a85d | |
![]() |
1586d6a929 | |
![]() |
cb385dee61 | |
![]() |
56b68c8eb6 | |
|
df5c8254d8 | |
![]() |
09e88feeb4 | |
![]() |
812a74447d | |
|
def718a76a | |
|
af1aa14d7d | |
![]() |
35eb2591ff | |
![]() |
3bf021aa3b | |
![]() |
1fd7f8315c | |
|
ca5f1f2765 | |
|
e51700eadd | |
|
07fc2f32fb | |
|
e532373dbd | |
|
4900fc9c6e | |
|
b93d25fb5b | |
|
6df997e287 | |
|
a4eef5628d | |
|
4320bebbc5 | |
|
f8d77069cc | |
![]() |
d5aad7ea5b | |
![]() |
6f13f312e7 | |
![]() |
6c25eea12f | |
![]() |
c8a4126fbb | |
![]() |
934d98d1e1 | |
![]() |
b36fa50cef | |
|
1c2c2eabb6 | |
![]() |
1edd16a29e | |
![]() |
e815b8ebc4 | |
|
4d59f6a42f | |
![]() |
e38aa097c1 | |
![]() |
84ac8ccc2b | |
![]() |
fa4d9a36fc | |
|
3d5c1a5b7b | |
|
c16c712676 | |
|
da039cf647 | |
|
cb7120973b | |
|
92097b2237 | |
|
35983aaa6d | |
|
b1a4945768 | |
|
4ab37abeab | |
|
d8c503bda7 | |
|
9eb166274a | |
![]() |
40eda6183e | |
![]() |
53377fb5fa | |
![]() |
48d6f7d267 | |
![]() |
737877b16c | |
![]() |
6bca27c3a3 | |
|
58ef09ea74 | |
![]() |
c7eba40e53 | |
![]() |
b9c9cfee6f | |
![]() |
f61eda3990 | |
![]() |
e1111196e0 | |
|
1ea31568c4 |
|
@ -22,6 +22,12 @@ public class PropertiesLoader {
|
|||
@Value("${application.secret}")
|
||||
private String secret;
|
||||
|
||||
@Value("${server.address}")
|
||||
private String serverAddress;
|
||||
|
||||
@Value("${server.port}")
|
||||
private String serverPort;
|
||||
|
||||
public void initUsosInstance() {
|
||||
RestAssured.baseURI = usosBaseURI;
|
||||
RestAssured.basePath = usosBasePath;
|
||||
|
@ -40,4 +46,11 @@ public class PropertiesLoader {
|
|||
return secret;
|
||||
}
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public String getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import studycave.studycaverestservice.model.studyGroup.CreateGroupDto;
|
|||
import studycave.studycaverestservice.model.studyGroup.GroupService;
|
||||
import studycave.studycaverestservice.model.studyGroup.dto.*;
|
||||
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMemberRepository;
|
||||
import studycave.studycaverestservice.model.user.User;
|
||||
import studycave.studycaverestservice.model.user.UserRepository;
|
||||
|
||||
@RestController
|
||||
|
@ -50,12 +51,12 @@ public class GroupController {
|
|||
}
|
||||
|
||||
@GetMapping("{group_id}/info")
|
||||
public GroupInfoDto getGroupInfo(@PathVariable(required = true) Long group_id) {
|
||||
public GroupInfoDto getGroupInfo(@PathVariable(required = true) Integer group_id) {
|
||||
return this.groupService.getGroupInfo(group_id);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{group_id}/member/{user_id}")
|
||||
public ResponseEntity deleteUserFromGroup(@PathVariable(required = true) Long group_id,
|
||||
public ResponseEntity deleteUserFromGroup(@PathVariable(required = true) Integer group_id,
|
||||
@PathVariable(required = true) Long user_id) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String currentPrincipalName = authentication.getName();
|
||||
|
@ -67,12 +68,12 @@ public class GroupController {
|
|||
}
|
||||
|
||||
@DeleteMapping("/{group_id}")
|
||||
public ResponseEntity deleteGroup(@PathVariable(required = true) Long group_id) {
|
||||
public ResponseEntity deleteGroup(@PathVariable(required = true) Integer group_id) {
|
||||
return this.groupService.deleteGroup(group_id);
|
||||
}
|
||||
|
||||
@GetMapping("/{group_id}/generate")
|
||||
public ResponseEntity generateCode(@PathVariable(required = true) Long group_id) {
|
||||
public ResponseEntity generateCode(@PathVariable(required = true) Integer group_id) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String currentPrincipalName = authentication.getName();
|
||||
Long id = userRepository.findByUsername(currentPrincipalName).get().getId();
|
||||
|
@ -99,12 +100,15 @@ public class GroupController {
|
|||
}
|
||||
|
||||
@GetMapping("/{group_id}/content/{type}")
|
||||
public ResponseEntity<?> getContent(@PathVariable(required = true) Long group_id, @PathVariable(required = true) String type) {
|
||||
return this.groupService.getContent(group_id,type);
|
||||
public ResponseEntity<?> getContent(@PathVariable(required = true) Integer group_id, @PathVariable(required = true) String type) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String currentPrincipalName = authentication.getName();
|
||||
Optional<User> user = userRepository.findByUsername(currentPrincipalName);
|
||||
return this.groupService.getContent(group_id,type, user.get());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{group_id}/content/{type}/{content_id}")
|
||||
public ResponseEntity<?> deleteContent(@PathVariable(required = true) Long group_id, @PathVariable(required = true) String type, @PathVariable(required = true) Long content_id) {
|
||||
public ResponseEntity<?> deleteContent(@PathVariable(required = true) Integer group_id, @PathVariable(required = true) String type, @PathVariable(required = true) Long content_id) {
|
||||
return this.groupService.deleteContent(group_id, type, content_id);
|
||||
}
|
||||
|
||||
|
@ -127,6 +131,12 @@ public class GroupController {
|
|||
return this.groupService.addTests(groupId, testIds);
|
||||
}
|
||||
|
||||
@PutMapping("/{groupId}/tests")
|
||||
public ResponseEntity<?> editTests(@PathVariable(required = true) String groupId,
|
||||
@RequestBody List<AddTestDto> testIds) {
|
||||
return this.groupService.editTests(groupId, testIds);
|
||||
}
|
||||
|
||||
@PutMapping("/{groupId}/tests/{testId}/status")
|
||||
public ResponseEntity<?> verifyTest(@PathVariable(required = true) String groupId,
|
||||
@PathVariable(required = true) String testId, @Valid @RequestBody VerifyDto dto) {
|
||||
|
@ -155,7 +165,7 @@ public class GroupController {
|
|||
}
|
||||
|
||||
@GetMapping("/{groupId}/content/{type}/unverified")
|
||||
public ResponseEntity<?> getUnverifiedContent(@PathVariable(required = true) Long groupId,
|
||||
public ResponseEntity<?> getUnverifiedContent(@PathVariable(required = true) Integer groupId,
|
||||
@PathVariable(required = true) String type) {
|
||||
return this.groupService.getUnverifiedContent(groupId, type);
|
||||
}
|
||||
|
@ -178,12 +188,24 @@ public class GroupController {
|
|||
}
|
||||
|
||||
@GetMapping("/{group_id}/leaderboard")
|
||||
public ResponseEntity<?> getGroupLeaderboard(@PathVariable(required = true) Long group_id) {
|
||||
public ResponseEntity<?> getGroupLeaderboard(@PathVariable(required = true) Integer group_id) {
|
||||
return this.groupService.getGroupLeaderboard(group_id);
|
||||
}
|
||||
|
||||
@GetMapping("/{group_id}/testleaderboard")
|
||||
public ResponseEntity<?> getGroupTestLeaderboard(@PathVariable(required = true) Long group_id) {
|
||||
public ResponseEntity<?> getGroupTestLeaderboard(@PathVariable(required = true) Integer group_id) {
|
||||
return this.groupService.getGroupTestLeaderboard(group_id);
|
||||
}
|
||||
|
||||
@GetMapping("/{groupId}/tests")
|
||||
public ResponseEntity<?> listTestsInGroup(@PathVariable Integer groupId) {
|
||||
return groupService.getGroupTests(groupId);
|
||||
}
|
||||
|
||||
@GetMapping("/{groupId}/tests/{testId}/results")
|
||||
public ResponseEntity<?> listTestsResultsInGroup(@PathVariable Integer groupId, @PathVariable Long testId) {
|
||||
return groupService.getGroupTestsWithResults(groupId, testId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -301,14 +300,14 @@ public class SetController {
|
|||
return new ResponseEntity<>(new String("User not found"), HttpStatus.NOT_FOUND);
|
||||
|
||||
ArrayList<SimpleSetDTO> setDTOs = new ArrayList<SimpleSetDTO>();
|
||||
List<SimpleSet> sets = simpleSetRepository.findByOptionalPermissionAndOptionalOwner(permission, ownerId);
|
||||
List<SimpleSet> sets = simpleSetRepository.findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(permission, ownerId);
|
||||
|
||||
for (SimpleSet set : sets) {
|
||||
String username = userRepository.findById((long) set.getIdOwner()).get().getUsername();
|
||||
SimpleSetDTO setDTO = modelMapper.map(set, SimpleSetDTO.class);
|
||||
setDTO.setOwner(username);
|
||||
if(set.getGroupId() != null)
|
||||
setDTO.setGroup(groupRepository.findById((long)set.getGroupId()).orElse(null).getName());
|
||||
setDTO.setGroup(groupRepository.findById(set.getGroupId()).orElse(null).getName());
|
||||
setDTOs.add(setDTO);
|
||||
}
|
||||
return new ResponseEntity<List<SimpleSetDTO>>(setDTOs, HttpStatus.OK);
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package studycave.studycaverestservice.controller;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,6 +28,8 @@ import studycave.studycaverestservice.model.simpleTest.SimpleTest;
|
|||
import studycave.studycaverestservice.model.simpleTest.SimpleTestRepository;
|
||||
import studycave.studycaverestservice.model.simpleTest.dto.SimpleTestDTO;
|
||||
import studycave.studycaverestservice.model.studyGroup.GroupRepository;
|
||||
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
|
||||
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMember;
|
||||
import studycave.studycaverestservice.model.test.Test;
|
||||
import studycave.studycaverestservice.model.test.TestRepository;
|
||||
import studycave.studycaverestservice.model.test.dto.*;
|
||||
|
@ -40,6 +39,8 @@ import studycave.studycaverestservice.model.test.result.TestResultRepository;
|
|||
import studycave.studycaverestservice.model.test.verifier.QuestionVerifier;
|
||||
import studycave.studycaverestservice.model.user.User;
|
||||
import studycave.studycaverestservice.model.user.UserRepository;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivity;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivityRepository;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivityService;
|
||||
import studycave.studycaverestservice.model.userBadge.UserBadge;
|
||||
import studycave.studycaverestservice.model.userBadge.UserBadgeRepository;
|
||||
|
@ -74,27 +75,68 @@ public class TestController {
|
|||
TestResultRepository testResultRepository;
|
||||
@Autowired
|
||||
UserActivityService userActivityService;
|
||||
@Autowired
|
||||
private UserActivityRepository userActivityRepository;
|
||||
|
||||
Random generator = new Random();
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Optional<Test> getTest(@PathVariable(required = true) Long id) {
|
||||
Optional<Test> test = testRepository.findById(id);
|
||||
for (Question question : test.get().getQuestions()) {
|
||||
Test testToReturn = test.get();
|
||||
for (Question question : testToReturn.getQuestions()) {
|
||||
if(question instanceof QuestionGaps) {
|
||||
List<AnswerGaps> answers = ((QuestionGaps)question).getAnswers();
|
||||
Collections.sort(answers,
|
||||
(o1, o2) -> o1.getId().compareTo(o2.getId()));
|
||||
}
|
||||
}
|
||||
test.get().setGroup(null);
|
||||
test.get().setActivity(null);
|
||||
|
||||
for (Question question : testToReturn.getQuestions()) {
|
||||
if (question.getHelp()){
|
||||
if (question instanceof QuestionChoices){
|
||||
QuestionChoices questionChoices = (QuestionChoices) question;
|
||||
List<AnswerChoices> answers = questionChoices.getAnswers();
|
||||
if (answers.size() > 2) {
|
||||
for (AnswerChoices answerChoices : answers){
|
||||
if (answerChoices.getGood()) {
|
||||
questionChoices.getAnswers_help().add(answerChoices);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (answers.size() % 2 == 0 && questionChoices.getAnswers_help().size() == 1){
|
||||
while (questionChoices.getAnswers_help().size() < answers.size() / 2){
|
||||
AnswerChoices answerChoices = answers.get(generator.nextInt(answers.size()));
|
||||
if (!answerChoices.getGood() && !questionChoices.getAnswers_help().contains(answerChoices))
|
||||
questionChoices.getAnswers_help().add(answerChoices);
|
||||
}
|
||||
}
|
||||
else if (questionChoices.getAnswers_help().size() == 1){
|
||||
while (questionChoices.getAnswers_help().size() < (answers.size() / 2) + 1){
|
||||
AnswerChoices answerChoices = answers.get(generator.nextInt(answers.size()));
|
||||
if (!answerChoices.getGood() && !questionChoices.getAnswers_help().contains(answerChoices))
|
||||
questionChoices.getAnswers_help().add(answerChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
testToReturn.setGroup(null);
|
||||
testToReturn.setActivity(null);
|
||||
return test;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/solve")
|
||||
public TestOwnerDTO getTestToSolve(@PathVariable(required = true) Long id) {
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
User userAuth = userRepository.findByUsername(authentication.getName()).get();
|
||||
|
||||
Optional<Test> test = testRepository.findById(id);
|
||||
|
||||
|
||||
|
||||
for (Question question : test.get().getQuestions()) {
|
||||
if (question.getType().equals("true-false") || question.getType().equals("single-choice")
|
||||
|| question.getType().equals("multiple-choice")) {
|
||||
|
@ -103,6 +145,38 @@ public class TestController {
|
|||
AnswerChoicesSolveDTO answerDTO = modelMapper.map(answer, AnswerChoicesSolveDTO.class);
|
||||
answersDTOs.add(answerDTO);
|
||||
}
|
||||
List<AnswerChoices> helpers = new ArrayList<>();
|
||||
if (question.getType().equals("single-choice")) {
|
||||
if (question.getHelp()){
|
||||
List<AnswerChoices> answers = answersDTOs;
|
||||
if (answers.size() > 2) {
|
||||
for (AnswerChoices answerChoices : answers){
|
||||
if (answerChoices.getGood()) {
|
||||
helpers.add(answerChoices);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (answers.size() % 2 == 0 && helpers.size() == 1){
|
||||
while (helpers.size() < answers.size() / 2){
|
||||
AnswerChoices answerChoices = answers.get(generator.nextInt(answers.size()));
|
||||
if (!answerChoices.getGood() && !helpers.contains(answerChoices))
|
||||
helpers.add(answerChoices);
|
||||
}
|
||||
}
|
||||
else if (helpers.size() == 1){
|
||||
while (helpers.size() < (answers.size() / 2) + 1){
|
||||
AnswerChoices answerChoices = answers.get(generator.nextInt(answers.size()));
|
||||
if (!answerChoices.getGood() && !helpers.contains(answerChoices))
|
||||
helpers.add(answerChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (helpers.size() > 0) {
|
||||
((QuestionChoices) question).setAnswers_help(helpers);
|
||||
}
|
||||
((QuestionChoices) question).setAnswers(answersDTOs);
|
||||
}
|
||||
if (question.getType().equals("puzzle")) {
|
||||
|
@ -143,9 +217,40 @@ public class TestController {
|
|||
((QuestionPairs) question).setAnswers(answersDTOs);
|
||||
}
|
||||
}
|
||||
|
||||
User user = userRepository.findById(test.get().getIdOwner()).get();
|
||||
TestOwnerDTO testDTO = modelMapper.map(test.get(), TestOwnerDTO.class);
|
||||
testDTO.setOwner(user.getUsername());
|
||||
if (test.get().getPermission().equals("GROUP")) {
|
||||
testDTO.setDateFrom(test.get().getAvailableFrom());
|
||||
testDTO.setDateTo(test.get().getAvailableTo());
|
||||
List<StudyGroupMember> groupUsers = test.get().getGroup().getMembers();
|
||||
for (StudyGroupMember studyGroupMember : groupUsers) {
|
||||
if (studyGroupMember.getIsGroupLeader()) {
|
||||
if (studyGroupMember.getUser().equals(userAuth)) {
|
||||
testDTO.setIsGroupOwner(true);
|
||||
testDTO.setAttempted(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (testDTO.getAttempted() == null) {
|
||||
for (StudyGroupMember studyGroupMember : groupUsers) {
|
||||
if (studyGroupMember.getUser().equals(userAuth)){
|
||||
List<UserActivity> userActivities = userActivityRepository.findAllByTestAndToUser(test.get(), userAuth);
|
||||
for (UserActivity userActivity : userActivities){
|
||||
if (userActivity.getType().equals("solvedTest")){
|
||||
testDTO.setAttempted(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (testDTO.getAttempted() == null){
|
||||
testDTO.setAttempted(false);
|
||||
}
|
||||
|
||||
return testDTO;
|
||||
}
|
||||
|
@ -291,13 +396,28 @@ public class TestController {
|
|||
|
||||
ArrayList<SimpleTestDTO> testDTOs = new ArrayList<SimpleTestDTO>();
|
||||
|
||||
List<SimpleTest> tests = simpleTestRepository.findByOptionalPermissionAndOptionalOwner(permission, ownerId);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String currentPrincipalName = authentication.getName();
|
||||
Optional<User> userCheck = userRepository.findByUsername(currentPrincipalName);
|
||||
User usersTests = null;
|
||||
if (userCheck.isPresent())
|
||||
usersTests = userCheck.get();
|
||||
|
||||
List<SimpleTest> tests = simpleTestRepository.findByGroupIdNullAndOptionalPermissionAndOptionalOwner(permission, ownerId);
|
||||
for (SimpleTest test : tests) {
|
||||
String username = userRepository.findById((long) test.getIdOwner()).get().getUsername();
|
||||
SimpleTestDTO testDTO = modelMapper.map(test, SimpleTestDTO.class);
|
||||
testDTO.setOwner(username);
|
||||
if (usersTests != null){
|
||||
List<TestResult> testResults = testResultRepository.findByIdOwnerAndIdTest(usersTests.getId(), test.getId());
|
||||
if (testResults.size() > 0) {
|
||||
testDTO.setGrade(testResults.get(testResults.size() - 1).getUserScore());
|
||||
testDTO.setMaxScore(testResults.get(testResults.size() - 1).getMaxScore());
|
||||
}
|
||||
}
|
||||
|
||||
if(test.getGroupId() != null)
|
||||
testDTO.setGroup(groupRepository.findById((long)test.getGroupId()).orElse(null).getName());
|
||||
testDTO.setGroup(groupRepository.findById(test.getGroupId()).orElse(null).getName());
|
||||
testDTOs.add(testDTO);
|
||||
|
||||
}
|
||||
|
@ -430,7 +550,6 @@ public class TestController {
|
|||
// System.out.println("usuwam "+oldquestion.getId());
|
||||
}
|
||||
}
|
||||
|
||||
testRepository.save(test);
|
||||
|
||||
for (Long a : deletea)
|
||||
|
|
|
@ -2,7 +2,6 @@ package studycave.studycaverestservice.controller;
|
|||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -29,10 +28,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -155,7 +152,7 @@ public class UploadController {
|
|||
|
||||
System.out.println("Permission: " + permission);
|
||||
List<MaterialGetDTO> materialDTOs = new ArrayList<>();
|
||||
List<Material> materials = materialRepository.findByOptionalPermissionAndOptionalOwner(permission,ownerId);
|
||||
List<Material> materials = materialRepository.findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(permission,ownerId);
|
||||
|
||||
for(Material material : materials) {
|
||||
System.out.println(material);
|
||||
|
@ -171,7 +168,7 @@ public class UploadController {
|
|||
materialDTO.setOwner(username);
|
||||
if(material.getGroup() != null )
|
||||
if((long)material.getGroup().getId() != 0 )
|
||||
materialDTO.setGroup(groupRepository.findById((long)material.getGroup().getId()).orElse(null).getName());
|
||||
materialDTO.setGroup(groupRepository.findById(material.getGroup().getId()).orElse(null).getName());
|
||||
materialDTOs.add(materialDTO);
|
||||
}
|
||||
return new ResponseEntity<List<MaterialGetDTO>>(materialDTOs, HttpStatus.OK);
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package studycave.studycaverestservice.controller;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import studycave.studycaverestservice.model.studyGroup.GroupRepository;
|
||||
import studycave.studycaverestservice.model.user.UserRepository;
|
||||
import studycave.studycaverestservice.model.userActivity.SortType;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivity;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivityDTO;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivityRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@Api
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public class UserActivityController {
|
||||
|
||||
@Autowired
|
||||
UserRepository userRepository;
|
||||
@Autowired
|
||||
GroupRepository groupRepository;
|
||||
@Autowired
|
||||
UserActivityRepository userActivityRepository;
|
||||
|
||||
@GetMapping("/groups/{groupId}/users/activity")
|
||||
public ResponseEntity<?> getUserActivity(@PathVariable(required = true) Long groupId,
|
||||
@RequestParam(value = "startDate", required = false) Date startDate,
|
||||
@RequestParam(value = "endDate", required = false) Date endDate,
|
||||
@RequestParam(value = "sort", required = false) SortType sort) {
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String currentPrincipalName = authentication.getName();
|
||||
Long userId = (userRepository.findByUsername(currentPrincipalName).orElse(null)).getId();
|
||||
|
||||
Timestamp endDateTime = null;
|
||||
|
||||
if (endDate != null ) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTimeInMillis(endDate.getTime());
|
||||
c.set(Calendar.HOUR_OF_DAY, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
endDateTime = new Timestamp(c.getTimeInMillis());
|
||||
|
||||
}
|
||||
|
||||
List<UserActivity> userActivity = this.userActivityRepository
|
||||
.findAllByToUserOrFromUserAndGroupAndTime(userId, groupId, startDate, endDateTime);
|
||||
List<UserActivityDTO> list = new ArrayList<UserActivityDTO>();
|
||||
|
||||
Collections.sort(userActivity, new Comparator<UserActivity>() {
|
||||
public int compare(UserActivity o1, UserActivity o2) {
|
||||
return o1.getDate().compareTo(o2.getDate());
|
||||
}
|
||||
});
|
||||
|
||||
for (UserActivity u : userActivity) {
|
||||
|
||||
String resourceType = null;
|
||||
String resourceName = null;
|
||||
|
||||
if (u.getMaterial() != null) {
|
||||
resourceType = "material";
|
||||
resourceName = u.getMaterial().getTitle();
|
||||
}
|
||||
|
||||
if (u.getTest() != null) {
|
||||
resourceType = "test";
|
||||
resourceName = u.getTest().getTitle();
|
||||
}
|
||||
|
||||
if (u.getSet() != null) {
|
||||
resourceType = "flashcards";
|
||||
resourceName = u.getSet().getName();
|
||||
}
|
||||
|
||||
UserActivityDTO dto;
|
||||
dto = new UserActivityDTO(
|
||||
u.getId(),
|
||||
u.getType(),
|
||||
u.getPoints(),
|
||||
u.getComment(),
|
||||
new SimpleDateFormat("yyyy-MM-dd").format(u.getDate()),
|
||||
resourceType,
|
||||
resourceName,
|
||||
u.getFromUser() != null ? u.getFromUser().getUsername() : null,
|
||||
u.getToUser() != null ? u.getToUser().getUsername() : null
|
||||
);
|
||||
list.add(dto);
|
||||
}
|
||||
|
||||
if (sort == SortType.DESC) {
|
||||
Collections.reverse(list);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
package studycave.studycaverestservice.controller;
|
||||
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -62,7 +60,7 @@ public class UserContentController {
|
|||
return new ResponseEntity<>(new String("User not found"), HttpStatus.NOT_FOUND);
|
||||
|
||||
ArrayList<SimpleSetDTO> setDTOs = new ArrayList<SimpleSetDTO>();
|
||||
List<SimpleSet> sets = simpleSetRepository.findByOptionalPermissionAndOptionalOwner(null, ownerId);
|
||||
List<SimpleSet> sets = simpleSetRepository.findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(null, ownerId);
|
||||
|
||||
for (SimpleSet set : sets) {
|
||||
Boolean isInGroup = false;
|
||||
|
@ -100,7 +98,7 @@ public class UserContentController {
|
|||
return new ResponseEntity<>(new String("User not found"), HttpStatus.NOT_FOUND);
|
||||
|
||||
ArrayList<MaterialGetDTO> materialDTOs = new ArrayList<MaterialGetDTO>();
|
||||
List<Material> materials = materialRepository.findByOptionalPermissionAndOptionalOwner(null, ownerId);
|
||||
List<Material> materials = materialRepository.findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(null, ownerId);
|
||||
|
||||
for (Material material : materials) {
|
||||
Boolean isInGroup = false;
|
||||
|
@ -138,7 +136,7 @@ public class UserContentController {
|
|||
return new ResponseEntity<>(new String("User not found"), HttpStatus.NOT_FOUND);
|
||||
|
||||
ArrayList<SimpleTestDTO> testDTOs = new ArrayList<SimpleTestDTO>();
|
||||
List<SimpleTest> tests = simpleTestRepository.findByOptionalPermissionAndOptionalOwner(null, new Long(ownerId));
|
||||
List<SimpleTest> tests = simpleTestRepository.findByGroupIdNullAndOptionalPermissionAndOptionalOwner(null, new Long(ownerId));
|
||||
|
||||
for (SimpleTest test : tests) {
|
||||
Boolean isInGroup = false;
|
||||
|
@ -155,6 +153,10 @@ public class UserContentController {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!isInGroup) {
|
||||
if (simpleTestRepository.findByGroupIdAndTitleLike(Integer.parseInt(groupId), test.getTitle()).isPresent())
|
||||
isInGroup = true;
|
||||
}
|
||||
if (!isInGroup) {
|
||||
SimpleTestDTO testDTO = modelMapper.map(test, SimpleTestDTO.class);
|
||||
testDTO.setOwner(currentPrincipalName);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class UsosController {
|
|||
responseHeaders.add("authorization", responseToken.getKey());
|
||||
return ResponseEntity.status(HttpStatus.OK).headers(responseHeaders).body(responseToken);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException | IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).headers(responseHeaders).body(new TokenResponseDTO(e.getCause().toString(), null));
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).headers(responseHeaders).body(new TokenResponseDTO(e.getCause().toString(), null, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ public interface SetRepository extends JpaRepository<Set, Long> {
|
|||
|
||||
|
||||
@Query("select t from Set t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'VERIFIED' )")
|
||||
List<Set> findSetByGroup(@Param("g") Long g);
|
||||
List<Set> findSetByGroup(@Param("g") Integer g);
|
||||
|
||||
|
||||
@Query("select t from Set t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'UNVERIFIED' )")
|
||||
List<Set> findWaitingSetByGroupKey(@Param("g") Long g);
|
||||
List<Set> findWaitingSetByGroupKey(@Param("g") Integer g);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ public interface MaterialRepository extends JpaRepository<Material, Long> {
|
|||
|
||||
|
||||
@Query("select m from Material m where (:permission is null or m.permission = :permission) and "
|
||||
+ "(:owner is null or m.owner = :owner)")
|
||||
List<Material> findByOptionalPermissionAndOptionalOwner(@Param("permission") String permission,
|
||||
+ "(:owner is null or m.owner = :owner) and m.group is null")
|
||||
List<Material> findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(@Param("permission") String permission,
|
||||
@Param("owner") Integer owner);
|
||||
|
||||
|
||||
@Query("select t from Material t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'VERIFIED' )")
|
||||
List<Material> findMaterialByGroup(@Param("g") Long g);
|
||||
List<Material> findMaterialByGroup(@Param("g") Integer g);
|
||||
|
||||
@Query("select t from Material t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'UNVERIFIED' )")
|
||||
List<Material> findWaitingMaterialByGroupKey(@Param("g") Long g);
|
||||
List<Material> findWaitingMaterialByGroupKey(@Param("g") Integer g);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public interface SimpleSetRepository extends JpaRepository<SimpleSet, Long> {
|
|||
|
||||
|
||||
@Query("select s from SimpleSet s where (:permission is null or s.permission = :permission) and "
|
||||
+ "(:owner is null or s.idOwner = :owner)")
|
||||
List<SimpleSet> findByOptionalPermissionAndOptionalOwner(@Param("permission") String permission,
|
||||
+ "(:owner is null or s.idOwner = :owner) and groupId is null")
|
||||
List<SimpleSet> findByOptionalPermissionAndOptionalOwnerAndGroupIdNull(@Param("permission") String permission,
|
||||
@Param("owner") Integer owner);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,15 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface SimpleTestRepository extends JpaRepository<SimpleTest, Long> {
|
||||
List<SimpleTest> findAll();
|
||||
|
||||
Optional<SimpleTest> findByGroupIdAndTitleLike(Integer groupId, String title);
|
||||
|
||||
@Query("select t from SimpleTest t where (:permission is null or t.permission = :permission) and "
|
||||
+ "(:owner is null or t.idOwner = :owner)")
|
||||
List<SimpleTest> findByOptionalPermissionAndOptionalOwner(@Param("permission") String permission,
|
||||
+ "(:owner is null or t.idOwner = :owner) and t.groupId is null")
|
||||
List<SimpleTest> findByGroupIdNullAndOptionalPermissionAndOptionalOwner(@Param("permission") String permission,
|
||||
@Param("owner") Long owner);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package studycave.studycaverestservice.model.simpleTest.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
@ -13,6 +14,7 @@ import java.sql.Date;
|
|||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SimpleTestDTO {
|
||||
private Long id;
|
||||
private String title;
|
||||
|
@ -23,7 +25,9 @@ public class SimpleTestDTO {
|
|||
private Date editDate;
|
||||
@ApiModelProperty(value = "Default value for note", required = true,example = "public")
|
||||
private String permission;
|
||||
private Long grade;
|
||||
private Float grade;
|
||||
private String group;
|
||||
|
||||
private int maxScore;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GroupRepository extends JpaRepository<StudyGroup, Long> {
|
||||
public interface GroupRepository extends JpaRepository<StudyGroup, Integer> {
|
||||
|
||||
List<StudyGroup> findByName(String name);
|
||||
|
||||
List<StudyGroup> findByGroupKey(String groupKey);
|
||||
|
||||
Optional<StudyGroup> findByUsosGroupId(String course_id);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package studycave.studycaverestservice.model.studyGroup;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
@ -28,12 +26,15 @@ import studycave.studycaverestservice.model.flashcardset.Set;
|
|||
import studycave.studycaverestservice.model.flashcardset.SetRepository;
|
||||
import studycave.studycaverestservice.model.material.Material;
|
||||
import studycave.studycaverestservice.model.material.MaterialRepository;
|
||||
import studycave.studycaverestservice.model.simpleTest.dto.SimpleTestDTO;
|
||||
import studycave.studycaverestservice.model.studyGroup.dto.*;
|
||||
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMember;
|
||||
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMemberRepository;
|
||||
import studycave.studycaverestservice.model.test.Test;
|
||||
import studycave.studycaverestservice.model.test.TestRepository;
|
||||
import studycave.studycaverestservice.model.test.dto.TestResultResponseDTO;
|
||||
import studycave.studycaverestservice.model.test.question.*;
|
||||
import studycave.studycaverestservice.model.test.result.TestResult;
|
||||
import studycave.studycaverestservice.model.test.result.TestResultRepository;
|
||||
import studycave.studycaverestservice.model.user.User;
|
||||
import studycave.studycaverestservice.model.user.UserRepository;
|
||||
|
@ -86,7 +87,7 @@ public class GroupService {
|
|||
while (!this.groupRepository.findByGroupKey(groupKey).isEmpty()) {
|
||||
groupKey = generator.generate(10);
|
||||
}
|
||||
;
|
||||
|
||||
group.setGroupKey(groupKey);
|
||||
Optional<User> owner = this.userRepository.findByUsername(groupDto.getOwner());
|
||||
if (!owner.isPresent()) {
|
||||
|
@ -118,11 +119,11 @@ public class GroupService {
|
|||
return new ResponseEntity<GroupDto>(createdGroupDto, HttpStatus.OK);
|
||||
}
|
||||
|
||||
public GroupInfoDto getGroupInfo(Long id) {
|
||||
public GroupInfoDto getGroupInfo(Integer id) {
|
||||
StudyGroup group = new StudyGroup();
|
||||
group = this.groupRepository.findById(id).orElse(null);
|
||||
GroupInfoDto groupInfo = new GroupInfoDto();
|
||||
groupInfo.setId((long)group.getId());
|
||||
groupInfo.setId(group.getId());
|
||||
groupInfo.setName(group.getName());
|
||||
groupInfo.setDescription(group.getDescription());
|
||||
groupInfo.setGroupKey(group.getGroupKey());
|
||||
|
@ -141,7 +142,7 @@ public class GroupService {
|
|||
return groupInfo;
|
||||
}
|
||||
|
||||
public ResponseEntity deleteUserFromGroup(Long gId, Long pId) {
|
||||
public ResponseEntity deleteUserFromGroup(Integer gId, Long pId) {
|
||||
StudyGroupMember user = new StudyGroupMember();
|
||||
user = this.memberRepository.findUserInGroup(gId, pId);
|
||||
this.memberRepository.delete(user);
|
||||
|
@ -149,7 +150,7 @@ public class GroupService {
|
|||
|
||||
}
|
||||
|
||||
public ResponseEntity deleteGroup(Long id) {
|
||||
public ResponseEntity deleteGroup(Integer id) {
|
||||
StudyGroup group = new StudyGroup();
|
||||
group = this.groupRepository.findById(id).orElse(null);
|
||||
for (StudyGroupMember m : group.getMembers()) {
|
||||
|
@ -159,7 +160,7 @@ public class GroupService {
|
|||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> generateCode(Long id) {
|
||||
public ResponseEntity<?> generateCode(Integer id) {
|
||||
StudyGroup group = new StudyGroup();
|
||||
group = this.groupRepository.findById(id).orElse(null);
|
||||
RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('0', 'z')
|
||||
|
@ -176,6 +177,45 @@ public class GroupService {
|
|||
return new ResponseEntity<>(groupKey, HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getGroupTests(Integer group_id) {
|
||||
ArrayList<SimpleTestDTO> simpleTestDTOS = new ArrayList<SimpleTestDTO>();
|
||||
List<Test> tests = testRepository.findAllByGroupIdOrderByAddDateDesc(group_id);
|
||||
for (Test test : tests) {
|
||||
SimpleTestDTO simpleTestDTO = new SimpleTestDTO();
|
||||
simpleTestDTO.setId(test.getId());
|
||||
simpleTestDTO.setTitle(test.getTitle());
|
||||
int testScore = 0;
|
||||
for (Question question : test.getQuestions())
|
||||
testScore += question.getPoints();
|
||||
simpleTestDTO.setMaxScore(testScore);
|
||||
|
||||
simpleTestDTOS.add(simpleTestDTO);
|
||||
}
|
||||
return new ResponseEntity<List<SimpleTestDTO>>(simpleTestDTOS,HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getGroupTestsWithResults(Integer groupId, Long testId) {
|
||||
Optional<Test> test = testRepository.findByIdAndGroupId(testId, groupId);
|
||||
|
||||
if (!test.isPresent())
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
|
||||
List<TestResult> testResults = testResultRepository.findAllByIdTestOrderByIdTestDesc(testId);
|
||||
|
||||
List<TestResultResponseDTO> testResultResponseDTOS = new ArrayList<>();
|
||||
|
||||
for (TestResult testResult : testResults) {
|
||||
Optional<User> userCheck = userRepository.findById(testResult.getIdOwner());
|
||||
if (userCheck.isPresent()) {
|
||||
User user = userCheck.get();
|
||||
testResultResponseDTOS.add(new TestResultResponseDTO(user.getName(), user.getSurname(), testResult.getUserScore(), (testResult.getUserScore()/testResult.getMaxScore()) * 100));
|
||||
}
|
||||
}
|
||||
Collections.sort(testResultResponseDTOS,
|
||||
Comparator.comparing(TestResultResponseDTO::getName));
|
||||
return new ResponseEntity<List<TestResultResponseDTO>>(testResultResponseDTOS,HttpStatus.OK);
|
||||
}
|
||||
|
||||
public List<SimpleStudyGroupMemberDTO> getMyGroups(Long id) {
|
||||
// User user = new User();
|
||||
// user = this.userRepository.findByUsername(username).orElse(null);
|
||||
|
@ -234,7 +274,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> addFlashcardSets(String groupId, @RequestBody List<AddSetDto> setIds) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
User user = userRepository.findByUsername(authentication.getName()).get();
|
||||
|
||||
|
@ -252,7 +292,19 @@ public class GroupService {
|
|||
entityManager.detach(set);
|
||||
set.setId(null);
|
||||
set.setPermission("GROUP");
|
||||
StudyGroupMember groupLeader = null;
|
||||
for (StudyGroupMember studyGroupMember : group.getMembers()){
|
||||
if (studyGroupMember.getIsGroupLeader())
|
||||
{
|
||||
groupLeader = studyGroupMember;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (groupLeader != null && groupLeader.getUser().getId() == user.getId()){
|
||||
set.setStatus("VERIFIED");
|
||||
} else {
|
||||
set.setStatus("UNVERIFIED");
|
||||
}
|
||||
set.setGroup(group);
|
||||
this.setRepository.save(set);
|
||||
this.userActivityService.saveActivity("addedResource", 0, null, user, null, group, null, set, null);
|
||||
|
@ -263,7 +315,7 @@ public class GroupService {
|
|||
|
||||
|
||||
public ResponseEntity<?> addMaterials(String groupId, @RequestBody List<AddMaterialDto> materialIds) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
User user = userRepository.findByUsername(authentication.getName()).get();
|
||||
|
||||
|
@ -276,7 +328,19 @@ public class GroupService {
|
|||
entityManager.detach(material);
|
||||
material.setId(null);
|
||||
material.setPermission("GROUP");
|
||||
StudyGroupMember groupLeader = null;
|
||||
for (StudyGroupMember studyGroupMember : group.getMembers()){
|
||||
if (studyGroupMember.getIsGroupLeader())
|
||||
{
|
||||
groupLeader = studyGroupMember;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (groupLeader != null && groupLeader.getUser().getId() == user.getId()){
|
||||
material.setStatus("VERIFIED");
|
||||
} else {
|
||||
material.setStatus("UNVERIFIED");
|
||||
}
|
||||
material.setGroup(group);
|
||||
this.materialRepository.save(material);
|
||||
this.userActivityService.saveActivity("addedResource", 0, null, user, null, group, material, null, null);
|
||||
|
@ -286,7 +350,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> addTests(String groupId, @RequestBody List<AddTestDto> testIds) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
User user = userRepository.findByUsername(authentication.getName()).get();
|
||||
|
||||
|
@ -328,9 +392,26 @@ public class GroupService {
|
|||
entityManager.detach(test);
|
||||
test.setId(null);
|
||||
test.setPermission("GROUP");
|
||||
StudyGroupMember groupLeader = null;
|
||||
for (StudyGroupMember studyGroupMember : group.getMembers()){
|
||||
if (studyGroupMember.getIsGroupLeader())
|
||||
{
|
||||
groupLeader = studyGroupMember;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (groupLeader != null && groupLeader.getUser().getId() == user.getId()){
|
||||
test.setStatus("VERIFIED");
|
||||
} else {
|
||||
test.setStatus("UNVERIFIED");
|
||||
}
|
||||
test.setGroup(group);
|
||||
this.testRepository.save(test);
|
||||
if (t.getDateFrom() != null && t.getDateFrom() > 0 && t.getDateTo() != null && t.getDateTo() > 0) {
|
||||
test.setAvailableFrom(t.getDateFrom());
|
||||
test.setAvailableTo(t.getDateTo());
|
||||
}
|
||||
test.setActivity(new ArrayList<>());
|
||||
test = this.testRepository.save(test);
|
||||
this.userActivityService.saveActivity("addedResource", 0, null, user, null, group, null, null, test);
|
||||
});
|
||||
}
|
||||
|
@ -339,7 +420,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
|
||||
public ResponseEntity<?> getContent(Long group_id, String type) {
|
||||
public ResponseEntity<?> getContent(Integer group_id, String type, User user) {
|
||||
List<ContentDto> contents = new ArrayList<>();
|
||||
|
||||
switch (type){
|
||||
|
@ -350,9 +431,25 @@ public class GroupService {
|
|||
ContentDto contentTest = new ContentDto();
|
||||
contentTest.setId(t.getId());
|
||||
contentTest.setOwner((userRepository.findById(t.getIdOwner()).orElse(null)).getUsername());
|
||||
long grade = 0;
|
||||
if (user != null){
|
||||
for (UserActivity userActivity : t.getActivity()){
|
||||
if (userActivity.getToUser() != null && userActivity.getToUser().equals(user) && userActivity.getType().equalsIgnoreCase("solvedTest")){
|
||||
grade = userActivity.getPoints();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
contentTest.setAddDate();
|
||||
contentTest.setGrade((long) 0);
|
||||
contentTest.setGrade(grade);
|
||||
contentTest.setTitle(t.getTitle());
|
||||
long maxScore = 0;
|
||||
for (Question question : t.getQuestions()){
|
||||
maxScore += question.getPoints();
|
||||
}
|
||||
contentTest.setDateTo(t.getAvailableTo());
|
||||
contentTest.setDateFrom(t.getAvailableFrom());
|
||||
contentTest.setMaxScore(maxScore);
|
||||
contents.add(contentTest);
|
||||
}
|
||||
|
||||
|
@ -391,7 +488,7 @@ public class GroupService {
|
|||
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getUnverifiedContent(Long group_id, String type){
|
||||
public ResponseEntity<?> getUnverifiedContent(Integer group_id, String type){
|
||||
List<ContentDto> contents = new ArrayList<>();
|
||||
|
||||
switch (type){
|
||||
|
@ -440,7 +537,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> acceptTest(String groupId, String testId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -458,7 +555,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> acceptSet(String groupId, String setId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -479,7 +576,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> acceptMaterial(String groupId, String materialId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -500,7 +597,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> rejectTest(String groupId, String testId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -519,7 +616,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> rejectSet(String groupId, String setId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -541,7 +638,7 @@ public class GroupService {
|
|||
}
|
||||
|
||||
public ResponseEntity<?> rejectMaterial(String groupId, String materialId, VerifyDto dto) {
|
||||
StudyGroup group = this.groupRepository.findById(Long.parseLong(groupId)).orElse(null);
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
@ -598,7 +695,7 @@ public class GroupService {
|
|||
return new ResponseEntity<>("Usunięto komentarz", HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> deleteContent(Long group_id, String type, Long content_id){
|
||||
public ResponseEntity<?> deleteContent(Integer group_id, String type, Long content_id){
|
||||
switch (type) {
|
||||
case "tests":
|
||||
Test test = this.testRepository.findById(content_id).orElse(null);
|
||||
|
@ -629,7 +726,7 @@ public class GroupService {
|
|||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getGroupLeaderboard(Long group_id){
|
||||
public ResponseEntity<?> getGroupLeaderboard(Integer group_id){
|
||||
StudyGroup group = this.groupRepository.findById(group_id).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
|
@ -643,6 +740,8 @@ public class GroupService {
|
|||
score += a.getPoints();
|
||||
}
|
||||
user.setUsername(m.getUser().getUsername());
|
||||
user.setName(m.getUser().getName());
|
||||
user.setSurname(m.getUser().getSurname());
|
||||
if(userBadgeRepository.findByIdAndUser((long)8, m.getUser().getId()).isEmpty() && score > 100) {
|
||||
UserBadge badgeAchieved = new UserBadge();
|
||||
Badge badge = new Badge();
|
||||
|
@ -666,7 +765,7 @@ public class GroupService {
|
|||
return new ResponseEntity<List<LeaderboardDTO>>(leaderboard,HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getGroupTestLeaderboard(Long group_id){
|
||||
public ResponseEntity<?> getGroupTestLeaderboard(Integer group_id){
|
||||
StudyGroup group = this.groupRepository.findById(group_id).orElse(null);
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
|
@ -677,10 +776,12 @@ public class GroupService {
|
|||
float score = 0;
|
||||
LeaderboardDTO user = new LeaderboardDTO();
|
||||
for (UserActivity a : m.getUser().getActivityTo()) {
|
||||
if(a.getType() == "solvedTest")
|
||||
if(a.getType().equalsIgnoreCase("solvedTest"))
|
||||
score += a.getPoints();
|
||||
}
|
||||
user.setUsername(m.getUser().getUsername());
|
||||
user.setName(m.getUser().getName());
|
||||
user.setSurname(m.getUser().getSurname());
|
||||
user.setPoints(score);
|
||||
leaderboard.add(user);
|
||||
}
|
||||
|
@ -689,4 +790,24 @@ public class GroupService {
|
|||
return new ResponseEntity<List<LeaderboardDTO>>(leaderboard,HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> editTests(String groupId, List<AddTestDto> testIds) {
|
||||
StudyGroup group = this.groupRepository.findById(Integer.parseInt(groupId)).orElse(null);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
User user = userRepository.findByUsername(authentication.getName()).get();
|
||||
|
||||
if (group == null) {
|
||||
return new ResponseEntity<>("Nie znaleziono grupy", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
for (AddTestDto t : testIds) {
|
||||
Optional<Test> test = testRepository.findByIdAndGroupId(Long.parseLong(t.getTestId()), Integer.parseInt(groupId));
|
||||
if (test.isPresent()){
|
||||
Test testGet = test.get();
|
||||
testGet.setAvailableFrom(t.getDateFrom());
|
||||
testGet.setAvailableTo(t.getDateTo());
|
||||
testRepository.save(testGet);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>("Edytowano", HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public class StudyGroup {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
private String usosGroupId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
@ -33,7 +35,7 @@ public class StudyGroup {
|
|||
@Column(unique = true)
|
||||
private String groupKey;
|
||||
|
||||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
|
||||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
List<StudyGroupMember> members = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
|
||||
|
|
|
@ -13,4 +13,8 @@ public class AddTestDto {
|
|||
|
||||
private String testId;
|
||||
|
||||
private Long dateTo;
|
||||
|
||||
private Long dateFrom;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package studycave.studycaverestservice.model.studyGroup.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -11,6 +12,7 @@ import java.sql.Date;
|
|||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ContentDto {
|
||||
|
||||
private Long id;
|
||||
|
@ -18,6 +20,10 @@ public class ContentDto {
|
|||
private Date addDate;
|
||||
private String owner;
|
||||
private Long grade;
|
||||
private Long maxScore;
|
||||
|
||||
private Long dateTo;
|
||||
private Long dateFrom;
|
||||
|
||||
public void setAddDate() {
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import lombok.Setter;
|
|||
@Getter
|
||||
@Setter
|
||||
public class GroupDto {
|
||||
private Long id;
|
||||
private Integer id;
|
||||
private String owner;
|
||||
private String name;
|
||||
private String description;
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
@Getter
|
||||
@Setter
|
||||
public class GroupInfoDto {
|
||||
private Long id;
|
||||
private Integer id;
|
||||
private String owner;
|
||||
private String name;
|
||||
private String description;
|
||||
|
|
|
@ -31,4 +31,10 @@ public class StudyGroupMember {
|
|||
|
||||
@Column(name="is_group_leader")
|
||||
private Boolean isGroupLeader;
|
||||
|
||||
public StudyGroupMember(StudyGroup group, User user, Boolean isGroupLeader) {
|
||||
this.group = group;
|
||||
this.user = user;
|
||||
this.isGroupLeader = isGroupLeader;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package studycave.studycaverestservice.model.studyGroupMember;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
@ -13,6 +14,7 @@ public interface StudyGroupMemberRepository extends JpaRepository<StudyGroupMemb
|
|||
|
||||
|
||||
@Query("select t from StudyGroupMember t where (t.group.id = :g and t.user.id = :u)")
|
||||
StudyGroupMember findUserInGroup(@Param("g") Long g, @Param("u") Long u);
|
||||
StudyGroupMember findUserInGroup(@Param("g") Integer g, @Param("u") Long u);
|
||||
|
||||
Optional<StudyGroupMember> findByUserUsosUserUsosIdAndGroupUsosGroupId(String id, String groupId);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
|
||||
import studycave.studycaverestservice.model.test.question.Question;
|
||||
import studycave.studycaverestservice.model.userActivity.UserActivity;
|
||||
|
@ -57,7 +58,16 @@ public class Test {
|
|||
private StudyGroup group;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "test", cascade = CascadeType.ALL)
|
||||
private List<UserActivity> activity;
|
||||
private List<UserActivity> activity = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private Long availableFrom = null;
|
||||
|
||||
@Nullable
|
||||
private Long availableTo = null;
|
||||
|
||||
|
||||
|
||||
|
||||
public void setAddDate() {
|
||||
java.util.Date utilDate = new java.util.Date();
|
||||
|
|
|
@ -5,15 +5,21 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface TestRepository extends JpaRepository<Test, Long> {
|
||||
|
||||
Optional<Test> findByIdAndGroupId(Long testId, Integer groupId);
|
||||
|
||||
@Query("select t from Test t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'VERIFIED' )")
|
||||
List<Test> findTestByGroup(@Param("g") Long g);
|
||||
List<Test> findTestByGroup(@Param("g") Integer g);
|
||||
|
||||
|
||||
|
||||
@Query("select t from Test t where (t.permission = 'GROUP' and t.group.id = :g and t.status = 'UNVERIFIED' )")
|
||||
List<Test> findWaitingTestByGroupKey(@Param("g") Long g);
|
||||
List<Test> findWaitingTestByGroupKey(@Param("g") Integer g);
|
||||
|
||||
|
||||
List<Test> findAllByGroupIdOrderByAddDateDesc(Integer id);
|
||||
|
||||
}
|
||||
|
|
|
@ -37,4 +37,6 @@ public class TestEditDTO {
|
|||
@JsonProperty("body")
|
||||
List<Question> questions;
|
||||
|
||||
private Boolean help;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,13 @@ public class TestOwnerDTO {
|
|||
private String permission;
|
||||
private int grade;
|
||||
|
||||
private Long dateFrom;
|
||||
private Long dateTo;
|
||||
|
||||
private Boolean attempted = null;
|
||||
|
||||
private Boolean isGroupOwner = false;
|
||||
|
||||
@JsonProperty("body")
|
||||
List<Question> questions = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package studycave.studycaverestservice.model.test.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TestResultResponseDTO {
|
||||
|
||||
@Getter
|
||||
private String name;
|
||||
|
||||
@Getter
|
||||
private String surname;
|
||||
|
||||
@Getter
|
||||
private float userScore;
|
||||
|
||||
private float percent;
|
||||
|
||||
public float getPercent(){
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMaximumFractionDigits(2);
|
||||
return Float.parseFloat(df.format(this.percent));
|
||||
}
|
||||
}
|
|
@ -64,4 +64,13 @@ public abstract class Question {
|
|||
@JsonManagedReference
|
||||
List<Answer> answers = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int time;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(columnDefinition = "TINYINT(1)")
|
||||
private Boolean help = false;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,7 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,10 +14,15 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
public class QuestionChoices extends Question {
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY,mappedBy="question",cascade = CascadeType.ALL)
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy="question", cascade = CascadeType.ALL)
|
||||
@JsonManagedReference
|
||||
List<AnswerChoices> answers = new ArrayList<>();
|
||||
|
||||
@Transient
|
||||
@Getter
|
||||
@Setter
|
||||
List<AnswerChoices> answers_help = new ArrayList<>();
|
||||
|
||||
public List<AnswerChoices> getAnswers() {
|
||||
return answers;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||
|
||||
public interface TestResultRepository extends JpaRepository<TestResult,Long> {
|
||||
|
||||
List<TestResult> findAllByIdTestOrderByIdTestDesc(Long testId);
|
||||
|
||||
List<TestResult> findByIdOwner(Long id);
|
||||
|
||||
List<TestResult> findByIdOwnerAndIdTest(Long id, Long id2);
|
||||
|
|
|
@ -7,4 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
Optional<User> findByUsername(String username);
|
||||
Optional<User> findByEmail(String email);
|
||||
|
||||
Optional<User> findByUsosUserUsosId(String id);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import lombok.Setter;
|
|||
@NoArgsConstructor
|
||||
public class LeaderboardDTO implements Comparable {
|
||||
private String Username;
|
||||
private String Name;
|
||||
private String Surname;
|
||||
private float points;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package studycave.studycaverestservice.model.userActivity;
|
||||
|
||||
public enum SortType {
|
||||
ASC, DESC;
|
||||
}
|
|
@ -46,7 +46,6 @@ public class UserActivity {
|
|||
private Set set;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "test_id")
|
||||
private Test test;
|
||||
|
||||
@ManyToOne
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package studycave.studycaverestservice.model.userActivity;
|
||||
|
||||
public class UserActivityDTO {
|
||||
private Long id;
|
||||
|
||||
private String type;
|
||||
|
||||
private float points;
|
||||
|
||||
private String comment;
|
||||
|
||||
private String date;
|
||||
|
||||
private String resourceType;
|
||||
|
||||
private String resourceName;
|
||||
|
||||
private String from;
|
||||
|
||||
private String to;
|
||||
|
||||
|
||||
|
||||
public UserActivityDTO(Long id, String type, float points, String comment, String date, String resourceType,
|
||||
String resourceName, String from, String to) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.points = points;
|
||||
this.comment = comment;
|
||||
this.date = date;
|
||||
this.resourceType = resourceType;
|
||||
this.resourceName = resourceName;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public float getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(float points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
public void setResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package studycave.studycaverestservice.model.userActivity;
|
|||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import studycave.studycaverestservice.model.test.Test;
|
||||
import studycave.studycaverestservice.model.user.User;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
@ -14,4 +16,5 @@ public interface UserActivityRepository extends JpaRepository<UserActivity, Long
|
|||
List<UserActivity> findAllByToUserOrFromUserAndGroupAndTime(Long userId, Long groupId,
|
||||
Date start, Timestamp end);
|
||||
|
||||
List<UserActivity> findAllByTestAndToUser(Test test, User userAuth);
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
package studycave.studycaverestservice.usos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -15,4 +16,7 @@ public class TokenResponseDTO {
|
|||
|
||||
private String username;
|
||||
|
||||
@JsonIgnore
|
||||
private String userId;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ spring.servlet.multipart.max-request-size=500KB
|
|||
#server.address=51.75.30.146
|
||||
#server.port=8080
|
||||
|
||||
server.address=localhost
|
||||
server.port=8080
|
||||
|
||||
#usos instance to use
|
||||
usos.baseURI=https://usosapps.amu.edu.pl
|
||||
usos.basePath=/services
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
"../node_modules/primeng/resources/primeng.min.css",
|
||||
"../node_modules/primeng/resources/themes/luna-amber/theme.css",
|
||||
"../node_modules/primeng/resources/components/dialog/dialog.css",
|
||||
"../node_modules/primeng/resources/components/calendar/calendar.css",
|
||||
"styles.css"
|
||||
],
|
||||
"scripts": [
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"repoId": "51789675-24f3-468d-a696-09187b48c708",
|
||||
"lastSync": 0
|
||||
}
|
|
@ -41,6 +41,7 @@
|
|||
"popper.js": "^1.12.9",
|
||||
"primeicons": "^1.0.0",
|
||||
"primeng": "^6.1.7",
|
||||
"ngx-csv": "^0.3.1",
|
||||
"rxjs": "^5.5.2",
|
||||
"zone.js": "^0.8.14"
|
||||
},
|
||||
|
|
|
@ -46,6 +46,7 @@ import { BagdesComponent } from './user/bagdes/bagdes.component';
|
|||
import { RankingComponent } from './groups/ranking/ranking.component';
|
||||
import { HistoryOfActivityInGroupComponent } from './groups/history-of-activity-in-group/history-of-activity-in-group.component';
|
||||
import { LoginUsosComponent } from './login/login-usos/login-usos.component';
|
||||
import { TestsInGroupResultsComponent } from './groups/tests-in-group-results/tests-in-group-results.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
|
@ -87,7 +88,8 @@ const routes: Routes = [
|
|||
{ path: 'groups/ranking/:id', component: RankingComponent , canActivate: [AuthGuard] },
|
||||
{ path: 'groups/waiting-resources/:id', component: WaitingResourcesComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'groups/waiting-resources/:id', component: WaitingResourcesComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'groups/history/:id', component: HistoryOfActivityInGroupComponent, canActivate: [AuthGuard] }
|
||||
{ path: 'groups/history/:id', component: HistoryOfActivityInGroupComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'groups/tests-results/:id', component: TestsInGroupResultsComponent, canActivate: [AuthGuard] }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -13,18 +13,12 @@
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.content{
|
||||
margin-top: 170px;
|
||||
height: calc(100vh - 200px);
|
||||
min-height: calc(100vh - 200px);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 352px) {
|
||||
.content{
|
||||
margin-top: 170px;
|
||||
height: calc(100vh - 250px);
|
||||
margin-top: 195px;
|
||||
height: 75%;
|
||||
min-height: calc(100vh - 250px);
|
||||
z-index: 1000;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import 'rxjs/add/observable/throw';
|
|||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { USOSUrl, LoginKey } from './login';
|
||||
import { environment } from './../environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class AuthenticationService {
|
||||
|
@ -68,7 +69,7 @@ export class AuthenticationService {
|
|||
}
|
||||
|
||||
getUSOSTokens(): Observable<USOSUrl> {
|
||||
return this.http.get<USOSUrl>(encodeURI('usos/request_token?oauth_callback=http://localhost:4200/login/usos'));
|
||||
return this.http.get<USOSUrl>(encodeURI(`usos/request_token?oauth_callback=${environment.frontend}login/usos`));
|
||||
}
|
||||
|
||||
getToken(): String {
|
||||
|
|
|
@ -6,6 +6,11 @@ margin-top: 1rem;
|
|||
text-align: left;
|
||||
|
||||
}
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: #181616;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="buttons-container">
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/add/table"><i class="fas fa-table"></i> DODAJ ZA POMOCĄ TABELI</button>
|
||||
<button class="button" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="button" routerLink="/flashcards/add/table"><i class="fas fa-table"></i> DODAJ ZA POMOCĄ TABELI</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrapper-add">
|
||||
|
@ -45,9 +45,9 @@
|
|||
<br />
|
||||
<input type="checkbox" name="{{ permission }}" class="form-control" [checked]="permission" (change)="changePermission()"/><b>Udostępnij publicznie</b>
|
||||
</div><br />
|
||||
<button class="btn btn-study-cave" [disabled]="!selectedFiles" (click)="upload()"><i class="fas fa-check-circle"></i> Dodaj fiszki!</button>
|
||||
<button class="button" style="font-size: x-large;" [disabled]="!selectedFiles" (click)="upload()"><i class="fas fa-check-circle"></i> Dodaj fiszki!</button>
|
||||
<br /><br />
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button" routerLink="/flashcards/sets/"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,6 +7,16 @@ table, th, td, tr {
|
|||
background-color: transparent;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.container {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="buttons-container">
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/add/csv"><i class="fas fa-file-csv"></i> DODAJ ZA POMOCĄ CSV</button>
|
||||
<button class="button" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="button" routerLink="/flashcards/add/csv"><i class="fas fa-file-csv"></i> DODAJ ZA POMOCĄ CSV</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrapper-add">
|
||||
|
@ -37,7 +37,7 @@
|
|||
<input [(ngModel)]="field.right_side" class="form-control" type="text" name="{{field.right_side}}" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-study-cave" type="button" (click)="deleteFieldValue(i)"><i class="fas fa-trash-alt"></i> Usuń fiszkę</button>
|
||||
<button class="button" type="button" (click)="deleteFieldValue(i)"><i class="fas fa-trash-alt"></i> Usuń fiszkę</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -48,7 +48,7 @@
|
|||
<input class="form-control" type="text" id="newAttributeRight" [(ngModel)]="newAttribute.right_side" name="newAttributeRight" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-study-cave" type="button" (click)="addFieldValue()"><i class="fas fa-plus"></i> Dodaj fiszkę</button>
|
||||
<button class="button" type="button" (click)="addFieldValue()"><i class="fas fa-plus"></i> Dodaj fiszkę</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -60,8 +60,8 @@
|
|||
<b>Udostępnij publicznie</b>
|
||||
</div>
|
||||
<br /><br />
|
||||
<button class="btn btn-study-cave" type="submit"><i class="fas fa-check-circle"></i> Dodaj fiszki!</button>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button" style="font-size: x-large;" type="submit"><i class="fas fa-check-circle"></i> Dodaj fiszki!</button><br />
|
||||
<button class="button" routerLink="/flashcards/sets/"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -34,3 +34,10 @@ ag-grid-angular{
|
|||
.buttons-container > div{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="buttons-container">
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/add/table"><i class="fas fa-table"></i> DODAJ ZA POMOCĄ TABELI</button>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/add/csv"><i class="fas fa-file-csv"></i> DODAJ ZA POMOCĄ CSV</button>
|
||||
<button class="button" routerLink="/flashcards/sets"><i class="fas fa-arrow-left"></i> WRÓĆ DO LISTY</button>
|
||||
<button class="button" routerLink="/flashcards/add/table"><i class="fas fa-table"></i> DODAJ ZA POMOCĄ TABELI</button>
|
||||
<button class="button" routerLink="/flashcards/add/csv"><i class="fas fa-file-csv"></i> DODAJ ZA POMOCĄ CSV</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -15,6 +15,13 @@ table, th, td, tr {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.wrapper-add {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="buttons-container">
|
||||
<button class="btn btn-study-cave" (click)="returnToSet()"><i class="fas fa-arrow-left"></i> WRÓĆ DO ZESTAWU</button>
|
||||
<button class="button" (click)="returnToSet()"><i class="fas fa-arrow-left"></i> WRÓĆ DO ZESTAWU</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrapper-add">
|
||||
|
@ -45,7 +45,7 @@
|
|||
<input [(ngModel)]="field.right_side" class="form-control" type="text" name="{{field.right_side}}" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-study-cave" type="button" (click)="deleteFieldValue(i)"><i class="fas fa-trash-alt"></i> Usuń fiszkę</button>
|
||||
<button class="button" type="button" (click)="deleteFieldValue(i)"><i class="fas fa-trash-alt"></i> Usuń fiszkę</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<input class="form-control" type="text" id="newAttributeRight" [(ngModel)]="newAttribute['right_side']" name="newAttributeRight" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-study-cave" type="button" (click)="addFieldValue()"><i class="fas fa-file-csv"></i> Dodaj fiszkę</button>
|
||||
<button class="button" type="button" (click)="addFieldValue()"><i class="fas fa-file-csv"></i> Dodaj fiszkę</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -64,8 +64,8 @@
|
|||
</label>
|
||||
<br />
|
||||
<div>
|
||||
<button class="btn btn-study-cave" type="submit"><i class="fas fa-check-circle"></i> Edytuj fiszki!</button>
|
||||
<button class="btn btn-study-cave" [routerLink]="['/flashcards/sets', ident]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button" style="font-size: x-large;" type="submit"><i class="fas fa-check-circle"></i> Edytuj fiszki!</button><br />
|
||||
<button class="button" [routerLink]="['/flashcards/sets', ident]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#container-large {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
Podaj odpowiedź:<br />
|
||||
{{flashcards[index].content}}
|
||||
<input appAutofocus [(ngModel)]="answer" class="mr-2" placeholder="odpowiedź" (keyup.enter)="verifyAnswer()" >
|
||||
<button class="btn btn-study-cave" (click)="verifyAnswer()"><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
<button class="button" style="min-width: 200px;" (click)="verifyAnswer()"><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
</div>
|
||||
<div *ngIf="this.is_correct === true && !finish">ODPOWIEDŹ POPRAWNA</div>
|
||||
<div *ngIf="this.is_correct === false && !finish">ODPOWIEDŹ NIEPOPRAWNA</div>
|
||||
|
@ -50,10 +50,10 @@
|
|||
<app-test-results [result]="good" [maxPts]="length_test"></app-test-results>
|
||||
</div>
|
||||
<div *ngIf="!finish">
|
||||
<button class="btn btn-study-cave" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="button" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
</div>
|
||||
<button class="btn btn-study-cave" *ngIf="finish" routerLink="/flashcards/sets/{{ id }}"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="btn btn-study-cave" *ngIf="started && !finish && !not_last"(click)="finished()"><i class="fas fa-arrow-left"></i> Przejdź do wyniku</button>
|
||||
<button class="button" *ngIf="finish" routerLink="/flashcards/sets/{{ id }}"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="button" *ngIf="started && !finish && !not_last"(click)="finished()"><i class="fas fa-arrow-left"></i> Przejdź do wyniku</button>
|
||||
<br />
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
<button class="button" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#container-large {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
</div>
|
||||
<br />
|
||||
<div *ngIf="!finish">
|
||||
<button class="btn btn-study-cave" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="btn btn-study-cave" *ngIf="checked && not_last" (click)="increment()"><i class="fas fa-arrow-right"></i>Przejdź dalej</button>
|
||||
<button class="btn btn-study-cave" *ngIf="checked && !not_last" (click)="increment()"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="button" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="button" *ngIf="checked && not_last" (click)="increment()"><i class="fas fa-arrow-right"></i>Przejdź dalej</button>
|
||||
<button class="button" *ngIf="checked && !not_last" (click)="increment()"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
</div>
|
||||
<br />
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
<button class="button" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,14 @@
|
|||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#container-large {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -27,5 +27,5 @@
|
|||
|
||||
</div>
|
||||
<br />
|
||||
<button *ngIf="!verify" class="btn btn-study-cave" (click)="nextQuestion()"><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
<button *ngIf="!verify" class="button" style="min-width: 200px;" (click)="nextQuestion()"><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
</div>
|
|
@ -15,6 +15,13 @@
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#container-large {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -45,11 +45,11 @@
|
|||
</div>
|
||||
<br />
|
||||
<div *ngIf="!finish">
|
||||
<button class="btn btn-study-cave" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="btn btn-study-cave" *ngIf="checked && not_last" (click)="increment()"><i class="far fa-play-circle"></i> Przejdź dalej</button>
|
||||
<button class="btn btn-study-cave" *ngIf="checked && !not_last" (click)="increment()"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="button" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="button" *ngIf="checked && not_last" (click)="increment()"><i class="far fa-play-circle"></i> Przejdź dalej</button>
|
||||
<button class="button" *ngIf="checked && !not_last" (click)="increment()"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
</div>
|
||||
<br />
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
<button class="button" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,6 +12,13 @@
|
|||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.content{
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="button-container">
|
||||
<button class="btn btn-study-cave" (click)="goBack()"><i class="fas fa-arrow-left"></i> POWRÓT</button>
|
||||
<button class="btn btn-study-cave" (click)="showTestTypeMenu()"><i class="fas fa-pencil-ruler"></i> GENERUJ TESTY</button>
|
||||
<button *ngIf="owned && set && set.permission !== 'GROUP'" class="btn btn-study-cave" (click)="navigateToEditMode()"><i class="fas fa-edit"></i> EDYTUJ FISZKI</button>
|
||||
<button *ngIf="owned && set && set.permission !== 'GROUP'" class="btn btn-study-cave" (click)="showPopup()"><i class="fas fa-trash-alt"></i> USUŃ FISZKI</button>
|
||||
<button class="button" (click)="goBack()"><i class="fas fa-arrow-left"></i> POWRÓT</button>
|
||||
<button class="button" (click)="showTestTypeMenu()"><i class="fas fa-pencil-ruler"></i> GENERUJ TESTY</button>
|
||||
<button *ngIf="owned && set && set.permission !== 'GROUP'" class="button" (click)="navigateToEditMode()"><i class="fas fa-edit"></i> EDYTUJ FISZKI</button>
|
||||
<button *ngIf="owned && set && set.permission !== 'GROUP'" class="button" (click)="showPopup()"><i class="fas fa-trash-alt"></i> USUŃ FISZKI</button>
|
||||
<div *ngIf="user && owned && set && set.permission !== 'GROUP'">
|
||||
<button class="btn btn-study-cave" (click)="changePermission()"><i class="fas fa-unlock"></i> ZMIEŃ UPRAWNIENIA</button>
|
||||
<button class="button" (click)="changePermission()"><i class="fas fa-unlock"></i> ZMIEŃ UPRAWNIENIA</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
|||
<p-dialog header="Potwierdź" [(visible)]="display">
|
||||
Czy chcesz usunąć fiszkę?
|
||||
<p-footer>
|
||||
<button type="button" pButton icon="pi pi-check" (click)="deleteSet()" label="TAK"></button>
|
||||
<button type="button" pButton icon="pi pi-close" (click)="display=false" label="NIE" class="ui-button-secondary"></button>
|
||||
<button type="button" class="button" pButton icon="pi pi-check" (click)="deleteSet()" label="TAK"></button>
|
||||
<button type="button" class="button" pButton icon="pi pi-close" (click)="display=false" label="NIE" class="ui-button-secondary"></button>
|
||||
</p-footer>
|
||||
</p-dialog>
|
||||
</div>
|
|
@ -10,6 +10,10 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.wrapper{
|
||||
width: 100%;
|
||||
padding: 30px;
|
||||
|
@ -17,6 +21,13 @@
|
|||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.mobile{
|
||||
display: none;
|
||||
|
@ -44,3 +55,6 @@ ag-grid-angular{
|
|||
.buttons-container > div{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
<br />
|
||||
<div class="buttons-container">
|
||||
<div *ngIf="logged">
|
||||
<button class="btn btn-study-cave" (click)="toFlashcardsMaker()"><i class="fas fa-plus"></i> Dodaj fiszki</button>
|
||||
<button class="button" (click)="toFlashcardsMaker()"><i class="fas fa-plus"></i> Dodaj fiszki</button>
|
||||
</div>
|
||||
<div *ngIf="logged" class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-study-cave active" (click)="ShowPublic()">
|
||||
<input type="radio" name="options" id="option1" autocomplete="off" checked><i class="fas fa-globe"></i> Publiczne
|
||||
<input type="radio" class="radio-answer" name="options" id="option1" autocomplete="off" checked><i class="fas fa-globe"></i> Publiczne
|
||||
</label>
|
||||
<label class="btn btn-study-cave" (click)="ShowPrivate()">
|
||||
<input type="radio" name="options" id="option2" autocomplete="off"><i class="fas fa-user-secret"></i> Prywatne
|
||||
<label class="btn btn-study-cave " (click)="ShowPrivate()">
|
||||
<input type="radio" class="radio-answer" name="options" id="option2" autocomplete="off"><i class="fas fa-user-secret"></i> Prywatne
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,8 +26,8 @@
|
|||
<p-dialog header="Potwierdź" [(visible)]="display">
|
||||
Czy chcesz usunąć fiszkę?
|
||||
<p-footer>
|
||||
<button type="button" pButton icon="pi pi-check" (click)="deleteSet()" label="TAK"></button>
|
||||
<button type="button" pButton icon="pi pi-close" (click)="display=false" label="NIE" class="ui-button-secondary"></button>
|
||||
<button type="button" class="button" pButton icon="pi pi-check" (click)="deleteSet()" label="TAK"></button>
|
||||
<button type="button" class="button" pButton icon="pi pi-close" (click)="display=false" label="NIE" class="ui-button-secondary"></button>
|
||||
</p-footer>
|
||||
</p-dialog>
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ export class FlashcardsSetsListComponent implements OnInit, OnDestroy {
|
|||
{ headerName: 'Nazwa', field: 'name', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'add_date', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Data modyfikacji', field: 'edit_date', headerTooltip: 'Data modyfikacji', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Grupa', field: 'group', headerTooltip: 'Grupa', hide: !this.isGroup },
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -59,9 +57,9 @@ export class FlashcardsSetsListComponent implements OnInit, OnDestroy {
|
|||
return '';
|
||||
} else if (params.data['owner'] === currentUser.username) {
|
||||
return `
|
||||
<button type="button" data-action-type="remove" class="btn btn-study-cave btn-sm" title="Usuń">
|
||||
<button type="button" data-action-type="remove" class="btn btn-study-cave " title="Usuń">
|
||||
<i class="fas fa-trash-alt" data-action-type="remove"></i></button>
|
||||
<button type="button" data-action-type="changePermission" class="btn btn-study-cave btn-sm" title="Uprawnienia">
|
||||
<button type="button" data-action-type="changePermission" class="btn btn-study-cave " title="Uprawnienia">
|
||||
<i class="fas fa-unlock" data-action-type="changePermission"></i></button>
|
||||
`;
|
||||
} else {
|
||||
|
@ -208,8 +206,6 @@ export class FlashcardsSetsListComponent implements OnInit, OnDestroy {
|
|||
{ headerName: 'Nazwa', field: 'name', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'add_date', headerTooltip: 'Data dodania', hide: true },
|
||||
{ headerName: 'Data modyfikacji', field: 'edit_date', headerTooltip: 'Data modyfikacji', hide: true },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: true },
|
||||
{ headerName: 'Grupa', field: 'group', headerTooltip: 'Grupa', hide: !this.isGroup },
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -223,8 +219,6 @@ export class FlashcardsSetsListComponent implements OnInit, OnDestroy {
|
|||
{ headerName: 'Nazwa', field: 'name', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'add_date', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Data modyfikacji', field: 'edit_date', headerTooltip: 'Data modyfikacji', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Grupa', field: 'group', headerTooltip: 'Grupa', hide: !this.isGroup },
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -257,8 +251,6 @@ export class FlashcardsSetsListComponent implements OnInit, OnDestroy {
|
|||
{ headerName: 'Nazwa', field: 'name', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'add_date', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Data modyfikacji', field: 'edit_date', headerTooltip: 'Data modyfikacji', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Grupa', field: 'group', headerTooltip: 'Grupa', hide: !this.isGroup },
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
|
|
@ -2,3 +2,11 @@ div{
|
|||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div>
|
||||
<button class="btn btn-study-cave" (click)="goToTestGenFill()">Uzupełnij</button>
|
||||
<button class="btn btn-study-cave" (click)="goToTestGen()">Pary</button>
|
||||
<button class="btn btn-study-cave" (click)="goToTestGenTyperace()">Na czas</button>
|
||||
<button class="btn btn-study-cave" (click)="goToTestGenMemory()">Memory</button>
|
||||
<button class="btn btn-study-cave" (click)="cancelMenu()"><i class="fas fa-times"></i> Anuluj</button>
|
||||
<button class="button" (click)="goToTestGenFill()">Uzupełnij</button>
|
||||
<button class="button" (click)="goToTestGen()">Pary</button>
|
||||
<button class="button" (click)="goToTestGenTyperace()">Na czas</button>
|
||||
<button class="button" (click)="goToTestGenMemory()">Memory</button><br />
|
||||
<button class="button" (click)="cancelMenu()"><i class="fas fa-times"></i> Anuluj</button>
|
||||
</div>
|
|
@ -15,6 +15,13 @@
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#container-large {
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
Podaj odpowiedź:<br />
|
||||
{{flashcards[index].content}}
|
||||
<input appAutofocus [(ngModel)]="answer" class="mr-2" placeholder="odpowiedź" (keyup.enter)="verifyAnswer()" >
|
||||
<button class="btn btn-study-cave" (click)="verifyAnswer()" ><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
<button class="button" style="min-width: 200px;" (click)="verifyAnswer()" ><i class="fas fa-check-circle"></i> Sprawdź</button>
|
||||
</div>
|
||||
<div *ngIf="this.is_correct === true && !finish">ODPOWIEDŹ POPRAWNA</div>
|
||||
<div *ngIf="this.is_correct === false && !finish">ODPOWIEDŹ NIEPOPRAWNA</div>
|
||||
|
@ -52,11 +52,11 @@
|
|||
<app-test-results [result]="good" [maxPts]="length_test" [minutes]="finalminute" [seconds]="finalsecond" [milliseconds]="finalmillisecond" [timer]="true"></app-test-results>
|
||||
</div>
|
||||
<div *ngIf="!finish">
|
||||
<button class="btn btn-study-cave" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
<button class="button" *ngIf="!started" (click)="start()"><i class="far fa-play-circle"></i> Rozpocznij test</button>
|
||||
</div>
|
||||
<button class="btn btn-study-cave" *ngIf="finish" routerLink="/flashcards/sets/{{ id }}"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="btn btn-study-cave" *ngIf="started && !finish && !not_last"(click)="finished()"><i class="far fa-stop-circle"></i> Przejdź do wyniku</button>
|
||||
<button class="button" *ngIf="finish" routerLink="/flashcards/sets/{{ id }}"><i class="far fa-stop-circle"></i> Zakończ test</button>
|
||||
<button class="button" *ngIf="started && !finish && !not_last"(click)="finished()"><i class="far fa-stop-circle"></i> Przejdź do wyniku</button>
|
||||
<br />
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
<button class="button" routerLink="/flashcards/sets/{{ id }}"><i class="fas fa-arrow-left"></i> Wróć do zestawu</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
.btn{
|
||||
margin-bottom: 5px;
|
||||
.button{
|
||||
font-size: large;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div>
|
||||
<button class="btn btn-study-cave" routerLink="/flashcards/sets"><i class="fas fa-scroll"></i> FISZKI</button>
|
||||
<button class="btn btn-study-cave" routerLink="/materials/list"><i class="fas fa-book-open"></i> MATERIAŁY</button>
|
||||
<button class="button" routerLink="/flashcards/sets"><i class="fas fa-scroll"></i> FISZKI</button>
|
||||
<button class="button" routerLink="/materials/list"><i class="fas fa-book-open"></i> MATERIAŁY</button>
|
||||
</div>
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
bottom: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: rgb(24, 22, 22);
|
||||
background-color: black;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<div class="footer">
|
||||
Regulamin | Polityka Cookies | © 2019 StudyCave
|
||||
© 2020 Punktonerzy
|
||||
</div>
|
|
@ -18,6 +18,13 @@ label {
|
|||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
padding: 30px;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<textarea name="description" class="form-control" ngModel required></textarea>
|
||||
</label>
|
||||
<br /><br />
|
||||
<button #btn class="btn btn-study-cave" type="submit"><i class="fas fa-check-circle"></i> Dodaj grupę!</button>
|
||||
<button class="btn btn-study-cave" routerLink="/my-groups"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button #btn class="button" style="font-size: x-large;" type="submit"><i class="fas fa-check-circle"></i> Dodaj grupę!</button><br />
|
||||
<button class="button" routerLink="/my-groups"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,8 +25,7 @@
|
|||
[minWidth]="300" [minY]="70" [draggable]="false" [closable]="false">
|
||||
<p>Twoja grupa została utworzona prawidłowo.</p>
|
||||
<p>Poniżej znajduje się kod dostępu poprzez który możesz dodawać członków:</p>
|
||||
<!--<p><b>{{ createdGroup.key }}</b></p>-->
|
||||
<p><b>{{ createdGroup.groupKey }}</b></p>
|
||||
<p><b>{{ createdGroup.key }}</b></p>
|
||||
<br />
|
||||
<p>Kod ten będzie dostępny także w sekcji "Zarządzaj grupą."</p>
|
||||
<br />
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
ag-grid-angular{
|
||||
margin: 10px;
|
||||
}
|
||||
|
@ -22,3 +29,7 @@ ag-grid-angular{
|
|||
.buttons-container > div{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,36 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div>
|
||||
<button class="btn btn-study-cave float-right mr-1" (click)="goToAddingResource()"><i class="fas fa-plus"></i>
|
||||
<button class="button float-right mr-1 mb-4" (click)="goToAddingResource()"><i class="fas fa-plus"></i>
|
||||
Dodaj zasoby do grupy</button>
|
||||
|
||||
<button class="btn btn-study-cave float-right mr-1" (click)="goToRankings()"><i class="fas fa-trophy"></i>
|
||||
<button class="button float-right mr-1 mb-4" (click)="goToRankings()"><i class="fas fa-trophy"></i>
|
||||
Rankingi</button>
|
||||
|
||||
<button *ngIf="group?.owner===currentUser.username" class="button float-right mr-1 mb-4" (click)="goToTestsResults()"><i class="fas fa-trophy"></i>
|
||||
Wyniki za testy</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<button class="btn btn-study-cave float-right mr-1" (click)="goToHistory()"><i class="fas fa-user-clock"></i> Twoja historia aktywności</button>
|
||||
<button class="button float-right mr-1 mb-4" (click)="goToHistory()"><i class="fas fa-user-clock"></i> Twoja historia aktywności</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<br />
|
||||
<h1>{{group?.name}}</h1>
|
||||
<br />
|
||||
<h3>Opis grupy:</h3>
|
||||
<p>{{group?.description}}</p>
|
||||
<div class="buttons-container">
|
||||
<div>
|
||||
<button class="btn btn-study-cave" (click)="goToGroupsList()"><i class="fas fa-arrow-left"></i> Do listy grup</button>
|
||||
<button *ngIf="group?.owner===currentUser.username" class="btn btn-study-cave" (click)="goToEditing()"><i class="fas fa-edit"></i> Edytuj grupę</button>
|
||||
<button class="button mb-4" (click)="goToGroupsList()"><i class="fas fa-arrow-left"></i> Do listy grup</button>
|
||||
<button *ngIf="group?.owner===currentUser.username" class="button mb-4" (click)="goToEditing()"><i class="fas fa-edit"></i> Edytuj grupę</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-study-cave" (click)="isDisplayed('materiałów')"><i class="fas fa-book-open"></i>
|
||||
<button class="button mb-4" (click)="isDisplayed('materiałów')"><i class="fas fa-book-open"></i>
|
||||
Materiały</button>
|
||||
<button class="btn btn-study-cave" (click)="isDisplayed('fiszek')"><i class="fas fa-scroll"></i> Fiszki</button>
|
||||
<button class="btn btn-study-cave" (click)="isDisplayed('testów')"><i class="fas fa-pencil-ruler"></i>Testy</button>
|
||||
<button class="button mb-4" (click)="isDisplayed('fiszek')"><i class="fas fa-scroll"></i> Fiszki</button>
|
||||
<button class="button mb-4" (click)="isDisplayed('testów')"><i class="fas fa-pencil-ruler"></i>Testy</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -48,4 +52,20 @@
|
|||
<button type="button" pButton icon="pi pi-close" (click)="display=false" label="NIE" class="ui-button-secondary"></button>
|
||||
</p-footer>
|
||||
</p-dialog>
|
||||
|
||||
<p-dialog header="Edytuj dostępność" [(visible)]="displayAvailability"
|
||||
[contentStyle]="{'min-height':'600px', 'min-width': '800px'}">
|
||||
<div *ngIf="dataToDisplay === 'testów'">
|
||||
Od kiedy test ma być dostępny:
|
||||
<p-calendar [minDate]="minDate" [(ngModel)]="dateFrom" [showTime]="true"></p-calendar>
|
||||
<br /><br /><br />
|
||||
Ile minut ma być dostępny ten test:
|
||||
<input type="number" step="1" min="1" name="howLong" [(ngModel)]="howLong" />
|
||||
<br /><br /><br />
|
||||
<button [disabled]="howLong < 1" class="button" (click)="editTestAvailability()">Edytuj</button>
|
||||
</div>
|
||||
<div *ngIf="dataToDisplay !== 'testów'">
|
||||
Ta funkcjonalność pozwala tylko na edycję dostępności testów.
|
||||
</div>
|
||||
</p-dialog>
|
||||
</div>
|
|
@ -5,6 +5,7 @@ import { Group } from '../group';
|
|||
import { Subscription } from 'rxjs/Subscription';
|
||||
import localeText from './../../../assets/localeText';
|
||||
import { GridOptions, RowDoubleClickedEvent } from 'ag-grid-community/main';
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-details',
|
||||
|
@ -28,12 +29,19 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
public gridApi;
|
||||
public gridOptions: GridOptions;
|
||||
|
||||
displayAvailability = false;
|
||||
|
||||
dateFrom: Date = new Date();
|
||||
howLong = 10;
|
||||
testId = 1;
|
||||
|
||||
minDate: Date = new Date();
|
||||
|
||||
columnDefs = [
|
||||
{ headerName: 'ID', field: 'id', headerTooltip: 'ID' },
|
||||
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'addDate', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
|
||||
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: false },
|
||||
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start' },
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -41,17 +49,58 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
cellRenderer: this.customCellRendererFunc
|
||||
}
|
||||
];
|
||||
timetest: number;
|
||||
|
||||
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router) { }
|
||||
timeout: any;
|
||||
|
||||
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router,
|
||||
public snackBar: MatSnackBar) { }
|
||||
|
||||
|
||||
customCellRendererFunc(params) {
|
||||
const currentUsername = JSON.parse(localStorage.getItem('currentUser')).username;
|
||||
const groupOwnerUsername = localStorage.getItem('groupOwnerUsername');
|
||||
return groupOwnerUsername === currentUsername ?
|
||||
`<button type="button" data-action-type="remove" class="btn btn-danger btn-sm"title="Usuń">
|
||||
let btns = '';
|
||||
if (groupOwnerUsername === currentUsername) {
|
||||
btns += `<button type="button" data-action-type="edit" class="btn btn-study-cave mr-2" title="Edytuj">
|
||||
<i class="fas fa-edit" data-action-type="edit"></i>
|
||||
</button>`;
|
||||
btns += `<button type="button" data-action-type="remove" class="btn btn-study-cave" title="Usuń">
|
||||
<i class="fas fa-trash-alt" data-action-type="remove"></i>
|
||||
</button>` : '';
|
||||
</button>`;
|
||||
}
|
||||
return btns;
|
||||
}
|
||||
|
||||
showAvailabilityDialog(data) {
|
||||
console.log(data);
|
||||
this.testId = data.id;
|
||||
if (data['dateFrom']) {
|
||||
this.dateFrom = new Date(data['dateFrom']);
|
||||
this.howLong = Math.round((data['dateTo'] - data['dateFrom']) / 1000 / 60);
|
||||
}
|
||||
this.displayAvailability = true;
|
||||
}
|
||||
|
||||
editTestAvailability() {
|
||||
let dateFrom = null;
|
||||
let dateTo = null;
|
||||
if (this.dateFrom) {
|
||||
dateFrom = this.dateFrom.getTime() - this.dateFrom.getSeconds() * 1000 - this.dateFrom.getMilliseconds();
|
||||
dateTo = dateFrom + this.howLong * 60 * 1000;
|
||||
}
|
||||
this.groupService.putTestsToGroup(this.id, [this.testId.toString()], dateFrom, dateTo).subscribe(
|
||||
success => {
|
||||
this.snackBar.open('Prawidłowo edytowano przedział czasowy.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-success'] });
|
||||
this.displayAvailability = false;
|
||||
this.isDisplayed('testów');
|
||||
},
|
||||
error => {
|
||||
this.snackBar.open('Wystąpił błąd serwera. Spróbuj ponownie później.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -77,17 +126,43 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
public onRowClicked(e) {
|
||||
if (e.event.target !== undefined) {
|
||||
const data = e.data;
|
||||
const now1 = new Date();
|
||||
const now = now1.getTime();
|
||||
const actionType = e.event.target.getAttribute('data-action-type');
|
||||
|
||||
const temp = new Date(data['dateFrom']);
|
||||
const timetest = temp.getTime();
|
||||
const tempstop = new Date(data['dateTo']);
|
||||
const timeteststop = tempstop.getTime();
|
||||
const currentUsername = JSON.parse(localStorage.getItem('currentUser')).username;
|
||||
const groupOwnerUsername = localStorage.getItem('groupOwnerUsername');
|
||||
if ((groupOwnerUsername === currentUsername) || (timetest < now && now < timeteststop)) {
|
||||
switch (actionType) {
|
||||
case 'remove':
|
||||
return this.onActionRemoveClick(e);
|
||||
case 'edit':
|
||||
return this.showAvailabilityDialog(e.data);
|
||||
default:
|
||||
this.goTo(e);
|
||||
}
|
||||
} else {
|
||||
switch (actionType) {
|
||||
case 'remove':
|
||||
return this.onActionRemoveClick(e);
|
||||
case 'edit':
|
||||
return this.showAvailabilityDialog(e.data);
|
||||
default:
|
||||
this.noTime();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
noTime() {
|
||||
this.snackBar.open('Test jest nieaktywny.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
}
|
||||
|
||||
goTo(event: RowDoubleClickedEvent) {
|
||||
if (this.dataToDisplay === 'fiszek') {
|
||||
this.router.navigate(['flashcards/sets', event.data.id]);
|
||||
|
@ -157,12 +232,15 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onGridSizeChanged(params) {
|
||||
const currentUsername = JSON.parse(localStorage.getItem('currentUser')).username;
|
||||
const groupOwnerUsername = localStorage.getItem('groupOwnerUsername');
|
||||
if (params.clientWidth < 800) {
|
||||
if (groupOwnerUsername === currentUsername) {
|
||||
this.columnDefs = [
|
||||
{ headerName: 'ID', field: 'id', headerTooltip: 'ID' },
|
||||
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'addDate', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
|
||||
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: true },
|
||||
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -172,10 +250,19 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
];
|
||||
} else {
|
||||
this.columnDefs = [
|
||||
{ headerName: 'ID', field: 'id', headerTooltip: 'ID' },
|
||||
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Data dodania', field: 'addDate', headerTooltip: 'Data dodania', hide: false },
|
||||
{ headerName: 'Właściciel', field: 'owner', headerTooltip: 'Właściciel', hide: false },
|
||||
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
|
||||
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: true },
|
||||
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
|
||||
];
|
||||
}
|
||||
} else {
|
||||
if (groupOwnerUsername === currentUsername) {
|
||||
this.columnDefs = [
|
||||
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
|
||||
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.' },
|
||||
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
|
||||
{
|
||||
headerName: '',
|
||||
suppressMenu: true,
|
||||
|
@ -183,6 +270,14 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
cellRenderer: this.customCellRendererFunc
|
||||
}
|
||||
];
|
||||
} else {
|
||||
this.columnDefs = [
|
||||
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
|
||||
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
|
||||
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.' },
|
||||
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start'}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
params.api.sizeColumnsToFit();
|
||||
|
@ -233,8 +328,42 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
if (resource === 'testów') {
|
||||
this.localeText.noRowsToShow = 'Brak testów do wyświetlenia';
|
||||
setTimeout(() => {
|
||||
this.testsSubscription = this.groupService.getResource(this.id, 'tests').subscribe(data => this.data = data);
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
this.timeout = setTimeout(() => {
|
||||
this.testsSubscription = this.groupService.getResource(this.id, 'tests').subscribe(data => {
|
||||
this.data = data;
|
||||
data.forEach(x => {
|
||||
const temp = new Date(x['dateFrom']);
|
||||
const tempstop = new Date(x['dateTo']);
|
||||
x['startDate'] = '';
|
||||
const hoursTemp = temp.getHours();
|
||||
let hours = hoursTemp.toString();
|
||||
if (hoursTemp < 10) {
|
||||
hours = `0${hoursTemp}`;
|
||||
}
|
||||
const minutesTemp = temp.getMinutes();
|
||||
let minutes = minutesTemp.toString();
|
||||
if (minutesTemp < 10) {
|
||||
minutes = `0${minutesTemp}`;
|
||||
}
|
||||
// const months = ['STY', 'LUT', 'MAR', 'KWI', 'MAJ', 'CZE', 'LIP', 'SIE', 'WRZ', 'PAŹ', 'LIS', 'GRU'];
|
||||
const year = temp.getFullYear().toString().substring(2);
|
||||
const monthTemp = (temp.getMonth() + 1);
|
||||
let month = monthTemp.toString();
|
||||
if (monthTemp < 10) {
|
||||
month = `0${monthTemp}`;
|
||||
}
|
||||
const dateTemp = temp.getDate();
|
||||
let date = dateTemp.toString();
|
||||
if (dateTemp < 10) {
|
||||
date = `0${dateTemp}`;
|
||||
}
|
||||
const time = date + '.' + month + '.' + year + ' ' + hours + ':' + minutes;
|
||||
x['startDate'] += time;
|
||||
});
|
||||
});
|
||||
this.dataToDisplay = resource;
|
||||
}, 200);
|
||||
|
||||
|
@ -249,6 +378,10 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
|
|||
this.router.navigate(['groups/ranking', this.id]);
|
||||
}
|
||||
|
||||
goToTestsResults() {
|
||||
this.router.navigate(['groups/tests-results', this.id]);
|
||||
}
|
||||
|
||||
goToHistory() {
|
||||
this.router.navigate(['groups/history', this.id]);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ export class Group {
|
|||
public name?: string;
|
||||
public description?: string;
|
||||
public groupKey?: string; // kod dostępu
|
||||
// public key?: string; // kod dostępu
|
||||
public key?: string; // kod dostępu
|
||||
public role?: string; // MEMBER || OWNER
|
||||
public owner?: string; // nazwa użytkownika z rolą OWNER
|
||||
public users?: UsersConfig[];
|
||||
|
@ -30,3 +30,20 @@ export class ActivityHistory {
|
|||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export class TestsInGroup {
|
||||
public id: number;
|
||||
public title: string;
|
||||
public maxScore: number;
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export class TestsInGroupResults {
|
||||
public name: string;
|
||||
public surname: string;
|
||||
public userScore: number;
|
||||
public percent: number;
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import { MatDatepickerModule } from '@angular/material/datepicker';
|
|||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatNativeDateModule } from '@angular/material';
|
||||
import { CalendarModule } from 'primeng/calendar';
|
||||
|
||||
import { GroupsService } from './groups.service';
|
||||
|
||||
|
@ -30,6 +31,7 @@ import { MaterialToGroupPreviewComponent } from './waiting-resources/material-to
|
|||
import { FlashcardsToGroupPreviewComponent } from './waiting-resources/flashcards-to-group-preview/flashcards-to-group-preview.component';
|
||||
import { RankingComponent } from './ranking/ranking.component';
|
||||
import { HistoryOfActivityInGroupComponent } from './history-of-activity-in-group/history-of-activity-in-group.component';
|
||||
import { TestsInGroupResultsComponent } from './tests-in-group-results/tests-in-group-results.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -49,7 +51,8 @@ import { HistoryOfActivityInGroupComponent } from './history-of-activity-in-grou
|
|||
MatInputModule,
|
||||
MatDatepickerModule,
|
||||
ReactiveFormsModule,
|
||||
MatNativeDateModule
|
||||
MatNativeDateModule,
|
||||
CalendarModule
|
||||
],
|
||||
declarations: [
|
||||
MyGroupsComponent,
|
||||
|
@ -63,7 +66,8 @@ import { HistoryOfActivityInGroupComponent } from './history-of-activity-in-grou
|
|||
MaterialToGroupPreviewComponent,
|
||||
FlashcardsToGroupPreviewComponent,
|
||||
RankingComponent,
|
||||
HistoryOfActivityInGroupComponent
|
||||
HistoryOfActivityInGroupComponent,
|
||||
TestsInGroupResultsComponent
|
||||
|
||||
],
|
||||
providers: [GroupsService, ConfirmationService]
|
||||
|
|
|
@ -28,6 +28,9 @@ export class GroupsService {
|
|||
|
||||
private getActivityHistoryURL = 'groups/{groupId}/users/activity?sort={sort}';
|
||||
|
||||
private getTestsInGroupsURL = 'groups/{groupId}/tests';
|
||||
private getResultsInTestsURL = 'groups/{groupId}/tests/{testId}/results';
|
||||
|
||||
constructor(private httpClient: HttpClient, private authenticationService: AuthenticationService) {
|
||||
this.setHeaders();
|
||||
}
|
||||
|
@ -45,6 +48,18 @@ export class GroupsService {
|
|||
}
|
||||
}
|
||||
|
||||
getTestsInGroups(groupId: number): Observable<any> {
|
||||
this.setHeaders();
|
||||
const url = this.getTestsInGroupsURL.replace('{groupId}', groupId.toString());
|
||||
return this.httpClient.get(url, { headers: this.headers });
|
||||
}
|
||||
|
||||
getResultsInTests(groupId: number, testId: number): Observable<any> {
|
||||
this.setHeaders();
|
||||
const url = this.getResultsInTestsURL.replace('{groupId}', groupId.toString()).replace('{testId}', testId.toString());
|
||||
return this.httpClient.get(url, { headers: this.headers });
|
||||
}
|
||||
|
||||
getGroups(): Observable<any> {
|
||||
this.setHeaders();
|
||||
const url = this.getGroupsURL;
|
||||
|
@ -162,9 +177,17 @@ export class GroupsService {
|
|||
});
|
||||
}
|
||||
|
||||
addTestsToGroup(group: number, tests: Array<string>): Observable<any> {
|
||||
addTestsToGroup(group: number, tests: Array<string>, dateFrom: number = null, dateTo = null): Observable<any> {
|
||||
const testToSend = tests.map(item => {
|
||||
if (dateFrom === null) {
|
||||
return { testId: item };
|
||||
} else {
|
||||
return {
|
||||
testId: item,
|
||||
dateFrom: dateFrom,
|
||||
dateTo: dateTo
|
||||
}
|
||||
}
|
||||
});
|
||||
this.setHeaders();
|
||||
return this.httpClient.post(`groups/${group}/tests`,
|
||||
|
@ -178,6 +201,30 @@ export class GroupsService {
|
|||
});
|
||||
}
|
||||
|
||||
putTestsToGroup(group: number, tests: Array<string>, dateFrom: number = null, dateTo = null): Observable<any> {
|
||||
const testToSend = tests.map(item => {
|
||||
if (dateFrom === null) {
|
||||
return { testId: item };
|
||||
} else {
|
||||
return {
|
||||
testId: item,
|
||||
dateFrom: dateFrom,
|
||||
dateTo: dateTo
|
||||
}
|
||||
}
|
||||
});
|
||||
this.setHeaders();
|
||||
return this.httpClient.put(`groups/${group}/tests`,
|
||||
testToSend,
|
||||
{
|
||||
headers: this.headers,
|
||||
observe: 'response',
|
||||
responseType: 'text'
|
||||
}).catch((error: any) => {
|
||||
return Observable.throw(error);
|
||||
});
|
||||
}
|
||||
|
||||
addMaterialsToGroup(group: number, materials: Array<string>): Observable<any> {
|
||||
const testToSend = materials.map(item => {
|
||||
return { materialId: item };
|
||||
|
|
|
@ -18,3 +18,10 @@
|
|||
.buttons-container > div {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div>
|
||||
<button class="btn btn-study-cave float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<h1>Twoja historia aktywności</h1>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<br />
|
||||
<span>Pokaż wszystkie aktywności</span>
|
||||
<br /><br />
|
||||
<button class="btn btn-study-cave" (click)="getHistory(true)">Pokaż wszystko</button>
|
||||
<button class="button" (click)="getHistory(true)">Pokaż wszystko</button>
|
||||
<br /><br /><br />
|
||||
<p>Pokaż aktywności z wybranego przedziału</p>
|
||||
<mat-form-field>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<mat-datepicker #picker2></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<br />
|
||||
<button class="btn btn-study-cave" (click)="getHistory()">Pokaż w wybranym przedziale</button>
|
||||
<button class="button" (click)="getHistory()">Pokaż w wybranym przedziale</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.join-to-group-form-item{
|
||||
margin-bottom: 10px;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="ui-message ui-widget ui-corner-all ui-message-success" *ngIf="reditectToGroup">Dołączyłeś do grupy, przekierowanie do niej nastąpi za 3 sekundy.</div>
|
||||
<form class="join-to-group-form" #f="ngForm" (ngSubmit)="joinToGroup(f.value)" *ngIf="!reditectToGroup">
|
||||
<input type="text" name="code" class="form-control join-to-group-form-item" placeholder="Kod dostępu" ngModel required/>
|
||||
<button type="submit" class="btn btn-study-cave join-to-group-form-item" [disabled]="f.form.invalid"><i class="fas fa-check-circle"></i> Dołącz!</button>
|
||||
<button type="submit" class="button join-to-group-form-item" [disabled]="f.form.invalid"><i class="fas fa-check-circle"></i> Dołącz!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
|
@ -1,4 +1,4 @@
|
|||
a.wrapper{
|
||||
.wrapper{
|
||||
width: 100%;
|
||||
padding: 30px;
|
||||
min-height: 100%;
|
||||
|
@ -15,6 +15,13 @@ a.wrapper{
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
ag-grid-angular{
|
||||
margin: 10px;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<p>Klucz: {{group?.groupKey}}</p>
|
||||
<br/>
|
||||
<div class="buttons-container">
|
||||
<button class="btn btn-study-cave" (click)="goToGroup()"><i class="fas fa-arrow-left"></i> Wróć do grupy</button>
|
||||
<button class="btn btn-study-cave" (click)="newKeyGenerate()"><i class="fas fa-key"></i> Generuj nowy klucz</button>
|
||||
<button class="btn btn-study-cave" (click)="showWaitingResources()"><i class="fas fa-stopwatch"></i> Oczekujące zasoby</button>
|
||||
<button class="btn btn-study-cave" (click)="showDialog()"><i class="fas fa-trash-alt"></i> Usuń grupę</button>
|
||||
<button class="button" (click)="goToGroup()"><i class="fas fa-arrow-left"></i> Wróć do grupy</button>
|
||||
<button class="button" (click)="newKeyGenerate()"><i class="fas fa-key"></i> Generuj nowy klucz</button>
|
||||
<button class="button" (click)="showWaitingResources()"><i class="fas fa-stopwatch"></i> Oczekujące zasoby</button>
|
||||
<button class="button" (click)="showDialog()"><i class="fas fa-trash-alt"></i> Usuń grupę</button>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ export class ManageGroupComponent implements OnInit, OnDestroy {
|
|||
// tslint:disable-next-line:max-line-length
|
||||
constructor(private route: ActivatedRoute, private groupsService: GroupsService,
|
||||
private confirmationService: ConfirmationService, public router: Router, public snackBar: MatSnackBar) {
|
||||
this.localeText.noRowsToShow = 'Brak użytkowników do wyświetlenia';
|
||||
this.localeText.noRowsToShow = 'Brak elementów do wyświetlenia';
|
||||
}
|
||||
|
||||
customCellRendererFunc(params) {
|
||||
return `<button type="button" data-action-type="remove" class="btn btn-study-cave btn-sm" title="Usuń">
|
||||
return `<button type="button" data-action-type="remove" class="btn btn-study-cave " title="Usuń">
|
||||
<i class="fas fa-trash-alt" data-action-type="remove"></i></button>`;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,13 @@ ag-grid-angular{
|
|||
margin: 10px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.buttons-container > div{
|
||||
margin: 10px;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<br />
|
||||
<div class="buttons-container">
|
||||
<div>
|
||||
<button class="btn btn-study-cave" (click)="toGroupMaker()"><i class="fas fa-plus"></i> Dodaj grupę</button>
|
||||
<button class="button" (click)="toGroupMaker()"><i class="fas fa-plus"></i> Dodaj grupę</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-study-cave" (click)="goToJoinToGroup()"><i class="fas fa-users"></i> Dołącz do grupy</button>
|
||||
<button class="button" (click)="goToJoinToGroup()"><i class="fas fa-users"></i> Dołącz do grupy</button>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
|
|
@ -95,7 +95,7 @@ export class MyGroupsComponent implements OnInit, OnDestroy {
|
|||
customCellRendererFunc(params) {
|
||||
if (params.data['role'] === 'Lider') {
|
||||
return `
|
||||
<button type="button" data-action-type="edit" class="btn btn-study-cave btn-sm" title="Zarządzaj grupą">
|
||||
<button type="button" data-action-type="edit" class="btn btn-study-cave " title="Zarządzaj grupą">
|
||||
<i class="fas fa-tools" data-action-type="edit"></i></button>
|
||||
`;
|
||||
} else {
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
margin: 10px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
margin: 10px;
|
||||
width: 100%;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div>
|
||||
<button class="btn btn-study-cave float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<h1>{{group?.name}}</h1>
|
||||
|
@ -15,6 +15,12 @@
|
|||
<input type="radio" name="options" id="option2" autocomplete="off"><i class="fas fa-pencil-ruler"></i> Ranking testów
|
||||
</label>
|
||||
</div>
|
||||
<br />
|
||||
<div *ngIf="group">
|
||||
<button class="button float-right mr-1" (click)="downloadCSVResults()">Eksportuj ranking do pliku CSV</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<br />
|
||||
<ag-grid-angular style="width: 100%; height: 475px;" class="ag-theme-dark" [rowData]="data" [columnDefs]="columnDefs"
|
||||
[enableSorting]="true" [enableFilter]="true" (gridReady)="onGridReady($event)" [gridOptions]="gridOptions"
|
||||
[pagination]="true" [paginationAutoPageSize]="true" [localeText]="localeText" (gridColumnsChanged)="onGridColumnsChanged($event)"
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Subscription } from 'rxjs/Subscription';
|
|||
import { RankingType } from './ranking';
|
||||
import { GridOptions } from 'ag-grid-community/main';
|
||||
import localeText from './../../../assets/localeText';
|
||||
import { ngxCsv } from 'ngx-csv/ngx-csv';
|
||||
import * as picasso from 'picasso.js';
|
||||
picasso.default('canvas');
|
||||
|
||||
|
@ -29,10 +30,12 @@ export class RankingComponent implements OnInit, OnDestroy {
|
|||
public chart;
|
||||
public localeText = localeText;
|
||||
public columnDefs = [
|
||||
{ headerName: 'Użytkownik', field: 'username', headerTooltip: 'Użytkownik' },
|
||||
{ headerName: 'Nazwa użytkownika', field: 'username', headerTooltip: 'Nazwa użytkownika' },
|
||||
{ headerName: 'Imię', field: 'name', headerTooltip: 'Imię' },
|
||||
{ headerName: 'Nazwisko', field: 'surname', headerTooltip: 'Nazwisko' },
|
||||
{ headerName: 'Punkty', field: 'points', headerTooltip: 'Punkty' },
|
||||
];
|
||||
public data;
|
||||
public data = [];
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router) { }
|
||||
|
@ -58,6 +61,20 @@ export class RankingComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
downloadCSVResults() {
|
||||
const options = {
|
||||
fieldSeparator: ';',
|
||||
quoteStrings: '',
|
||||
decimalseparator: ',',
|
||||
showLabels: true,
|
||||
headers: ['Punkty', 'Imię', 'Nazwisko']
|
||||
};
|
||||
const arr = this.data;
|
||||
arr.map(x => delete x['username']);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
new ngxCsv(arr, this.group.name + '_ranking_' + this.typeOfRankingToDisplay, options);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.groupDetailsSubscription) {
|
||||
this.groupDetailsSubscription.unsubscribe();
|
||||
|
@ -127,7 +144,7 @@ export class RankingComponent implements OnInit, OnDestroy {
|
|||
|
||||
showGlobalRanking(): void {
|
||||
this.typeOfRankingToDisplay = RankingType.all;
|
||||
this.rankingSubscription = this.groupService.getGlobalRanking(this.group.id).subscribe(data => {
|
||||
this.rankingSubscription = this.groupService.getGlobalRanking(this.id).subscribe(data => {
|
||||
this.data = data.sort((a, b) => {
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
|
@ -143,7 +160,7 @@ export class RankingComponent implements OnInit, OnDestroy {
|
|||
|
||||
showOnlyTestsRanking(): void {
|
||||
this.typeOfRankingToDisplay = RankingType.test;
|
||||
this.rankingSubscription = this.groupService.getTestsRanking(this.group.id).subscribe(data => {
|
||||
this.rankingSubscription = this.groupService.getTestsRanking(this.id).subscribe(data => {
|
||||
this.data = data.sort((a, b) => {
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
margin-right: auto;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.buttons-container > div {
|
||||
margin: 10px;
|
||||
}
|
||||
|
@ -23,3 +30,8 @@
|
|||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-left: 1rem;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div>
|
||||
<button class="btn btn-study-cave float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<button class="button float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<h1>Dodawanie zasobów do grupy</h1>
|
||||
|
@ -9,9 +9,9 @@
|
|||
<div>
|
||||
<p>Wybierz typ zasobu do dodania:</p>
|
||||
<div>
|
||||
<button [disabled]="materialsToAdd.length > 0" class="btn btn-study-cave mr-1" (click)="getMaterialsToAdd()"><i class="fas fa-book-open"></i> Materiały</button>
|
||||
<button [disabled]="flashcardsToAdd.length > 0" class="btn btn-study-cave mr-1" (click)="getFlashcardsToAdd()"><i class="fas fa-book-open"></i> Fiszki</button>
|
||||
<button [disabled]="testsToAdd.length > 0" class="btn btn-study-cave mr-1" (click)="getTestsToAdd()"><i class="fas fa-book-open"></i> Testy</button>
|
||||
<button [disabled]="materialsToAdd.length > 0" class="button mr-1" (click)="getMaterialsToAdd()"><i class="fas fa-book-open"></i> Materiały</button>
|
||||
<button [disabled]="flashcardsToAdd.length > 0" class="button mr-1" (click)="getFlashcardsToAdd()"><i class="fas fa-book-open"></i> Fiszki</button>
|
||||
<button [disabled]="testsToAdd.length > 0" class="button mr-1" (click)="getTestsToAdd()"><i class="fas fa-book-open"></i> Testy</button>
|
||||
</div>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
@ -25,8 +25,19 @@
|
|||
<h2 *ngIf="testsToAdd.length > 0">Testy</h2>
|
||||
</p-header>
|
||||
</p-listbox>
|
||||
<div *ngIf="testsToAdd.length > 0">
|
||||
<br /><br />
|
||||
<button [disabled]="selected.length === 0" class="btn btn-study-cave mr-1" (click)="addResources()"><i class="fas fa-check-circle"></i> Dodaj</button>
|
||||
Od kiedy test ma być dostępny:
|
||||
<p-calendar [(ngModel)]="dateFrom" [minDate]="minDate" [showTime]="true"></p-calendar>
|
||||
<br /><br /><br />
|
||||
Ile minut ma być dostępny ten test:
|
||||
<input type="number" step="1" min="1" name="howLong" [(ngModel)]="howLong" />
|
||||
</div>
|
||||
<br /><br />
|
||||
<button [disabled]="(selected.length === 0) && (howLong < 1)" class="button mr-1" (click)="addResources()"><i class="fas fa-check-circle"></i> Dodaj</button>
|
||||
</div>
|
||||
<div *ngIf="!(materialsToAdd.length > 0 || flashcardsToAdd.length > 0 || testsToAdd.length > 0)">
|
||||
Brak elementów do dodania
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,9 @@ import { Subscription } from 'rxjs/Subscription';
|
|||
export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
|
||||
|
||||
public id = 0;
|
||||
public dateFrom: Date = new Date();
|
||||
public howLong = 10;
|
||||
public minDate = new Date();
|
||||
|
||||
public materialsToAdd: Resource[] = [];
|
||||
public testsToAdd: Resource[] = [];
|
||||
|
@ -65,10 +68,10 @@ export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
|
|||
this.testsToAdd = [];
|
||||
this.flashcardsToAdd = [];
|
||||
this.materialsToAdd = success.map(this.addPropertiesToDisplayInMultiselectList);
|
||||
if (this.materialsToAdd.length === 0) {
|
||||
/*if (this.materialsToAdd.length === 0) {
|
||||
this.snackBar.open('Brak materiałów, które możesz dodać do grupy.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
}
|
||||
}*/
|
||||
},
|
||||
error => {
|
||||
this.snackBar.open('Wystąpił błąd serwera. Spróbuj ponownie później.', null,
|
||||
|
@ -86,10 +89,10 @@ export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
|
|||
this.flashcardsToAdd = [];
|
||||
this.materialsToAdd = [];
|
||||
this.testsToAdd = success.map(this.addPropertiesToDisplayInMultiselectList);
|
||||
if (this.testsToAdd.length === 0) {
|
||||
/*if (this.testsToAdd.length === 0) {
|
||||
this.snackBar.open('Brak testów, które możesz dodać do grupy.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
}
|
||||
}*/
|
||||
},
|
||||
error => {
|
||||
this.snackBar.open('Wystąpił błąd serwera. Spróbuj ponownie później.', null,
|
||||
|
@ -107,10 +110,10 @@ export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
|
|||
this.materialsToAdd = [];
|
||||
this.testsToAdd = [];
|
||||
this.flashcardsToAdd = success.map(this.addPropertiesToDisplayInMultiselectList);
|
||||
if (this.flashcardsToAdd.length === 0) {
|
||||
/*if (this.flashcardsToAdd.length === 0) {
|
||||
this.snackBar.open('Brak fiszek, które możesz dodać do grupy.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
}
|
||||
}*/
|
||||
},
|
||||
error => {
|
||||
this.snackBar.open('Wystąpił błąd serwera. Spróbuj ponownie później.', null,
|
||||
|
@ -159,7 +162,13 @@ export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
|
|||
addResources() {
|
||||
this.id = this.route.snapshot.params.id;
|
||||
if (this.selectedTypeOfResource === ResourceType.test) {
|
||||
this.addTestsToGroupSub = this.groupService.addTestsToGroup(this.id, this.selected).subscribe(
|
||||
let dateFrom = null;
|
||||
let dateTo = null;
|
||||
if (this.dateFrom) {
|
||||
dateFrom = this.dateFrom.getTime() - this.dateFrom.getSeconds() * 1000 - this.dateFrom.getMilliseconds();
|
||||
dateTo = dateFrom + this.howLong * 60 * 1000;
|
||||
}
|
||||
this.addTestsToGroupSub = this.groupService.addTestsToGroup(this.id, this.selected, dateFrom, dateTo).subscribe(
|
||||
success => {
|
||||
this.snackBar.open('Twoje testy zostały dodane do grupy.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-success'] });
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
.wrapper{
|
||||
width: 100%;
|
||||
padding: 30px;
|
||||
min-height: 100%;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.content{
|
||||
background-color: #181616;
|
||||
padding: 30px;
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
text-align: center;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
ag-grid-angular{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.button{
|
||||
font-size: large;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.buttons-container > div{
|
||||
margin: 10px;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div>
|
||||
<button class="button float-right mr-1" [routerLink]="['/groups/', id]"><i class="fas fa-arrow-left"></i> Powrót</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<h1>Wyniki za testy w grupie: {{group?.name}}</h1>
|
||||
<br />
|
||||
<div>
|
||||
<h2>Wybierz test aby zobaczyć wyniki:</h2>
|
||||
<br />
|
||||
<ag-grid-angular style="width: 100%; height: 475px;" class="ag-theme-dark" [rowData]="data" [columnDefs]="columnDefs"
|
||||
[enableSorting]="true" [enableFilter]="true" (gridReady)="onGridReady($event)" [gridOptions]="gridOptions"
|
||||
[pagination]="true" [paginationAutoPageSize]="true" [localeText]="localeText" (gridColumnsChanged)="onGridColumnsChanged($event)"
|
||||
(rowClicked)="onRowClicked($event)" (gridSizeChanged)="onGridSizeChanged($event)">
|
||||
</ag-grid-angular>
|
||||
</div>
|
||||
<br /><br />
|
||||
<div *ngIf="selectedTest">
|
||||
<h2>Wybrany test: {{selectedTest.title}}</h2>
|
||||
<br />
|
||||
<button *ngIf="group" class="button float-right mr-1" (click)="downloadCSVResults()">Eksportuj wyniki do pliku CSV</button>
|
||||
<div style="clear: both;"></div>
|
||||
<br />
|
||||
<ag-grid-angular style="width: 100%; height: 475px;" class="ag-theme-dark" [rowData]="testdata" [columnDefs]="testcolumnDefs"
|
||||
[enableSorting]="true" [enableFilter]="true" (gridReady)="testonGridReady($event)" [gridOptions]="testgridOptions"
|
||||
[pagination]="true" [paginationAutoPageSize]="true" [localeText]="localeText" (gridColumnsChanged)="testonGridColumnsChanged($event)"
|
||||
(rowClicked)="testonRowClicked($event)" (gridSizeChanged)="testonGridSizeChanged($event)">
|
||||
</ag-grid-angular>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue