Skip to content
Snippets Groups Projects
Commit 5367eaa0 authored by Thomas Schnaak's avatar Thomas Schnaak
Browse files

fix: edited journals arn no saved correctly

parent 72558e05
No related branches found
No related tags found
No related merge requests found
......@@ -57,5 +57,11 @@ public interface IJournal {
* @return EPortfolio (containing Report, ProjectDescription and Journal)
*/
EPortfolio getFinalPortfolioForAssessment(Project project, User user);
EPortfolio getFinalPortfolioForAssessment(Project project, User user) ;
EPortfolio getPortfolio(String project, String user);
byte[] exportPortfolioToPdf(EPortfolio ePortfolio);
}
package unipotsdam.gf.modules.journal.service;
import com.qkyrie.markdown2pdf.Markdown2PdfConverter;
import com.qkyrie.markdown2pdf.internal.exceptions.ConversionException;
import com.qkyrie.markdown2pdf.internal.exceptions.Markdown2PdfLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import unipotsdam.gf.core.management.project.Project;
......@@ -9,13 +12,12 @@ import unipotsdam.gf.interfaces.IJournal;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.journal.model.EPortfolio;
import unipotsdam.gf.modules.journal.model.Journal;
import unipotsdam.gf.modules.peer2peerfeedback.Category;
import unipotsdam.gf.modules.researchreport.ResearchReport;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
public class IJournalImpl implements IJournal {
......@@ -24,6 +26,7 @@ public class IJournalImpl implements IJournal {
private final JournalService journalService = new JournalServiceImpl();
private final ProjectDescriptionService descriptionService = new ProjectDescriptionImpl();
private final SimpleDateFormat jdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
@Override
public Map<StudentIdentifier, ConstraintsMessages> getPortfoliosForEvaluationPrepared(Project project) {
......@@ -60,26 +63,158 @@ public class IJournalImpl implements IJournal {
@Override
public void uploadJournalEntry(Journal journalEntry, User student) {
//TODO
journalService.saveJournal("0",student.getId(),journalEntry.getStudentIdentifier().getProjectId(),journalEntry.getEntryMD(),journalEntry.getVisibility().toString(),journalEntry.getCategory().toString());
}
@Override
public void uploadFinalPortfolio(Project project, List<Journal> journalEntries, ResearchReport finalResearchReport, File presentation, User user) {
//TODO
//TODO for version 2
}
@Override
public EPortfolio getFinalPortfolioForAssessment(Project project, User user) {
return getPortfolio(project.getId(), user.getId());
}
@Override
public EPortfolio getPortfolio(String project, String user) {
EPortfolio result = new EPortfolio();
StudentIdentifier studentIdentifier = new StudentIdentifier(project.getId(), user.getId());
StudentIdentifier studentIdentifier = new StudentIdentifier(project, user);
result.setDescription(descriptionService.getProjectByStudent(studentIdentifier));
result.setJournals(journalService.getAllJournals(user.getId(), project.getId()));
result.setJournals(journalService.getAllJournals(user, project));
//TODO result.setReport(...);
return result;
}
@Override
public byte[] exportPortfolioToPdf(EPortfolio ePortfolio) {
//IntelliJs solution for lambda statement
final byte[][] res = new byte[1][1];
//Build String
String input = ePortfolioToString(ePortfolio);
//Convert
try {
Markdown2PdfConverter
.newConverter()
.readFrom(() -> input)
.writeTo(out -> {
res[0] = out;
})
.doIt();
} catch (ConversionException | Markdown2PdfLogicException e) {
e.printStackTrace();
}
return res[0];
}
//TODO Formatierung
private String ePortfolioToString(EPortfolio ePortfolio) {
StringBuilder result = new StringBuilder();
//If Description exists, add to pdf
if (ePortfolio.getDescription() != null) {
result.append("#Portfolio# \n\n");
result.append(ePortfolio.getDescription().getDescriptionMD()).append("\n");
}
//If Journals and Report exists combine
if (ePortfolio.getReport() != null && ePortfolio.getJournals() != null && !ePortfolio.getJournals().isEmpty()) {
ArrayList<Journal> journals = ePortfolio.getJournals();
ResearchReport researchReport = ePortfolio.getReport();
//TODO zuordnung Absprechen
result.append(researchReport.getTitle()).append("\n");
result.append(journalStringByCategory(journals, Category.TITEL));
result.append(researchReport.getResearchQuestion()).append("\n");
result.append(journalStringByCategory(journals, Category.FORSCHUNGSFRAGE));
for (String s : researchReport.getLearningGoals()) {
result.append(s).append("\n");
}
result.append(researchReport.getMethod()).append("\n");
//TODO zuordnung Absprechen
result.append(journalStringByCategory(journals, Category.UNTERSUCHUNGSKONZEPT));
result.append(journalStringByCategory(journals, Category.METHODIK));
result.append(researchReport.getResearch()).append("\n");
result.append(journalStringByCategory(journals, Category.RECHERCHE));
result.append(researchReport.getResearchResult()).append("\n");
result.append(journalStringByCategory(journals, Category.DURCHFUEHRUNG));
result.append(researchReport.getEvaluation()).append("\n");
result.append(journalStringByCategory(journals, Category.AUSWERTUNG));
//TODO Extract String when implemented
result.append(researchReport.getBibliography()).append("\n");
result.append(journalStringByCategory(journals, Category.LITERATURVERZEICHNIS));
}
//if Report but no Journals, add Report
else if (ePortfolio.getReport() != null) {
ResearchReport report = ePortfolio.getReport();
result.append(report.getTitle()).append("\n");
result.append(report.getResearchQuestion()).append("\n");
for (String s : report.getLearningGoals()) {
result.append(s).append("\n");
}
result.append(report.getMethod()).append("\n");
result.append(report.getResearch()).append("\n");
result.append(report.getResearchResult()).append("\n");
result.append(report.getEvaluation()).append("\n");
//TODO Extract String when implemented
result.append(report.getBibliography()).append("\n");
}
//If Journal but no Report
else if (ePortfolio.getJournals() != null) {
result.append("##Lerntagebuch## \n\n");
for (Journal j : ePortfolio.getJournals()) {
result.append(journalAsString(j));
}
}
return result.toString();
}
private String journalStringByCategory(ArrayList<Journal> journals, Category c) {
StringBuilder str = new StringBuilder();
for (Journal j : journals) {
if (j.getCategory().equals(c)) {
str.append(journalAsString(j));
}
}
return str.toString();
}
private String journalAsString(Journal j) {
return jdf.format(new Date(j.getTimestamp())) + " " + j.getCategory() + "\n" + j.getEntryMD() + "\n";
}
}
......@@ -80,7 +80,7 @@ public class JournalServiceImpl implements JournalService {
Journal journal = new Journal(id, new StudentIdentifier(project, student), text, JournalUtils.stringToVisibility(visibility), JournalUtils.stringToCategory(category));
//if id = 0 new Journal else update
if (id.equals("0")) {
if (id.equals("")) {
log.debug("save journal: create new");
journalDAO.createJournal(journal);
......
......@@ -100,7 +100,7 @@ public class JournalView {
URI location;
try {
location = new URI("../pages/eportfolio.jsp?token=" + student + "&projectId=" + project);
location = new URI("../journal/eportfolio.jsp?token=" + student + "&projectId=" + project);
log.debug("<<< createJournal: redirect to " + location.toString());
return Response.temporaryRedirect(location).build();
......@@ -145,7 +145,7 @@ public class JournalView {
StudentIdentifier student = journalService.getJournal(journal).getStudentIdentifier();
journalService.closeJournal(journal);
try {
URI location = new URI("../pages/eportfolio.jsp?token=" + student.getStudentId() + "&projectId=" + student.getProjectId());
URI location = new URI("../journal/eportfolio.jsp?token=" + student.getStudentId() + "&projectId=" + student.getProjectId());
log.debug("<<< closeJournal: redirect to " +location.toString());
return Response.temporaryRedirect(location).build();
......
......@@ -35,7 +35,7 @@
<td id="yourContent">
<h1> Tagebucheintrag erstellen </h1>
<form id="journalform" class="form-journal" method="POST" action="rest/journal/save">
<form id="journalform" class="form-journal" method="POST" action="../rest/journal/save">
<input type="hidden" id="student" name="student">
<input type="hidden" id="project" name="project">
......
var student = getQueryVariable("token");
var project = getQueryVariable("projectId");
var journal = getQueryVariable("journal");
$(document).ready(function () {
......@@ -11,9 +12,10 @@ $(document).ready(function () {
});
$.ajax({
url: "../rest/projectdescription/" + student + "/" + project
url: "../rest/journal/" + journal
}).then(function (data) {
$('#editor').append(data.descriptionMD);
$('#editor').append(data.entryMD);
$('#journalid').val(journal);
//TODO preselet in select tags
new InscrybMDE({
......
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