Skip to content

Commit

Permalink
SEBSERV-479 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Nov 21, 2023
1 parent 6be552b commit 455d980
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class MoodleUtils {

private static final Logger log = LoggerFactory.getLogger(MoodleUtils.class);

public static final String getInternalQuizId(
public static String getInternalQuizId(
final String quizId,
final String courseId,
final String shortname,
Expand All @@ -47,29 +47,41 @@ public static final String getInternalQuizId(
new String[] {
quizId,
courseId,
StringUtils.isNotBlank(shortname) ? shortname : Constants.EMPTY_NOTE,
StringUtils.isNotBlank(shortname) ? maskShortName(shortname) : Constants.EMPTY_NOTE,
StringUtils.isNotBlank(idnumber) ? idnumber : Constants.EMPTY_NOTE
},
Constants.COLON);
}

public static final String getQuizId(final String internalQuizId) {
private static String maskShortName(final String shortname) {
return shortname
.replace(Constants.SEMICOLON.toString(), "_SC_")
.replace(Constants.COLON.toString(), "_COLON_");
}

private static String unmaskShortName(final String shortname) {
return shortname
.replace("_SC_", Constants.SEMICOLON.toString())
.replace("_COLON_", Constants.COLON.toString());
}

public static String getQuizId(final String internalQuizId) {
if (StringUtils.isBlank(internalQuizId)) {
return null;
}

return StringUtils.split(internalQuizId, Constants.COLON)[0];
}

public static final String getCourseId(final String internalQuizId) {
public static String getCourseId(final String internalQuizId) {
if (StringUtils.isBlank(internalQuizId)) {
return null;
}

return StringUtils.split(internalQuizId, Constants.COLON)[1];
}

public static final String getShortname(final String internalQuizId) {
public static String getShortname(final String internalQuizId) {
if (StringUtils.isBlank(internalQuizId)) {
return null;
}
Expand All @@ -80,7 +92,7 @@ public static final String getShortname(final String internalQuizId) {
}

final String shortName = split[2];
return shortName.equals(Constants.EMPTY_NOTE) ? null : shortName;
return shortName.equals(Constants.EMPTY_NOTE) ? null : unmaskShortName(shortName);
}

public static final String getIdnumber(final String internalQuizId) {
Expand Down

0 comments on commit 455d980

Please sign in to comment.