Skip to content
Snippets Groups Projects
Commit 6afa2b30 authored by Maddy's avatar Maddy
Browse files

Add profile to sidebar

parent e30af791
Branches
No related tags found
1 merge request!28Sidebar adjustments
Pipeline #269244 passed
...@@ -21,20 +21,5 @@ public class FullstackProsjektApplication { ...@@ -21,20 +21,5 @@ public class FullstackProsjektApplication {
SpringApplication.run(FullstackProsjektApplication.class, args); SpringApplication.run(FullstackProsjektApplication.class, args);
} }
@Bean
CommandLineRunner run(RoleRepository roleRepository, UserRepository userRepository, PasswordEncoder encoder) {
return args -> {
// Exit early if DB already contains the admin user
if (roleRepository.findByAuthority("ADMIN").isPresent()) return;
Role adminRole = roleRepository.save(new Role("ADMIN"));
roleRepository.save(new Role("USER"));
Set<Role> roles = new HashSet<>();
roles.add(adminRole);
User admin = new User(2, "potetmos", encoder.encode("potetmos"), roles);
userRepository.save(admin);
};
}
} }
\ No newline at end of file
package edu.ntnu.idatt2105;
import edu.ntnu.idatt2105.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class QuizCreationAndTest {
// Initialize the logger for the class
private static final Logger logger = LoggerFactory.getLogger(QuizCreationAndTest.class);
public static void main(String[] args) {
logger.info("Quiz creation and test started.");
//Step 0: Create a User
Role admin = new Role("ROLE_ADMIN");
HashSet<Role> roles = new HashSet<>(Arrays.asList(admin));
User JohnDoe = new User("John Doe", "password", roles);
logger.info("Created user: {}", JohnDoe.getUsername());
// Step 1: Create questions with assigned scores
MultipleChoiceQuestion question1 = new MultipleChoiceQuestion(null,
"What is the capital of France?",
2,
Arrays.asList("1. Paris", "2. London", "3. Berlin", "4. Madrid"),
0
);
logger.info("Created question: {}", question1.getQuestionText());
MultipleChoiceQuestion question2 = new MultipleChoiceQuestion(null,
"Which language is primarily spoken in Brazil?",
3,
Arrays.asList("1. Spanish", "2. Portuguese", "3. French", "4. English"),
1
);
logger.info("Created question: {}", question2.getQuestionText());
// Step 2: Create a quiz and add questions
List<Question> questions = new ArrayList<>();
questions.add(question1);
questions.add(question2);
Quiz quiz = new Quiz("Sample Quiz", questions, JohnDoe, QuizCategory.GEOGRAPHY, QuizDifficulty.EASY);
questions.forEach(question -> question.setQuiz(quiz));
logger.info("Created quiz: {}", quiz.getTitle());
// Step 3: Simulate answers from a user
QuestionAnswer answer1 = new QuestionAnswer(question1, "2");
QuestionAnswer answer2 = new QuestionAnswer(question2, "2");
logger.info("Simulated answers for the quiz.");
// Step 4: Create a QuizResult and add answers
QuizResult quizResult = new QuizResult(quiz, new ArrayList<>(), JohnDoe, "påbegynt", LocalDateTime.now(), null); // Initialize with an empty answers list
quizResult.addQuestionAnswer(answer1);
quizResult.addQuestionAnswer(answer2);
logger.info("Created quiz result for user: {}", JohnDoe.getUsername());
// Output results
quizResult.getAnswers().forEach(answer -> {
logger.info("Question: {} - Your Answer: {} - Correct? {}", answer.getQuestion().getQuestionText(), answer.getGivenAnswer(), answer.isCorrect());
});
logger.info("Quiz completed!");
int totalPossibleScore = questions.stream().mapToInt(Question::getScore).sum();
logger.info("Your score: {}/{}", quizResult.getScore(), totalPossibleScore);
}
}
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
<g id="SVGRepo_iconCarrier"> <path d="M4.5 12L9.5 7M4.5 12L9.5 17M4.5 12L14.5 12C16.1667 12 19.5 13 19.5 17" stroke="#363636" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </g>
</svg>
\ No newline at end of file
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
<g id="SVGRepo_iconCarrier"> <path d="M8 13H16M8 13V18C8 19.8856 8 20.8284 8.58579 21.4142C9.17157 22 10.1144 22 12 22C13.8856 22 14.8284 22 15.4142 21.4142C16 20.8284 16 19.8856 16 18V13M8 13C5.2421 12.3871 3.06717 10.2687 2.38197 7.52787L2 6M16 13C17.7107 13 19.1506 14.2804 19.3505 15.9795L20 21.5" stroke="#FFF" stroke-width="1.5" stroke-linecap="round"/> <circle cx="12" cy="6" r="4" stroke="#FFF" stroke-width="1.5"/> </g>
</svg>
\ No newline at end of file
...@@ -34,9 +34,10 @@ export default { ...@@ -34,9 +34,10 @@ export default {
<SidebarLink to="/about" icon="about-us-icon">About</SidebarLink> <SidebarLink to="/about" icon="about-us-icon">About</SidebarLink>
<SidebarLink to="/feedback" icon="feedback-icon">Feedback</SidebarLink> <SidebarLink to="/feedback" icon="feedback-icon">Feedback</SidebarLink>
<SidebarLink to="/login" icon="login-icon">Login</SidebarLink> <SidebarLink to="/login" icon="login-icon">Login</SidebarLink>
<SidebarLink to="/profile" icon="profile-icon">Profile</SidebarLink>
<span class="collapse-icon" :class="{'rotate-180': collapsed}" @click="toggleSideBar"> <span class="collapse-icon" :class="{'rotate-180': collapsed}" @click="toggleSideBar">
<Svg name="double-arrow" class="sidebar-c-icon"></Svg> <Svg name="double-arrow" class="sidebar-c-icon"/>
</span> </span>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment