Commit 2f4640ff by Muhammad Usman

go back to prev question

parent 0e4837db
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
<div class="assessment-body-header"> <div class="assessment-body-header">
<div class="assessment-heading">Workplace Preferences</div> <div class="assessment-heading">Workplace Preferences</div>
<span class="assessment-estimation"> <i class="fa fa-clock-o"></i> <strong>Estimated time to complete</strong>: 5 mins</span> <span class="assessment-estimation">
<img src="assets/images/clck.png" alt="" style="width: 16px; margin-top: -2px;">
<strong>Estimated time to complete</strong>: 5 mins</span>
</div> </div>
<div class="assessment-body-description"> <div class="assessment-body-description">
...@@ -34,10 +36,17 @@ ...@@ -34,10 +36,17 @@
<div class="answer-options"> <div class="answer-options">
<div class="answer-option" *ngFor="let question of workPreferenceQuestion?.CultureElement?.Questions"> <div class="answer-option" *ngFor="let question of workPreferenceQuestion?.CultureElement?.Questions">
<p-radioButton [label]="question.Description" name="ANSWER" [value]="question.ObjectID" (onClick)="submitAnswer(question)"> <p-radioButton [(ngModel)]="selectedAns" [label]="question.Description" name="ANSWER" [value]="question.ObjectID" (onClick)="submitAnswer(question)">
</p-radioButton> </p-radioButton>
</div> </div>
</div> </div>
<hr class="mt-5">
<div class="d-flex justify-content-center mt-5">
<button class="ui-button-info mc-btn-primary" (click)="initiateWorkPreference(true)" *ngIf="workPreferenceQuestion.QuestionNo > 1" pButton label="Go Back"></button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -18,11 +18,12 @@ import { ToasterService } from '../../services/toaster.service'; ...@@ -18,11 +18,12 @@ import { ToasterService } from '../../services/toaster.service';
export class WorkPreferenceComponent extends BaseComponent implements OnInit, OnDestroy { export class WorkPreferenceComponent extends BaseComponent implements OnInit, OnDestroy {
workPreferenceQuestion = new WorkPreferenceQuestionModel(); workPreferenceQuestion = new WorkPreferenceQuestionModel();
assocs = ['CultureElement', 'CultureElement.Questions']; assocs = ['CultureElement', 'CultureElement.Questions', 'SelectedQuestion'];
wasUpdated = false; wasUpdated = false;
autoSaveInterval; autoSaveInterval;
autoSavedOn; autoSavedOn;
autoSaveLabel = 'a few seconds ago'; autoSaveLabel = 'a few seconds ago';
selectedAns;
constructor( constructor(
private assessmentService: AssessmentService, private assessmentService: AssessmentService,
...@@ -38,9 +39,9 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -38,9 +39,9 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
this.setAutoSaveInterval(); this.setAutoSaveInterval();
} }
initiateWorkPreference(): void { initiateWorkPreference(previousQuestion = false): void {
this.isLoading = true; this.isLoading = true;
this.assessmentService.getWorkPreferences(this.assocs) this.assessmentService.getWorkPreferences(this.assocs, previousQuestion)
.pipe(takeUntil(this.componentInView)) .pipe(takeUntil(this.componentInView))
.subscribe(response => { .subscribe(response => {
this.isLoading = false; this.isLoading = false;
...@@ -49,6 +50,9 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -49,6 +50,9 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
this.wasUpdated = true; this.wasUpdated = true;
if (response.length > 0) { if (response.length > 0) {
this.workPreferenceQuestion = response[0]; this.workPreferenceQuestion = response[0];
if (this.workPreferenceQuestion.SelectedQuestion) {
this.selectedAns = this.workPreferenceQuestion.SelectedQuestion.ObjectID;
}
} else { } else {
this.exit(); this.exit();
} }
...@@ -78,6 +82,7 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -78,6 +82,7 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
} }
submitAnswer(question: QuestionModel): void { submitAnswer(question: QuestionModel): void {
this.selectedAns = question.ObjectID;
const formData = { const formData = {
CultureElement: this.workPreferenceQuestion.CultureElement.ObjectID, CultureElement: this.workPreferenceQuestion.CultureElement.ObjectID,
SelectedQuestion: question.ObjectID, SelectedQuestion: question.ObjectID,
...@@ -86,6 +91,7 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -86,6 +91,7 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
this.isLoading = true; this.isLoading = true;
this.assessmentService.saveWorkPreferences(formData) this.assessmentService.saveWorkPreferences(formData)
.subscribe(response => { .subscribe(response => {
this.selectedAns = null;
this.isLoading = false; this.isLoading = false;
this.autoSavedOn = new Date(); this.autoSavedOn = new Date();
this.autoSave(); this.autoSave();
......
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
<div class="assessment-body-header"> <div class="assessment-body-header">
<div class="assessment-heading">Work Style</div> <div class="assessment-heading">Work Style</div>
<span class="assessment-estimation"> <i class="fa fa-clock-o"></i> <strong>Estimated time to complete</strong>: 20 mins</span>
<span class="assessment-estimation">
<img src="assets/images/clck.png" alt="" style="width: 16px; margin-top: -2px;">
<strong>Estimated time to complete</strong>: 20 mins</span>
</div> </div>
<div class="assessment-body-description"> <div class="assessment-body-description">
...@@ -39,21 +42,29 @@ ...@@ -39,21 +42,29 @@
<div class="answer-wrapper" *ngIf="!isMobileView"> <div class="answer-wrapper" *ngIf="!isMobileView">
<span class="extreme-label-left">{{workStyleQuestion.LeftScaleText}}</span> <span class="extreme-label-left">{{workStyleQuestion.LeftScaleText}}</span>
<div class="answer-options"> <div class="answer-options">
<span class="option-value" *ngFor="let scale of answerScales;" (click)="submitAnswer(scale)">{{scale}}</span> <span class="option-value" [class.selected]="selectedAns === scale" *ngFor="let scale of answerScales;" (click)="submitAnswer(scale)">{{scale}}</span>
</div> </div>
<span class="extreme-label-right">{{workStyleQuestion.RightScaleText}}</span> <span class="extreme-label-right">{{workStyleQuestion.RightScaleText}}</span>
</div> </div>
<div class="answer-wrapper" *ngIf="isMobileView"> <div class="answer-wrapper" *ngIf="isMobileView">
<div class="answer-options"> <div class="answer-options">
<span class="option-value" *ngFor="let scale of answerScales;" (click)="submitAnswer(scale)">{{scale}}</span> <span class="option-value" [class.selected]="selectedAns === scale" *ngFor="let scale of answerScales;" (click)="submitAnswer(scale)">{{scale}}</span>
</div> </div>
<div class="answer-option-labels"> <div class="answer-option-labels">
<span class="extreme-label-left">{{workStyleQuestion.LeftScaleText}}</span> <span class="extreme-label-left">{{workStyleQuestion.LeftScaleText}}</span>
<span class="extreme-label-right">{{workStyleQuestion.RightScaleText}}</span> <span class="extreme-label-right">{{workStyleQuestion.RightScaleText}}</span>
</div> </div>
</div> </div>
<hr class="mt-5">
<div class="d-flex justify-content-center mt-5">
<button class="ui-button-info mc-btn-primary" (click)="initiateWorkStyle(true)" *ngIf="workStyleQuestion.QuestionNo > 1" pButton label="Go Back"></button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -16,12 +16,13 @@ import { ToasterService } from '../../services/toaster.service'; ...@@ -16,12 +16,13 @@ import { ToasterService } from '../../services/toaster.service';
export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestroy { export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestroy {
workStyleQuestion = new WorkStyleQuestionModel(); workStyleQuestion = new WorkStyleQuestionModel();
assocs = ['Question']; assocs = ['Question', 'SelectedQuestion'];
answerScales = []; answerScales = [];
autoSaveInterval; autoSaveInterval;
autoSavedOn; autoSavedOn;
autoSaveLabel = 'a few seconds ago'; autoSaveLabel = 'a few seconds ago';
wasUpdated = false; wasUpdated = false;
selectedAns;
constructor( constructor(
private assessmentService: AssessmentService, private assessmentService: AssessmentService,
...@@ -37,9 +38,9 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr ...@@ -37,9 +38,9 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr
this.setAutoSaveInterval(); this.setAutoSaveInterval();
} }
initiateWorkStyle(): void { initiateWorkStyle(previousQuestion = false): void {
this.isLoading = true; this.isLoading = true;
this.assessmentService.getWorkStyle(this.assocs) this.assessmentService.getWorkStyle(this.assocs, previousQuestion)
.pipe(takeUntil(this.componentInView)) .pipe(takeUntil(this.componentInView))
.subscribe(response => { .subscribe(response => {
this.isLoading = false; this.isLoading = false;
...@@ -47,6 +48,9 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr ...@@ -47,6 +48,9 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr
this.autoSave(); this.autoSave();
if (response.length > 0) { if (response.length > 0) {
this.workStyleQuestion = response[0]; this.workStyleQuestion = response[0];
this.selectedAns = this.workStyleQuestion.Answer ? this.workStyleQuestion.Answer : null;
} else {
this.exit();
} }
this.setAnswerScales(); this.setAnswerScales();
}, err => { }, err => {
...@@ -66,6 +70,7 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr ...@@ -66,6 +70,7 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr
} }
submitAnswer(scale): void { submitAnswer(scale): void {
this.selectedAns = scale;
const formData = { const formData = {
Question: this.workStyleQuestion.Question.ObjectID, Question: this.workStyleQuestion.Question.ObjectID,
Answer: scale, Answer: scale,
...@@ -74,6 +79,7 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr ...@@ -74,6 +79,7 @@ export class WorkStyleComponent extends BaseComponent implements OnInit, OnDestr
this.isLoading = true; this.isLoading = true;
this.assessmentService.saveWorkStyle(formData) this.assessmentService.saveWorkStyle(formData)
.subscribe(response => { .subscribe(response => {
this.selectedAns = null;
this.isLoading = false; this.isLoading = false;
this.autoSavedOn = new Date(); this.autoSavedOn = new Date();
this.autoSave(); this.autoSave();
......
import { BaseModel } from './base.model'; import { BaseModel } from './base.model';
import { CLASSES } from '../config/constants'; import { CLASSES } from '../config/constants';
import { CultureElementModel } from './culture-element.model'; import { CultureElementModel } from './culture-element.model';
import { QuestionModel } from './question.model';
export class WorkPreferenceQuestionModel extends BaseModel { export class WorkPreferenceQuestionModel extends BaseModel {
ObjectClass = CLASSES.WORK_PREFERENCE_QUESTION; ObjectClass = CLASSES.WORK_PREFERENCE_QUESTION;
...@@ -8,4 +9,5 @@ export class WorkPreferenceQuestionModel extends BaseModel { ...@@ -8,4 +9,5 @@ export class WorkPreferenceQuestionModel extends BaseModel {
IntroductoryText: string; IntroductoryText: string;
QuestionNo: number; QuestionNo: number;
CultureElement: CultureElementModel; CultureElement: CultureElementModel;
SelectedQuestion: QuestionModel;
} }
...@@ -12,4 +12,5 @@ export class WorkStyleQuestionModel extends BaseModel { ...@@ -12,4 +12,5 @@ export class WorkStyleQuestionModel extends BaseModel {
RightScaleText: string; RightScaleText: string;
Scalar: null; Scalar: null;
Question: QuestionModel; Question: QuestionModel;
Answer: number;
} }
...@@ -11,8 +11,9 @@ export class AssessmentService { ...@@ -11,8 +11,9 @@ export class AssessmentService {
private searchService: SearchService private searchService: SearchService
) { } ) { }
getWorkStyle(assocs = []): Observable<any> { getWorkStyle(assocs = [], previousQuestion): Observable<any> {
return this.searchService.getObjects('WorkStyle', 'All', '', assocs, null, null, null, null) const queryParams = previousQuestion ? {IsBack: true} : '';
return this.searchService.getObjects('WorkStyle', 'All', queryParams, assocs, null, null, null, null)
.map( .map(
data => { data => {
return this.utilsService.convertResponseToObjects(data, assocs); return this.utilsService.convertResponseToObjects(data, assocs);
...@@ -20,8 +21,9 @@ export class AssessmentService { ...@@ -20,8 +21,9 @@ export class AssessmentService {
) )
} }
getWorkPreferences(assocs = []): Observable<any> { getWorkPreferences(assocs = [], previousQuestion = false): Observable<any> {
return this.searchService.getObjects('WorkPreferences', 'All', '', assocs, null, null, null, null) const queryParams = previousQuestion ? {IsBack: true} : '';
return this.searchService.getObjects('WorkPreferences', 'All', queryParams, assocs, null, null, null, null)
.map( .map(
data => { data => {
return this.utilsService.convertResponseToObjects(data, assocs); return this.utilsService.convertResponseToObjects(data, assocs);
......
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