Skip to content

Commit

Permalink
SAK-46390: T&Q: If timed, no validation on initial save & publish, me…
Browse files Browse the repository at this point in the history
…ssage rewording needed (sakaiproject#9916)

* SAK-46390 Make Listener for 'Save and Publish' also accept string value for isTimed

* SAK-46390 Reword error message

Co-authored-by: Markus Stetschnig <[email protected]>
  • Loading branch information
stetsche and stetsche authored Oct 8, 2021
1 parent 3c1e7a4 commit 6149bcf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ time_limit=Time Limit
no_time_limit= No Time Limit

#ERROR
timeSelect_error=Please specify a time limit in hours and/or minutes, or uncheck the "has a time limit of" box.
timeSelect_error=Please specify a time limit in hours and/or minutes, or select the "No" option.
assessmentName_error= You cannot have duplicate assessment titles. Please choose another title.
gbConflict_error= Another item with the same title exists in Gradebook. Please choose another title.
assessmentName_empty= Assessment Name should not be empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,28 @@ else if (assessmentSettings.getAutoSubmit() && retractDate == null) {
}


//#2c - validate if this is a time assessment, is there a time entry?
Object time=assessmentSettings.getValueMap().get("hasTimeAssessment");
boolean isTime=false;
if (time!=null) {
// Because different flow might get different type, we test it before cast.
if (time instanceof java.lang.String) {
isTime = Boolean.getBoolean((String) time);
}
else if (time instanceof java.lang.Boolean) {
isTime= (Boolean) time;
}
}

Object time=assessmentSettings.getValueMap().get("hasTimeAssessment");
boolean isTime=false;
try
{
if (time != null) {
if (time instanceof String) {
String timeStr = time.toString();
if ("true".equals(timeStr)) {
isTime = true;
} else if ("false".equals(timeStr)) {
isTime = false;
}
} else {
isTime = ( (Boolean) time).booleanValue();
}
}
}
catch (Exception ex)
{
// keep default
log.warn("Expecting Boolean or String true/false for hasTimeAssessment, got: " + time + ", exception: " + ex.getMessage());
}

if ((isTime) &&((assessmentSettings.getTimeLimit())==0)){
String time_err=ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages","timeSelect_error");
Expand Down

0 comments on commit 6149bcf

Please sign in to comment.