Skip to content
Snippets Groups Projects
Commit 4bb8586a authored by ywb16155's avatar ywb16155
Browse files

commit #52 - styling improvements, refactoring forms, fixing bugs, changing config to server config

parent 68ceefa9
No related branches found
No related tags found
No related merge requests found
Showing
with 120 additions and 79 deletions
......@@ -11,30 +11,30 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class ConnectorConfig {
//
// @Bean
// public TomcatEmbeddedServletContainerFactory servletContainer() {
// TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
// @Override
// protected void postProcessContext(Context context) {
// SecurityConstraint securityConstraint = new SecurityConstraint();
// securityConstraint.setUserConstraint("CONFIDENTIAL");
// SecurityCollection collection = new SecurityCollection();
// collection.addPattern("/*");
// securityConstraint.addCollection(collection);
// context.addConstraint(securityConstraint);
// }
// };
// tomcat.addAdditionalTomcatConnectors(getHttpConnector());
// return tomcat;
// }
//
// private Connector getHttpConnector() {
// Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
// connector.setScheme("http");
// connector.setPort(8080);
// connector.setSecure(false);
// connector.setRedirectPort(8433);
// return connector;
// }
@Bean
public TomcatEmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(getHttpConnector());
return tomcat;
}
private Connector getHttpConnector() {
Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
connector.setScheme("http");
connector.setPort(8080);
connector.setSecure(false);
connector.setRedirectPort(8433);
return connector;
}
}
spring.jpa.hibernate.ddl-auto=none
#spring.datasource.url=jdbc:mysql://devweb2018.cis.strath.ac.uk:3306/ywb16155
spring.datasource.url=jdbc:mysql://localhost:3306/ompdb
spring.datasource.url=jdbc:mysql://devweb2018.cis.strath.ac.uk:3306/ywb16155
#spring.datasource.url=jdbc:mysql://localhost:3306/ompdb
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.username=ywb16155
#spring.datasource.password=Uir2Imaim7eo
spring.datasource.username=apiuser
spring.datasource.password=password
spring.datasource.username=ywb16155
spring.datasource.password=Uir2Imaim7eo
#spring.datasource.username=apiuser
#spring.datasource.password=password
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=10
spring.datasource.tomcat.max-wait=10000
......@@ -13,6 +13,6 @@ spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.open-in-view=false
spring.jpa.show-sql=false
#server.tomcat.additional-tld-skip-patterns='*.jar'
#server.context-path=/ywb16155-root/ompp-api
#server.port=8443
server.tomcat.additional-tld-skip-patterns='*.jar'
server.context-path=/ywb16155-root/ompp-api
server.port=8443
......@@ -69,6 +69,7 @@ export class ResponseChartComponent implements OnInit, OnDestroy {
}
private getClassesForYear(data: any) {
this.classCodes = new Set();
data.forEach(rgd => {
this.classCodes.add(rgd.classCode);
});
......@@ -126,7 +127,7 @@ export class ResponseChartComponent implements OnInit, OnDestroy {
private createPaperHeaders(index: number): string[] {
const xAxisHeaders = [];
this.papersByYear[index].forEach(elem => {
if (elem.classCode === this.currentClassCode) {
if (elem.classCode === this.currentClassCode && elem.year === this.currentYear) {
xAxisHeaders.push(elem.paperName.toString());
}
});
......
......@@ -151,6 +151,10 @@ export class LecturerCreateOmpViewComponent implements OnInit, OnDestroy {
private getCurrentTemplate() {
this.questions = [];
this.questions = this.currentTemplate.questions;
this.questions.forEach(question => {
question.questionId = '0';
question.paperId = '0';
});
this.isAnonymous = this.currentTemplate.paper.anonymous;
this.paperName = this.currentTemplate.paper.name;
this.paperTopic = this.currentTemplate.paper.topic;
......@@ -182,18 +186,20 @@ export class LecturerCreateOmpViewComponent implements OnInit, OnDestroy {
public createPaper(): void {
this.isSubmitted = true;
if (this.validateForm()) {
this.lecturerInfoService.createPaper(this.createWrapperObject()).subscribe();
this.router.navigate(['/ldashboard']);
this.ngOnDestroy();
this.lecturerInfoService.createPaper(this.createWrapperObject()).subscribe(() => {
this.router.navigate(['/ldashboard']);
this.ngOnDestroy();
});
}
}
public createTemplate(): void {
this.isSubmitted = true;
if (this.validateForm()) {
this.lecturerInfoService.createTemplate(this.createWrapperObject()).subscribe();
this.router.navigate(['/ldashboard']);
this.ngOnDestroy();
this.lecturerInfoService.createTemplate(this.createWrapperObject()).subscribe(() => {
this.router.navigate(['/ldashboard']);
this.ngOnDestroy();
});
}
}
......
......@@ -96,9 +96,10 @@ export class LecturerEditTemplateViewComponent implements OnInit, OnDestroy {
public saveTemplate(): void {
if (this.validateForm()) {
this.lecturerInfoService.createTemplate(this.createWrapperObject()).subscribe();
this.router.navigate(['/template-view']);
this.ngOnDestroy();
this.lecturerInfoService.createTemplate(this.createWrapperObject()).subscribe(() => {
this.router.navigate(['/template-view']);
this.ngOnDestroy();
});
}
}
......
......@@ -3,7 +3,7 @@
<div id="back-button">
<button class="btn btn-primary" (click)="back()">Back</button>
</div>
<div class="card border-primary" style="width: 50rem;">
<div class="card border-primary" style="width: 60%;">
<div class="card-body">
<h5 class="card-title">{{currentPaper.name}}</h5>
<p class="card-text">{{currentPaper.classCode}}</p>
......@@ -11,7 +11,7 @@
</div>
</div>
<div id="view-paper-questions" class="pre-scrollable" *ngFor="let question of questions; let i = index" [attr.data-index]="i">
<div class="card border-primary" style="width: 50rem;">
<div class="card border-primary" style="width: 60.55%;">
<div class="card-body">
<h5 class="card-title">Question {{i+1}}:</h5>
<p class="card-text">{{question.questionText}}</p>
......
......@@ -34,8 +34,8 @@ export class LoginComponent implements OnInit, OnDestroy, OnChanges {
}
ngOnDestroy(): void {
this.username = '';
this.password = '';
this.username = '0';
this.password = '0';
this.alive = false;
}
......@@ -60,7 +60,6 @@ export class LoginComponent implements OnInit, OnDestroy, OnChanges {
public login(): void {
this.validateUsername();
this.validatePassword();
this.isSubmitted = true;
if (!this.isUsernameInvalid && !this.isPasswordInvalid) {
this.loginService.login(this.username, this.password)
.pipe(
......@@ -80,6 +79,7 @@ export class LoginComponent implements OnInit, OnDestroy, OnChanges {
this.isUsernameInvalid = false;
this.isPasswordInvalid = false;
}
this.isSubmitted = true;
});
}
}
......
.pre-scrollable {
max-height: 80vh;
max-height: 87vh;
overflow-y: scroll;
}
......
......@@ -3,7 +3,7 @@
<div id="closed-papers" class="col-lg">
<h3>Your Closed One-minute Papers</h3>
<div *ngIf="closedPaperList.length <= 0">
<h4>You have no open one-minute papers!</h4>
<h4>You have no closed one-minute papers!</h4>
</div>
<div class="pre-scrollable">
<div *ngFor="let paper of closedPaperList; let i = index" [attr.data-index]="i" style="margin-top: 1%;">
......
.pre-scrollable {
max-height: 80vh;
max-height: 85vh;
}
#completed-view {
margin-top: 2%;
margin-left: 25%;
margin-right: 0;
}
#return-button {
margin-top: 2%;
margin-top: 1%;
margin-bottom: 1%;
}
<app-student-navbar></app-student-navbar>
<div id="completed-view">
<div id="return-button">
<button class="btn btn-primary" (click)="goBack()">Return</button>
</div>
<div class="pre-scrollable">
<div class="card border-primary" style="width: 50rem;">
<div class="card border-primary" style="width: 58%;">
<div class="card-body">
<h5 class="card-title" style="text-underline: black">{{currentPaper.name}}</h5>
<h5 class="card-title">Your submission for class {{classCode}} about {{currentPaper.topic}}</h5>
<h5 class="card-title">Your submission for class {{classCode}} about: {{currentPaper.topic}}</h5>
</div>
</div>
<div *ngFor="let pair of questionAnswerPairs; let i = index" [attr.data-index]="i" style="margin-top: 1%">
<div class="card border-primary" style="width: 50rem;">
<div class="card border-primary" style="width: 58%;">
<div class="card-body">
<p class="card-text">Question {{i+1}}:</p>
<p class="card-text">{{pair.question.questionText}}</p>
</div>
</div>
<div class="card" style="width: 50rem; margin-top: 1%; border-bottom-style: solid; border-color: green" >
<div class="card" style="width: 58%; margin-top: 1%; border-bottom-style: solid; border-color: green" >
<div class="card-body">
<p class="card-text">Your response:</p>
<p class="card-text">{{pair.answer.answerText}}</p>
......@@ -22,8 +25,5 @@
</div>
</div>
</div>
<div id="return-button">
<button class="btn btn-primary" (click)="goBack()">Return</button>
</div>
</div>
.pre-scrollable {
max-height: 80vh;
max-height: 87vh;
overflow-y: scroll;
}
......
.pre-scrollable {
max-height: 80vh;
max-height: 75vh;
width: 60%;
}
#submission-view {
......@@ -33,3 +34,7 @@
#save-button {
margin-left: 2%;
}
#cancel-button {
margin-left: 2%;
}
......@@ -2,14 +2,14 @@
<div id="submission-view">
<form id="studentSubmission" #studentSubmission="ngForm" class="row">
<div id="pair-row" class="pre-scrollable">
<div id="question-header" class="card border-primary" style="width: 50rem;">
<div id="question-header" class="card border-primary" style="width: 100%">
<div class="card-body">
<h5 class="card-title" style="text-underline: black">{{currentPaper.name}}</h5>
<h5 class="card-title">Write a response about {{currentPaper.topic}} for {{currentPaper.classCode}}</h5>
</div>
</div>
<div *ngFor="let pair of questionAnswerPairs; let i = index" [attr.data-index]="i" style="margin-top: 1%">
<div class="card border-primary" style="width: 50rem;">
<div class="card border-primary" style="width: 100%;">
<div class="card-body">
<p class="card-text">Question {{i+1}}:</p>
<p class="card-text">{{pair.question.questionText}}</p>
......@@ -21,15 +21,18 @@
</div>
</div>
</form>
<div *ngIf="invalidAnswers" class="is-invalid">
<p style="color: red">*Please complete all questions before submitting.</p>
</div>
<div id="submission-button-row" class="row">
<div id="submit-button">
<button class="btn btn-primary" type="submit" (click)="submit()"> Submit Response </button>
<div *ngIf="invalidAnswers" class="is-invalid">
<p style="color: red">*Please complete all questions before submitting.</p>
</div>
<button class="btn btn-primary" type="submit" (click)="submit()">Submit Response</button>
</div>
<div id="save-button">
<button class="btn btn-secondary" type="submit" (click)="save()"> Save As Draft </button>
<button class="btn btn-secondary" type="submit" (click)="save()">Save As Draft</button>
</div>
<div id="cancel-button">
<button class="btn btn-danger" type="submit" (click)="cancel()">Cancel</button>
</div>
</div>
</div>
......@@ -88,7 +88,7 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
});
}
private checkAnswers(): Boolean {
private checkForEmpty(): Boolean {
let result = false;
this.questionAnswerPairs.forEach(a => {
if (this.empty(a.answer.answerText)) {
......@@ -98,6 +98,16 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
return result;
}
private checkForNonEmpty(): Boolean {
let result = false;
this.questionAnswerPairs.forEach(a => {
if (!this.empty(a.answer.answerText)) {
result = true;
}
});
return result;
}
public empty(text: String): Boolean {
if (text.replace(/\s/g, '').length === 0 || text === '') {
return true;
......@@ -106,19 +116,34 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
}
public submit(): void {
this.invalidAnswers = this.checkAnswers();
this.invalidAnswers = this.checkForEmpty();
if (!this.invalidAnswers) {
this.populateAnswers();
this.studentInfoService.submitResponse(this.studentResponse).subscribe();
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
this.studentInfoService.submitResponse(this.studentResponse).subscribe(() => {
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
});
}
}
public save(): void {
this.populateAnswers();
this.studentInfoService.saveDraft(this.studentResponse).subscribe();
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
this.studentInfoService.saveDraft(this.studentResponse).subscribe(() => {
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
});
}
public cancel(): void {
if (this.checkForNonEmpty()) {
const choice = confirm('Are you sure you want to cancel submission? All unsaved work will be lost!');
if (choice) {
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
}
} else {
this.router.navigate(['/sdashboard']);
this.ngOnDestroy();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment