Commit 8610af15 by Nilu Committed by Harsh Shah

fixed issues in C008, C004

parent ebc0974d
package performa.form;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import performa.orm.Answer;
import performa.orm.JobApplication;
public class SaveAndExitWorkStypeFP extends SaveFP
{
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
JobApplication jobApplication = process.getAttribute("JobApplication") != null ? (JobApplication) process.getAttribute("JobApplication") : (JobApplication) request.getAttribute("JobApplication");
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In SaveAndExitWorkStypeFP saving job application: ", jobApplication );
for (Answer answer : jobApplication.getProfileAssessmentAnswersSet())
{
if(answer.getAnswerNo() == null)
{
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In SaveAndExitWorkStypeFP deleting ProfileAssessmentAnswer : ", answer );
answer.delete();
}
}
return super.processForm(process, submission, params);
}
}
\ No newline at end of file
......@@ -62,7 +62,7 @@ public class Job extends BaseJob
if (getIncludeAssessmentCriteria())
{
context.check(getAssessmentCriteriasCount() > 0 , this, MULTIPLEREFERENCE_AssessmentCriterias, "atleastOneRequirement");
context.check(getAssessmentCriteriasCount() > 0 , this, FIELD_IncludeAssessmentCriteria, "atleastOneRequirement");
}
context.check(getSaveAssessmentTemplate() == null || !getSaveAssessmentTemplate() , this, FIELD_AssessmentTemplateName, "saveTemplateFirst");
......
......@@ -116,32 +116,47 @@ public class JobApplication extends BaseJobApplication
}
public boolean initAssessmentAnswers(List<Question> allQuestions) throws StorageException, FieldException
public boolean initAssessmentAnswers(List<Question> questions) throws StorageException, FieldException
{
boolean redirect = false;
boolean redirect = false;
List<Question> allQuestions = new ArrayList<>();
if(getProfileAssessmentAnswersCount() == 0)
for(Question question : questions)
{
for(Question question : allQuestions)
{
redirect = true;
Answer answer = Answer.createAnswer(getTransaction());
allQuestions.add(question);
addToProfileAssessmentAnswers(answer);
answer.setQuestion(question);
if(question.getRightQuestion() != null)
{
allQuestions.add(question.getRightQuestion());
}
}
for(Question question : allQuestions)
{
boolean available = false;
if(question.getRightQuestion() != null)
for(Answer answer : getProfileAssessmentAnswersSet())
{
if(question.equals(answer.getQuestion()))
{
Answer rightAnswer = Answer.createAnswer(getTransaction());
addToProfileAssessmentAnswers(rightAnswer);
rightAnswer.setQuestion(question.getRightQuestion());
available = true;
break;
}
}
}
if(!available)
{
Answer answer = Answer.createAnswer(getTransaction());
addToProfileAssessmentAnswers(answer);
answer.setQuestion(question);
redirect = true;
}
}
return redirect;
}
public Answer getAnswerForQuestion(Question question) throws FieldException
{
Filter filter = Answer.SearchByAll().andQuestion(new EqualsFilter<>(question));
......
......@@ -7,6 +7,7 @@
<FORM name="*.completeApplication" factory="Participant" class="performa.form.CompleteApplicationFP"/>
<FORM name="*.saveAndExitExperienece" factory="Participant" class="performa.form.SaveAndExitExperienceFP"/>
<FORM name="*.saveAndExitCulture" factory="Participant" class="performa.form.SaveAndExitCultureFP"/>
<FORM name="*.saveAndExitWorkStyle" factory="Participant" class="performa.form.SaveAndExitWorkStypeFP"/>
</NODE>
......
......@@ -10,10 +10,10 @@
String nextPage = WebUtils.getSamePageInRenderMode(request, "SubmitApplication");
JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication");
Job job = jobApplication.getJob();
int questionNumber = process.getAttribute("QuestionNumber")!= null ? (int) process.getAttribute("QuestionNumber") : 0;
String sectionNo = jobApplication.isIncludeAssessmentCriteria() ? "3" : "2";
int questionNumber = process.getAttribute("QuestionNumber")!= null ? (int) process.getAttribute("QuestionNumber") : jobApplication.getProfileAssessmentAnswersCount();
List<Question> allQuestions = (List<Question>) process.getAttribute("AllQuestions");
String exitPage = WebUtils.getArticleLink(request, transaction, WebUtils.APPLY_JOB, "Page") + "&id=" + job.getID() + "&key=" + job.getRandomKey();
if(allQuestions == null)
{
allQuestions = job.getAllLeftQuestions();
......@@ -25,6 +25,8 @@
if(toRedirect)
{
process.setAttribute("QuestionNumber", questionNumber);
%><%@include file="/saferedirect.jsp" %><%
}
%>
......@@ -38,6 +40,11 @@
$(".ratting-number input[type='radio']:checked").closest('li').addClass("active" );
});
});
function gotoNextQuestion()
{
$("#nextButton").click();
}
</script>
<div class="main-application-outline">
......@@ -138,7 +145,7 @@
%>
<li class="<%= activeStr %>">
<a href="javascript:void(0);">
<input type="radio" name="<%= optionKey %>" id="<%= index %>" class="answer_radio" value="<%= index %>" <%= selectedStr %>>
<input type="radio" name="<%= optionKey %>" id="<%= index %>" onchange="gotoNextQuestion();" class="answer_radio" value="<%= index %>" <%= selectedStr %>>
<label for="<%= index %>"><%= index %></label>
</a>
</li>
......@@ -165,47 +172,38 @@
}
%>
<div>
<span style="float: left">
<%
if(questionNumber>0)
if((questionNumber+1) < totNoOfQuestions)
{
%>
<oneit:button value="Previous" name="gotoPage" cssClass="box-btn-gray"
<oneit:button value=" " name="gotoPage" id="nextButton" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
.mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber - 1)).toMap())
.mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber + 1)).toMap())
.toMap() %>"/>
<%
}
%>
</span>
<span style="float: right">
<%
if((questionNumber+1)<totNoOfQuestions)
else
{
%>
<oneit:button value="Next" name="gotoPage" cssClass="box-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
.mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber + 1)).toMap())
.toMap() %>"/>
<oneit:button value="Complete" name="completeApplication" id="nextButton" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
.mapEntry("attribNamesToRestore", Collections.singleton("JobApplication"))
.mapEntry("restartProcess", Boolean.TRUE)
.toMap() %>"/>
<%
}
%>
</span>
</div>
<div class="auto-save">
<%
if((questionNumber+1) == totNoOfQuestions)
{
%>
<oneit:button value="Complete" name="completeApplication" cssClass="box-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
.mapEntry("attribNamesToRestore", Collections.singleton("JobApplication"))
.mapEntry("restartProcess", Boolean.TRUE)
.toMap() %>"/>
<%
}
%>
<span style="float: left">
<oneit:button value="Save and exit" name="saveAndExitWorkStyle" cssClass="box-btn-gray"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage)
.mapEntry ("JobApplication", jobApplication)
.mapEntry(UpdateMappedObjFP.FAIL_VALIDATION_ERRORS, Boolean.FALSE)
.toMap() %>"/>
</span>
<%-- <div>Autosaved 1 min ago.</div> --%>
</div>
</div>
......
......@@ -30,12 +30,14 @@
<oneit:toString value="<%= job.getJobTitle() %>" mode="EscapeHTML"/>
has been submitted for review.
</div>
<div class="section-btn text-center">
<oneit:button value="Return to Job Details" name="gotoPage" cssClass="box-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage)
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
.toMap() %>"/>
</div>
<oneit:form name="applyJob" method="post" enctype="multipart/form-data">
<div class="section-btn text-center">
<oneit:button value="Return to Job Details" name="gotoPage" cssClass="box-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage)
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
.toMap() %>"/>
</div>
</oneit:form>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment