Skip to content

Commit

Permalink
Test Settings page changed, fixed mark for review problem in mutiple …
Browse files Browse the repository at this point in the history
…type question
  • Loading branch information
asif-khan17 authored and shreel2015 committed Oct 6, 2017
1 parent 8d7fa0f commit d33162d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,28 @@ export class TestComponent implements OnInit {
* @param index: index of question
*/
clearResponse(index: number) {
if (this.testQuestions[index].question.question.questionType === QuestionType.codeSnippetQuestion)
this.codeAnswer = '';
if (this.testQuestions[index].question.question.questionType === QuestionType.codeSnippetQuestion) {
if (this.selectLanguage.toLowerCase() === 'c')
this.codeAnswer = [
' #include <stdio.h>'
, 'int main()'
, '{'
, ' printf("Hello, World!");'
, ' return 0;'
, '}'
].join('\n');
if (this.selectLanguage.toLowerCase() === 'cpp')
this.codeAnswer = [
'#include <iostream>'
, 'using namespace std;'
, 'int main()'
, '{'
, ' cout << "Hello World!";'
, '}'
].join('\n');
if (this.selectLanguage.toLowerCase() === 'java')
this.codeAnswer = this.JAVA_CODE;
}
else
this.testQuestions[index].question.singleMultipleAnswerQuestion.singleMultipleAnswerQuestionOption.forEach(x => x.isAnswer = false);
//Leave the reviewed question
Expand All @@ -657,9 +677,9 @@ export class TestComponent implements OnInit {
} else {
let checked = this.testQuestions[questionIndex].question.singleMultipleAnswerQuestion.singleMultipleAnswerQuestionOption[optionIndex].isAnswer;
this.testQuestions[questionIndex].question.singleMultipleAnswerQuestion.singleMultipleAnswerQuestionOption[optionIndex].isAnswer = !checked;
if (this.testQuestions[questionIndex].question.singleMultipleAnswerQuestion.singleMultipleAnswerQuestionOption.some(x => x.isAnswer)) {
if (!this.testQuestions[questionIndex].question.singleMultipleAnswerQuestion.singleMultipleAnswerQuestionOption.some(x => x.isAnswer)) {
this.testQuestions[questionIndex].questionStatus = QuestionStatus.selected;
this.questionStatus = QuestionStatus.unanswered;
this.questionStatus = this.questionStatus !== QuestionStatus.review ? QuestionStatus.unanswered : this.questionStatus;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export class CreateTestFooterComponent implements OnInit {
@Input('validStartDate')
public validStartDate: boolean;
@Input()
isRelaunched: boolean;
@Input()
showIsPausedButton: boolean;
@Input('validEndDate')
public validEndDate: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
</div>
<div class="buttons-block pull-right" *ngIf="isTestSettings && loader">
<button type="button" class="btn" [disabled]="isValid||settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="updateTestSettings()">Save & Exit</button>
<button type="button" class="btn btn-primary" *ngIf="!testDetails.isLaunched && !showIsPausedButton && !isRelaunched" [disabled]="settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="launchTestDialogBox()">Save & Launch</button>
<button type="button" class="btn btn-primary" *ngIf="(showIsPausedButton && !testDetails.isPaused)" (click)="pausTest()">Pause</button>
<button type="button" class="btn btn-primary" *ngIf="(testDetails.isPaused && showIsPausedButton)" [disabled]="settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="resumTest()">Resume</button>
<button type="button" class="btn btn-primary" *ngIf="isRelaunched && !showIsPausedButton" [disabled]="settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="launchTestDialogBox()">Relaunch</button>
<button type="button" class="btn btn-primary" *ngIf="!testDetails.isLaunched" [disabled]="settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="launchTestDialogBox()">Save & Launch</button>
<button type="button" class="btn btn-primary" *ngIf="(testDetails.isLaunched && !testDetails.isPaused)" (click)="pausTest()">Pause</button>
<button type="button" class="btn btn-primary" *ngIf="(testDetails.isPaused && testDetails.isLaunched)" [disabled]="settingsForm.invalid || validStartDate || validEndDate || validTime || !isIpAddressAdded || isFocusLostNull" (click)="resumTest()">Resume</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class TestQuestionsComponent implements OnInit {
this.testId = params['id'];
});
this.getTestDetails();
this.isTestAttendeeExist();
}

openSnackBar(text: string) {
Expand Down Expand Up @@ -114,7 +115,6 @@ export class TestQuestionsComponent implements OnInit {
this.isAnyCategorySelectedForTest = this.testDetails.categoryAcList.some(function (category) {
return category.isSelect;
});
this.isTestAttendeeExist();
this.loader = false;
}, err => {
this.loader = false;
Expand Down Expand Up @@ -221,9 +221,6 @@ export class TestQuestionsComponent implements OnInit {
* Checks if any candidate has taken the test
*/
isTestAttendeeExist() {
if (new Date(<string>this.testDetails.startDate).getTime() > Date.now() && this.testDetails.isLaunched)
this.isEditTestEnabled = true;
else
this.testService.isTestAttendeeExist(this.testId).subscribe((res) => {
this.isEditTestEnabled = !res.response;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class TestSectionsComponent implements OnInit {
this.loader = true;
this.testId = this.route.snapshot.params['id'];
this.getTestById(this.testId);
this.isTestAttendeeExist();
}

/**
Expand All @@ -55,7 +56,6 @@ export class TestSectionsComponent implements OnInit {
this.testService.getTestById(id).subscribe((response) => {
this.testDetails = (response);
this.testCategories = this.testDetails.categoryAcList.filter(x => x.questionCount !== 0);
this.isTestAttendeeExist();
this.disablePreview = this.testDetails.categoryAcList === null || this.testDetails.categoryAcList.every(x => !x.isSelect) || this.testDetails.categoryAcList.every(x => x.numberOfSelectedQuestion === 0);
this.isCategoryExist = this.testDetails.categoryAcList.length === 0 ? false : true;
this.testNameReference = this.testDetails.testName;
Expand Down Expand Up @@ -146,11 +146,8 @@ export class TestSectionsComponent implements OnInit {
* Checks if any candidate has taken the test
*/
isTestAttendeeExist() {
if (new Date(<string>this.testDetails.startDate).getTime() > Date.now() && this.testDetails.isLaunched)
this.isEditTestEnabled = true;
else
this.testService.isTestAttendeeExist(this.testId).subscribe((res) => {
this.isEditTestEnabled = !res.response;
});
this.testService.isTestAttendeeExist(this.testId).subscribe((res) => {
this.isEditTestEnabled = !res.response;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export class TestSettingsComponent implements OnInit {
getTestById(id: number) {
this.testService.getTestById(id).subscribe((response) => {
this.testDetails = (response);
this.isRelaunched = new Date(<string>this.testDetails.startDate).getTime() > Date.now() && this.testDetails.isLaunched;
this.showIsPausedButton = new Date(<string>this.testDetails.startDate).getTime() <= Date.now() && this.testDetails.isLaunched;
this.testNameReference = this.testDetails.testName;
this.disablePreview = this.testDetails.categoryAcList === null || this.testDetails.categoryAcList.every(x => !x.isSelect) || this.testDetails.categoryAcList.every(x => x.numberOfSelectedQuestion === 0);
this.loader = false;
Expand Down Expand Up @@ -200,8 +198,6 @@ export class TestSettingsComponent implements OnInit {
});
if (isQuestionAdded) {
this.testDetails.isLaunched = true;
this.isRelaunched = new Date(<string>this.testDetails.startDate).getTime() > Date.now() && this.testDetails.isLaunched;
this.showIsPausedButton = new Date(<string>this.testDetails.startDate).getTime() <= Date.now() && this.testDetails.isLaunched;
testObject.startDate = new Date(<string>testObject.startDate).toISOString();
testObject.endDate = new Date(<string>testObject.endDate).toISOString();
this.testService.updateTestById(id, testObject).subscribe((response) => {
Expand Down Expand Up @@ -250,7 +246,6 @@ export class TestSettingsComponent implements OnInit {
* Resumes the test
*/
resumeTest() {

this.testDetails.isPaused = false;
let testObject = JSON.parse(JSON.stringify(this.testDetails));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="container">
<h5>Settings & Schedule</h5>
<div class="form-area">
<fieldset [disabled]="showIsPausedButton && !testDetails.isPaused">
<fieldset [disabled]="testDetails.isLaunched && !testDetails.isPaused">
<div class="form-group">
<label>Time Duration (mins)</label><em class="danger-text h4">*</em>
<input type="text" class="form-control small-width" [(ngModel)]="testDetails.duration" name="Duration" placeholder="00" #Duration="ngModel" required pattern="^(0*[1-9])\d{0,3}?$" (keyup)="isWarningTimeValid()" />
Expand All @@ -34,13 +34,13 @@ <h5>Settings & Schedule</h5>
<label>IP Restrictions</label>
<div class="ip-add-field" *ngFor="let ip of testDetails.testIpAddress; let i= index">
<input type="text" class="form-control small-width" id="From" name="ip_{{i}}" placeholder="IP Address {{i+1}}" (keyup)="IpAddressAdded(ip.ipAddress);showErrorMessage(ip)" (focus)="IpAddressAdded(ip.ipAddress)" #From=ngModel [(ngModel)]="ip.ipAddress" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" />
<em class="material-icons" *ngIf="!(showIsPausedButton && !testDetails.isPaused)" (click)="removeIpAddress(i,ip.id,ip.ipAddress)">close</em>
<em class="material-icons" *ngIf="!(testDetails.isLaunched && !testDetails.isPaused)" (click)="removeIpAddress(i,ip.id,ip.ipAddress)">close</em>
<div class="errors-container">
<span class="error-msg" *ngIf="From.errors && From.dirty" [hidden]="!From.errors.pattern">Enter IP address in correct format.</span>
<span class="error-msg" *ngIf="ip.isErrorMessageVisible">Add IP Address or remove this field.</span>
</div>
</div>
<button md-mini-fab type="button" [disabled]="showIsPausedButton && !testDetails.isPaused || !isIpAddressAdded" (click)="addIpFields()"><md-icon>add</md-icon></button>
<button md-mini-fab type="button" [disabled]="testDetails.isLaunched && !testDetails.isPaused || !isIpAddressAdded" (click)="addIpFields()"><md-icon>add</md-icon></button>
</div>
<div class="form-group">
<label>Browser Tolerance</label>
Expand Down Expand Up @@ -115,7 +115,7 @@ <h5>Settings & Schedule</h5>
</div>

</fieldset>
<create-test-footer [isFocusLostNull]="isFocusLostNull" [loader]="!loader" [showIsPausedButton]="showIsPausedButton" [isRelaunched]="isRelaunched" [testDetails]="testDetails" (saveTestSettings)="saveTestSettings(testDetails.id,testDetails)" (launchTestDialog)="launchTestDialog(testDetails.id,testDetails,$event)" (pauseTest)="pauseTest()" (resumeTest)="resumeTest()" [settingsForm]="settingsForm" [validStartDate]="validStartDate" [validEndDate]="validEndDate" [validTime]="validTime" [isIpAddressAdded]="isIpAddressAdded"></create-test-footer>
<create-test-footer [isFocusLostNull]="isFocusLostNull" [loader]="!loader" [testDetails]="testDetails" (saveTestSettings)="saveTestSettings(testDetails.id,testDetails)" (launchTestDialog)="launchTestDialog(testDetails.id,testDetails,$event)" (pauseTest)="pauseTest()" (resumeTest)="resumeTest()" [settingsForm]="settingsForm" [validStartDate]="validStartDate" [validEndDate]="validEndDate" [validTime]="validTime" [isIpAddressAdded]="isIpAddressAdded"></create-test-footer>
</div>
</div>
</form>
Expand Down

0 comments on commit d33162d

Please sign in to comment.