Skip to content

Commit

Permalink
SEBSERV-607 cut shortname to max 200 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Dec 12, 2024
1 parent 7e53995 commit c1159cc
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static String getInternalQuizId(
final String courseId,
final String shortname,
final String idnumber) {

return StringUtils.join(
new String[] {
quizId,
Expand All @@ -54,14 +54,25 @@ public static String getInternalQuizId(
}

private static String maskShortName(final String shortname) {
return shortname
if (shortname == null) {
return null;
}

String shortName = shortname
.replace(Constants.SEMICOLON.toString(), "_SC_")
.replace(Constants.COLON.toString(), "_COLON_")
.replace(Constants.SLASH.toString(), "_SL_")
.replace(Constants.BACKSLASH.toString(), "_BSL_")
.replace(Constants.AMPERSAND.toString(), "_AMP_")
.replace(Constants.ANGLE_BRACE_OPEN.toString(), "_AO_")
.replace(Constants.ANGLE_BRACE_CLOSE.toString(), "_AC_");

if (shortName.length() > 200) {
log.warn("Moodle course short name is too long: {}. Cut it down to 200 chars", shortName.length());
shortName = shortName.substring(0, 200);
}

return shortName;
}

private static String unmaskShortName(final String shortname) {
Expand Down

0 comments on commit c1159cc

Please sign in to comment.