Skip to content
Snippets Groups Projects
Commit 3a4372e0 authored by srosse's avatar srosse
Browse files

Merge remote-tracking branch 'origin/OpenOLAT_13.0'

parents 176058eb 92b3a83e
No related branches found
No related tags found
No related merge requests found
...@@ -514,9 +514,7 @@ public class BreadcrumbedStackedPanel extends Panel implements StackedPanel, Bre ...@@ -514,9 +514,7 @@ public class BreadcrumbedStackedPanel extends Panel implements StackedPanel, Bre
BreadCrumb crumb = (BreadCrumb)currentLink.getUserObject(); BreadCrumb crumb = (BreadCrumb)currentLink.getUserObject();
if(crumb.getController() == null) { if(crumb.getController() == null) {
if(crumbIndex - 1 >= 0) { if(crumbIndex - 1 >= 0) {
Link parentLink = stack.get(crumbIndex - 1); setContent(crumbIndex - 1);
BreadCrumb parentCrumb = (BreadCrumb)parentLink.getUserObject();
setContent(parentCrumb.getController());
} }
} else { } else {
setContent(crumb.getController()); setContent(crumb.getController());
......
...@@ -153,7 +153,7 @@ public class PdfDocument { ...@@ -153,7 +153,7 @@ public class PdfDocument {
text = ""; text = "";
} else { } else {
String subString = text.substring(0, spaceIndex); String subString = text.substring(0, spaceIndex);
float size = fontSize * textFont.getStringWidth(subString) / 1000; float size = getStringWidth(subString, textFont, fontSize);
if (size > paragraphWidth) { if (size > paragraphWidth) {
if (lastSpace < 0) // So we have a word longer than the line... draw it anyways if (lastSpace < 0) // So we have a word longer than the line... draw it anyways
lastSpace = spaceIndex; lastSpace = spaceIndex;
...@@ -179,15 +179,20 @@ public class PdfDocument { ...@@ -179,15 +179,20 @@ public class PdfDocument {
} }
public float getStringWidth(String string, float fontSize) public float getStringWidth(String string, float fontSize)
throws IOException {
return getStringWidth(string, font, fontSize);
}
public float getStringWidth(String string, PDFont textFont, float fontSize)
throws IOException { throws IOException {
if(string == null || string.length() == 0) return 0.0f; if(string == null || string.length() == 0) return 0.0f;
try { try {
string = cleanString(string); string = cleanString(string);
return fontSize * font.getStringWidth(string) / 1000; return fontSize * textFont.getStringWidth(string) / 1000;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.error("", e); log.error("", e);
return getStringEstimatedWidth(string.length(), fontSize); return getStringEstimatedWidth(string.length(), textFont, fontSize);
} }
} }
...@@ -199,10 +204,10 @@ public class PdfDocument { ...@@ -199,10 +204,10 @@ public class PdfDocument {
* @return A width * @return A width
* @throws IOException * @throws IOException
*/ */
public float getStringEstimatedWidth(int length, float fontSize) throws IOException { public float getStringEstimatedWidth(int length, PDFont textFont, float fontSize) throws IOException {
char[] onlyA = new char[length]; char[] onlyA = new char[length];
Arrays.fill(onlyA, 'A'); Arrays.fill(onlyA, 'A');
return fontSize * font.getStringWidth(String.valueOf(onlyA)) / 1000.0f; return fontSize * textFont.getStringWidth(String.valueOf(onlyA)) / 1000.0f;
} }
public static String cleanString(String string) { public static String cleanString(String string) {
......
...@@ -205,13 +205,16 @@ public class CorrectionAssessmentItemListController extends FormBasicController ...@@ -205,13 +205,16 @@ public class CorrectionAssessmentItemListController extends FormBasicController
for(Map.Entry<Identity, AssessmentTestSession> entry:model.getLastSessions().entrySet()) { for(Map.Entry<Identity, AssessmentTestSession> entry:model.getLastSessions().entrySet()) {
if(model.getLastSessions().containsKey(entry.getKey())) { if(model.getLastSessions().containsKey(entry.getKey())) {
TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey()); TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
for(Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry:testSessionState.getItemSessionStates().entrySet()) { Map<TestPlanNodeKey, ItemSessionState> itemSessionStates = (testSessionState == null ? null : testSessionState.getItemSessionStates());
String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString(); if(itemSessionStates != null) {
CorrectionAssessmentItemRow row = itemRefIdToRows.get(itemRefIdentifier); for(Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry:itemSessionStates.entrySet()) {
if(row != null) { String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
AssessmentItemSession itemSession = itemSessionMap CorrectionAssessmentItemRow row = itemRefIdToRows.get(itemRefIdentifier);
.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier)); if(row != null) {
appendStatistics(row, itemSession, itemEntry.getValue()); AssessmentItemSession itemSession = itemSessionMap
.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
appendStatistics(row, itemSession, itemEntry.getValue());
}
} }
} }
} }
......
...@@ -778,12 +778,11 @@ public class ForumManager { ...@@ -778,12 +778,11 @@ public class ForumManager {
* @param creator * @param creator
* @param replyToMessage * @param replyToMessage
*/ */
public void replyToMessage(Message newMessage, Message replyToMessage) { public Message replyToMessage(Message newMessage, Message replyToMessage) {
Message top = replyToMessage.getThreadtop(); Message top = replyToMessage.getThreadtop();
newMessage.setThreadtop((top != null ? top : replyToMessage)); newMessage.setThreadtop((top != null ? top : replyToMessage));
newMessage.setParent(replyToMessage); newMessage.setParent(replyToMessage);
return saveMessage(newMessage);
saveMessage(newMessage);
} }
/** /**
...@@ -791,10 +790,10 @@ public class ForumManager { ...@@ -791,10 +790,10 @@ public class ForumManager {
* @param forum * @param forum
* @param topMessage * @param topMessage
*/ */
public void addTopMessage(Message topMessage) { public Message addTopMessage(Message topMessage) {
topMessage.setParent(null); topMessage.setParent(null);
topMessage.setThreadtop(null); topMessage.setThreadtop(null);
saveMessage(topMessage); return saveMessage(topMessage);
} }
/** /**
......
...@@ -494,7 +494,7 @@ public class MessageEditController extends FormBasicController { ...@@ -494,7 +494,7 @@ public class MessageEditController extends FormBasicController {
if(editMode == EditMode.newThread) { if(editMode == EditMode.newThread) {
if(foCallback.mayOpenNewThread()) { if(foCallback.mayOpenNewThread()) {
// save a new thread // save a new thread
fm.addTopMessage(message); message = fm.addTopMessage(message);
fm.markNewMessageAsRead(getIdentity(), forum, message); fm.markNewMessageAsRead(getIdentity(), forum, message);
persistTempUploadedFiles(message); persistTempUploadedFiles(message);
// if notification is enabled -> notify the publisher about news // if notification is enabled -> notify the publisher about news
...@@ -527,7 +527,7 @@ public class MessageEditController extends FormBasicController { ...@@ -527,7 +527,7 @@ public class MessageEditController extends FormBasicController {
showWarning("may.not.save.msg.as.author"); showWarning("may.not.save.msg.as.author");
} }
} else if(editMode == EditMode.reply) { } else if(editMode == EditMode.reply) {
fm.replyToMessage(message, parentMessage); message = fm.replyToMessage(message, parentMessage);
fm.markNewMessageAsRead(getIdentity(), forum, message); fm.markNewMessageAsRead(getIdentity(), forum, message);
persistTempUploadedFiles(message); persistTempUploadedFiles(message);
notifiySubscription(); notifiySubscription();
...@@ -657,11 +657,7 @@ public class MessageEditController extends FormBasicController { ...@@ -657,11 +657,7 @@ public class MessageEditController extends FormBasicController {
* @return the edited message * @return the edited message
*/ */
public Message getMessage() { public Message getMessage() {
if (!StringHelper.containsNonWhitespace(message.getTitle()) && message == null) { return message;
throw new AssertException("Getting back the edited message failed! You first have to edit one and intialize properly!");
} else {
return message;
}
} }
/** /**
......
...@@ -310,7 +310,7 @@ public class MessageListController extends BasicController implements GenericEve ...@@ -310,7 +310,7 @@ public class MessageListController extends BasicController implements GenericEve
} else { } else {
scrollTo(message); scrollTo(message);
} }
} else if(message != null) { } else if(message != null && message.getKey() != null) {
MessageView view = loadView(ureq, message); MessageView view = loadView(ureq, message);
int index = 0; int index = 0;
for(int i=0; i<backupViews.size(); i++) { for(int i=0; i<backupViews.size(); i++) {
......
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