Skip to content
Snippets Groups Projects
Commit 3e74dc18 authored by Axel's avatar Axel
Browse files

feat: first real db to website works!! on viewQuiz.jsp

parent 0e6a32a0
No related branches found
No related tags found
No related merge requests found
Showing
with 67 additions and 20 deletions
......@@ -203,15 +203,15 @@ public class ManagementImpl implements Management {
public Quiz getQuizByProjectGroupId(String projectId, String quizId){
MysqlConnect connect = new MysqlConnect();
connect.connect();
String mysqlRequest = "SELECT * FROM quiz where projectId=" + projectId + " , question="+quizId;
String mysqlRequest = "SELECT * FROM quiz where projectId=? AND question=?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, "");
connect.issueSelectStatement(mysqlRequest, projectId,quizId);
boolean next = vereinfachtesResultSet.next();
String question = "";
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
String answer = "";
Boolean correct = false;
String answer;
Boolean correct;
String mcType = "";
while (next) {
mcType = vereinfachtesResultSet.getString("mcType");
......@@ -230,6 +230,49 @@ public class ManagementImpl implements Management {
return quiz;
}
public ArrayList<Quiz> getQuizByProjectId(String projectId) {
MysqlConnect connect = new MysqlConnect();
ArrayList<Quiz> result= new ArrayList<Quiz>();
connect.connect();
String mysqlRequest = "SELECT * FROM quiz where projectId= ?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, projectId);
boolean next = vereinfachtesResultSet.next();
String question = "";
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
String answer;
String oldQuestion="";
Boolean correct;
String mcType = "";
while (next) {
mcType = vereinfachtesResultSet.getString("mcType");
question = vereinfachtesResultSet.getString("question");
answer = vereinfachtesResultSet.getString("answer");
correct = vereinfachtesResultSet.getBoolean("correct");
if (oldQuestion.equals(question)){
if (correct){
correctAnswers.add(answer);
}else{
incorrectAnswers.add(answer);
}
}else{
result.add(new Quiz(mcType,question, correctAnswers, incorrectAnswers));
correctAnswers.clear();
incorrectAnswers.clear();
if (correct){
correctAnswers.add(answer);
}else{
incorrectAnswers.add(answer);
}
}
oldQuestion = question;
next = vereinfachtesResultSet.next();
}
return result;
}
private User getUserByField(String field, String value) {
MysqlConnect connect = new MysqlConnect();
connect.connect();
......
......@@ -22,7 +22,7 @@ public class PeerAssessment implements IPeerAssessment {
@Override //returns all quizzes in the course
public ArrayList<Quiz> getQuiz(String projectId) {
return null;
return new ManagementImpl().getQuizByProjectId(projectId);
}
@Override
......
......@@ -12,7 +12,7 @@ import java.util.List;
@Path("/assessments")
public class QuizView implements IPeerAssessment {
private static IPeerAssessment peer = new PeerAssessmentDummy(); //TestSubject
private static IPeerAssessment peer = new PeerAssessment(); //TestSubject
//private static IPeerAssessment peer = new PeerAssessment(); //correct DB-conn and stuff
@GET
@Produces(MediaType.APPLICATION_JSON)
......@@ -60,7 +60,7 @@ public class QuizView implements IPeerAssessment {
public Assessment getAssessmentDataFromDB(@PathParam("projectId") String projectId,@PathParam("studentId") String studentId){
StudentIdentifier student = new StudentIdentifier(projectId, studentId);
return getAssessmentDataFromDB(student);
} ///////////////////////////////funktioniert wie geplant//////////////////////////////////
} //////////dummy//////////////funktioniert wie geplant//////////////////////////////////
@POST
......@@ -71,6 +71,7 @@ public class QuizView implements IPeerAssessment {
public void createQuiz(StudentAndQuiz studentAndQuiz) {
peer.createQuiz(studentAndQuiz);
}
////////////////////////////////todo: sollte das nächste Element sein, was ich baue////////
@POST
@Consumes(MediaType.APPLICATION_JSON)
......@@ -80,6 +81,7 @@ public class QuizView implements IPeerAssessment {
public List<Grading> calculateAssessment(ArrayList<Performance> totalPerformance) {
return peer.calculateAssessment(totalPerformance);
}
///////////////dummy/////////funktioniert glaube ich!?////////////////////////////////////////
@GET
@Produces(MediaType.APPLICATION_JSON)
......@@ -96,12 +98,12 @@ public class QuizView implements IPeerAssessment {
public ArrayList<Performance> getTotalAssessment(@PathParam("projectId") String ProjectId,@PathParam("student") String student){
StudentIdentifier studentIdentifier = new StudentIdentifier(ProjectId, student);
return getTotalAssessment(studentIdentifier);
} ///////////////////////////////funktioniert wie geplant//////////////////////////////////
} //////////dummy/////////////funktioniert wie geplant//////////////////////////////////
@Override
public ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) {
return peer.getTotalAssessment(studentIdentifier);
} ///////////////////////////////funktioniert wie geplant//////////////////////////////////
} /////////dummy/////////////funktioniert wie geplant//////////////////////////////////
@GET
......@@ -116,6 +118,6 @@ public class QuizView implements IPeerAssessment {
result.add(pf);
result.add(pf2);
return result;
} ///////////////////////////////returns what i expect it to return!!!!!//////////////////////////////////
} /////////dummy////////////returns what i expect it to return!!!!!//////////////////////////////////
}
$(document).ready(function(){
var projectId = document.getElementById('projectId').innerText.trim();
$.ajax({
url: '../rest/assessments/project/1/quiz/',
url: '../rest/assessments/project/'+projectId+'/quiz/',
type: 'GET',
success: function (data) {
var table = document.getElementById('myQuizzes');
......
$(document).ready(function () {
$("#save").on('click', function () {
$("#save").on('click', function () {//todo: remember to cut out whitespace and signs (?.,;)
document.location = "Quiz.jsp?token=" + getUserTokenFromUrl();
});
});
......@@ -28,8 +28,9 @@ $(document).ready(function () {
return 'CORRECT';
};
var projectId = document.getElementById('projectId').innerText.trim();
$.ajax({
url: '../rest/assessments/project/1/quiz/',
url: '../rest/assessments/project/'+projectId+'/quiz/',
type: 'GET',
success: function (data) {
var table = document.getElementById('tableQuiz');
......
......@@ -34,9 +34,9 @@ $(document).ready(function () {
$_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
}
var quizId = $_GET['quizId'];
var projectId = document.getElementById('projectId').innerText.trim();
$.ajax({
url: '../rest/assessments/project/1/quiz/'+quizId,
url: '../rest/assessments/project/'+projectId+'/quiz/'+quizId,
type: 'GET',
success: function (data) {
var table = document.getElementById('tableQuiz');
......
......@@ -30,7 +30,7 @@
<menu:menu></menu:menu>
<div class="page-content-wrapper">
<div class="container-fluid">
<h1 id="projectId">project1
<h1 id="projectId">gemeinsamForschen
<a href="#">
<span class="glyphicon glyphicon-envelope"
style="font-size:27px;margin-top:-17px;margin-left:600px;"></span>
......
......@@ -33,7 +33,7 @@
</div>
<div style="margin-left:50px;">
<div>
<input placeholder="Ihre Frage">
<input placeholder="Ihre Frage"><!--todo: remember to cut out whitespace and signs (?.,;)-->
</div>
<div><label><input type="radio" name="type">Schwierigkeit 3</label></div>
<div><label><input type="radio" name="type">Schwierigkeit 2</label></div>
......
......@@ -24,7 +24,7 @@
<menu:menu></menu:menu>
<div class="page-content-wrapper">
<div class="container-fluid">
<h1 id="projectId">project1
<h1 id="projectId">gemeinsamForschen
<a href="#">
<span class="glyphicon glyphicon-envelope"
style="font-size:27px;margin-top:-17px;margin-left:600px;"></span>
......@@ -37,7 +37,7 @@
<table>
<tr>
<td id="yourContent">
<h1>Quiz for project1 </h1>
<h1>Quiz for gemeinsamForschen </h1>
<!-- here will be all the content -->
......
......@@ -25,7 +25,7 @@
<menu:menu></menu:menu>
<div class="page-content-wrapper">
<div class="container-fluid">
<h1 id="projectId">project1
<h1 id="projectId">gemeinsamForschen
<a href="#">
<span class="glyphicon glyphicon-envelope"
style="font-size:27px;margin-top:-17px;margin-left:600px;"></span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment