Merge branch 'main' of https://github.com/CodingTurtle2/gmci_project
This commit is contained in:
commit
cb859890c0
2 files changed
+342
-104
No files matched your search
+189
@@ -0,0 +1,189 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Sign Up</title>
|
||||||
|
<link rel="stylesheet" href="./lib/basic.css" />
|
||||||
|
<script src="./auth.js" defer></script>
|
||||||
|
<script src="./lib/basic.js" defer></script>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-color: #f6f8fa;
|
||||||
|
padding: 2rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-card {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 2.5rem 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
|
width: 100%;
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup-card h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 0.3rem;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
border: 1px solid #d1d5da;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.6rem;
|
||||||
|
background-color: #2ea44f;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #279f43;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-text {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-text a {
|
||||||
|
color: #0366d6;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-text a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="signup-card">
|
||||||
|
<h1>Create Account</h1>
|
||||||
|
|
||||||
|
<label for="username">Username</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="username"
|
||||||
|
name="username"
|
||||||
|
autocomplete="username"
|
||||||
|
autocapitalize="off"
|
||||||
|
autocorrect="off"
|
||||||
|
required
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
autocomplete="new-password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label for="role">Role</label>
|
||||||
|
<select id="role" name="role" required>
|
||||||
|
<option value="student">Student</option>
|
||||||
|
<option value="professor">Professor</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="button" onclick="signup()">Sign up</button>
|
||||||
|
|
||||||
|
<div class="login-text">
|
||||||
|
Already have an account? <a href="login.html">Sign in</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const couchDB = new CouchDB();
|
||||||
|
|
||||||
|
async function getData() {
|
||||||
|
try {
|
||||||
|
const res = await couchDB.get("users");
|
||||||
|
return res || {};
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to get users:", e);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function signup() {
|
||||||
|
const username = document
|
||||||
|
.getElementById("username")
|
||||||
|
.value.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
const password = document.getElementById("password").value;
|
||||||
|
const role = document.getElementById("role").value;
|
||||||
|
|
||||||
|
if (!username) {
|
||||||
|
return alert("Please enter a username!");
|
||||||
|
}
|
||||||
|
if (!password) {
|
||||||
|
return alert("Please enter a password!");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await getData();
|
||||||
|
|
||||||
|
// Check if user already exists
|
||||||
|
if (data[username]) {
|
||||||
|
return alert("Username already exists!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new user object
|
||||||
|
data[username] = {
|
||||||
|
password: password,
|
||||||
|
level: 1,
|
||||||
|
avatar: null,
|
||||||
|
abilities: [],
|
||||||
|
enabled_abilities: [],
|
||||||
|
role: role,
|
||||||
|
courses: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
await couchDB.set("users", data);
|
||||||
|
alert("Account created successfully!");
|
||||||
|
|
||||||
|
// Redirect to login page
|
||||||
|
location.href = "./login.html";
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to create account:", e);
|
||||||
|
alert("Failed to create account. Please try again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+153
-104
@@ -5,113 +5,162 @@
|
|||||||
<script src="../lib/basic.js"></script>
|
<script src="../lib/basic.js"></script>
|
||||||
<script src="../other/skills.js"></script>
|
<script src="../other/skills.js"></script>
|
||||||
<script src="../other/skilltree.js"></script>
|
<script src="../other/skilltree.js"></script>
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Beispielseite</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-btn {
|
|
||||||
position:absolute;
|
|
||||||
top:20px;
|
|
||||||
left:20px;
|
|
||||||
font-size: 28px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
header {
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 120px;
|
|
||||||
padding-bottom: 40px;
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bewertungsskala */
|
|
||||||
.rating span {
|
|
||||||
font-size: 30px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigationspunkte */
|
|
||||||
.nav-dots {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
font-size: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-dots .active {
|
|
||||||
font-size: 45px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Weiter-Button */
|
|
||||||
.weiter-btn {
|
|
||||||
display: block;
|
|
||||||
width: 150px;
|
|
||||||
margin: 0 auto 30px auto;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 18px;
|
|
||||||
text-align: center;
|
|
||||||
background-color: #007bff;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.weiter-btn:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<Body>
|
|
||||||
|
|
||||||
<div class="close-btn">X</div>
|
|
||||||
|
|
||||||
<header>
|
|
||||||
Verstehen Sie den in der Vorlesung vorgetragenen Inhalt?
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<div class="rating">
|
|
||||||
<span>1</span>
|
|
||||||
<span>2</span>
|
|
||||||
<span>3</span>
|
|
||||||
<span>4</span>
|
|
||||||
<span>5</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<textarea rows="5" cols="40" placeholder="Gib hier deinen Text ein..."></textarea>
|
<Body>
|
||||||
</main>
|
<div id="kurs">
|
||||||
<div class="nav-dots">
|
|
||||||
<span><</span>
|
|
||||||
<span class="active">•</span>
|
|
||||||
<span>•</span>
|
|
||||||
<span>•</span>
|
|
||||||
<span>></span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="weiter-btn">Weiter</button>
|
<div id="frage">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="antworttext">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="weiterbutton">
|
||||||
|
<button onclick="goToNextScreen()">Weiter</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="closebutton">
|
||||||
|
<button onclick="goToMainscreen()">X</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#closebutton{
|
||||||
|
position: fixed;
|
||||||
|
top: 10px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#weiterbutton{
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
#frage{
|
||||||
|
position: fixed;
|
||||||
|
top: 25%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
#kurs{
|
||||||
|
position: fixed;
|
||||||
|
top: 5%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
#antworttext{
|
||||||
|
position: fixed;
|
||||||
|
top: 40%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const couchDB = new CouchDB();
|
||||||
|
//setUserData(couchDB).then(alert);
|
||||||
|
getId("frage").innerHTML=getURLArgsMap();
|
||||||
|
var seitenindex = 0;
|
||||||
|
var antworten = null;
|
||||||
|
var kurslaenge = 0;
|
||||||
|
|
||||||
|
async function setData(position){
|
||||||
|
const kurs = await getCourse();
|
||||||
|
if(!kurs){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const kurslabel = getId("kurs");
|
||||||
|
const fragenlabel = getId("frage");
|
||||||
|
const aktuellefrage = kurs.questions[position];
|
||||||
|
|
||||||
|
kurslabel.innerHTML = kurs.title;
|
||||||
|
fragenlabel.innerHTML = aktuellefrage.title;
|
||||||
|
|
||||||
|
const antwortfeld = getId("antworttext");
|
||||||
|
if(aktuellefrage.type == "text"){
|
||||||
|
antwortfeld.innerHTML = `
|
||||||
|
<textarea class="input"></textarea>
|
||||||
|
`
|
||||||
|
}else if(aktuellefrage.type == "scala"){
|
||||||
|
antwortfeld.innerHTML = `
|
||||||
|
auf einer skala von 1 bis 5: <br>
|
||||||
|
<input type="range" min="1" max="5" class="input"></input>
|
||||||
|
`
|
||||||
|
}else if(aktuellefrage.type == "emoji"){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(antworten == null){
|
||||||
|
kurslaenge = kurs.questions.length;
|
||||||
|
setUserData(couchDB).then(alert);
|
||||||
|
antworten = [];
|
||||||
|
for(var i = 0; i < kurs.questions.length; i++){
|
||||||
|
antworten.push(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
setData(seitenindex);
|
||||||
|
|
||||||
|
async function getCourse(){
|
||||||
|
const args = getURLArgsMap();
|
||||||
|
const coursename = args.course;
|
||||||
|
if(!coursename){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const kurs = await couchDB.get("course:" + coursename);
|
||||||
|
if(!kurs){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return kurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setCourseAnswer(answer) {
|
||||||
|
const args = getURLArgsMap();
|
||||||
|
const coursename = args.course;
|
||||||
|
if (!coursename) return null;
|
||||||
|
const kurs = await couchDB.get("course:" + coursename);
|
||||||
|
if (!kurs) return null;
|
||||||
|
|
||||||
|
kurs.result.push(answer);
|
||||||
|
|
||||||
|
await couchDB.set("course:" + coursename, kurs);
|
||||||
|
|
||||||
|
return kurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToMainscreen(){
|
||||||
|
location.href = "./uebersicht.html?user="+ userData.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function goToNextScreen(){
|
||||||
|
const antwortfeld = getId("antworttext");
|
||||||
|
const wert = antwortfeld.querySelector(".input").value;
|
||||||
|
const isTextField = wert.tagName == "TEXTAREA";
|
||||||
|
if(isTextField){
|
||||||
|
antworten[seitenindex] = wert;
|
||||||
|
}else{
|
||||||
|
antworten[seitenindex] = parseInt(wert);
|
||||||
|
}
|
||||||
|
seitenindex++;
|
||||||
|
if(seitenindex == kurslaenge){
|
||||||
|
setCourseAnswer(antworten);
|
||||||
|
//bitte hier den link zu der zusammenfassung einrichten
|
||||||
|
//location.href = "./uebersicht.html?user="+ userData.name;
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(seitenindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user