Skip to content
Snippets Groups Projects
Commit 0ffcde95 authored by ywb16155's avatar ywb16155
Browse files

commit #21 - updating minute paper entity to reflect addition of name...

commit #21 - updating minute paper entity to reflect addition of name attribute in database, adding components for paper and paper template creation
parent 61476f15
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 54 deletions
package com.diss.omppapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@SpringBootApplication
@EnableJpaRepositories("com.diss.omppapp.repositories")
......
......@@ -21,6 +21,9 @@ public class MinutePaperEntity implements Serializable {
@Column
private String classCode;
@Column
private String name;
@Column
private String topic;
......@@ -62,6 +65,14 @@ public class MinutePaperEntity implements Serializable {
this.classCode = classCode;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getTopic() {
return topic;
}
......
package com.diss.omppapp.services;
import com.diss.omppapp.entities.AnswerEntity;
import com.diss.omppapp.entities.MinutePaperEntity;
import com.diss.omppapp.entities.QuestionEntity;
import com.diss.omppapp.pojo.MinutePaperWrapper;
......@@ -50,6 +49,7 @@ public class LecturerInfoService {
MinutePaperEntity entity = new MinutePaperEntity();
entity.setUsername(paper.getMinutePaperEntity().getUsername());
entity.setClassCode(paper.getMinutePaperEntity().getClassCode());
entity.setName(paper.getMinutePaperEntity().getName());
entity.setTopic(paper.getMinutePaperEntity().getTopic());
entity.setCreationDate(new Date());
entity.setTemplate(isTemplate);
......
<div>
<div class="container">
<div class="row">
<form [formGroup]="infoForm">
<label for="name">Enter a name for this one-minute paper:</label>
<input id="name" placeholder="Enter one-minute paper name...">
<label for="topic">Enter a topic for this one-minute paper:</label>
<input id="topic" placeholder="Enter one-minute paper topic...">
<label for="class-select">Choose a class:</label>
<select id="class-select">
</select>
</form>
</div>
<div *ngIf="!isTemplate" class="row">
<form [formGroup]="templateForm">
<label for="template-select">Load a template:</label>
<select id="template-select">
</select>
</form>
</div>
<div class="row">
<form [formGroup]="checkBoxForm">
<label for="anonymous-box">Would you like responses to be anonymised?:</label>
<input id="anonymous-box" type="checkbox" [value]="isAnonymous" (change)="flipIsAnonymous()">
</form>
</div>
<div class="row">
<form [formGroup]="questionForm">
<div *ngFor="let question of questions; let i = index;" [attr.data-index]="i">
<div class="row">
<span>Question {{i+1}}:</span>
</div>
<div class="row">
<label for="{{i}}">Question {{i}}</label>
<textarea id="{{i}}" [formControlName]="i" class="form-control" type="text" rows="3" placeholder="Start typing your question here.."></textarea>
</div>
</div>
</form>
<button class="btn-primary" (click)="addQuestion()">Add Question</button>
<button class="btn-danger" (click)="removeQuestion()">Remove Question</button>
</div>
<div *ngIf="!isTemplate">
<button class="btn-primary" type="submit" (click)="createPaper()">Create One-minute Paper</button>
</div>
<div *ngIf="isTemplate">
<button class="btn-primary" type="submit" (click)="createTemplate()">Create Template</button>
</div>
</div>
......@@ -3,6 +3,9 @@ import {LecturerInfoService} from 'src/app/services/lecturer-info.service';
import {LecturerDataService} from 'src/app/services/lecturer-data.service';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';
import {Router} from '@angular/router';
import {FormBuilder, FormGroup} from '@angular/forms';
import {QuestionDao} from 'src/app/dao/question.dao';
import {OmpClassDao} from 'src/app/dao/omp-class.dao';
@Component({
selector: 'app-lecturer-create-omp-view',
......@@ -11,16 +14,56 @@ import {Router} from '@angular/router';
})
export class LecturerCreateOmpViewComponent implements OnInit, OnDestroy {
public isTemplate: Boolean;
public questions: QuestionDao[];
public classes: OmpClassDao[];
public isAnonymous: Boolean;
public infoForm: FormGroup;
public questionForm: FormGroup;
public templateForm: FormGroup;
public checkBoxForm: FormGroup;
constructor(private lecturerInfoService: LecturerInfoService,
private lecturerDataService: LecturerDataService,
private lecturerViewService: LecturerViewService,
private formBuilder: FormBuilder,
private router: Router) {
}
ngOnInit(): void {
this.isTemplate = this.lecturerDataService.isTemplate;
this.questions = [];
this.classes = [];
this.isAnonymous = false;
this.initialiseForms();
}
ngOnDestroy(): void {
this.questions = [];
this.classes = [];
}
private initialiseForms(): void {
}
public createPaper(): void {
}
public createTemplate(): void {
}
public flipIsAnonymous(): void {
this.isAnonymous = !this.isAnonymous;
}
public addQuestion(): void {
}
public removeQuestion(): void {
}
}
import {Component, OnDestroy, OnInit} from '@angular/core';
import {LecturerInfoService} from 'src/app/services/lecturer-info.service';
import {LecturerDataService} from 'src/app/services/lecturer-data.service';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';
import {Router} from '@angular/router';
@Component({
selector: 'app-lecturer-create-template-view',
templateUrl: './lecturer-create-template-view.component.html',
styleUrls: ['./lecturer-create-template-view.component.css']
})
export class LecturerCreateTemplateViewComponent implements OnInit, OnDestroy {
constructor(private lecturerInfoService: LecturerInfoService,
private lecturerDataService: LecturerDataService,
private lecturerViewService: LecturerViewService,
private router: Router) {
}
ngOnInit(): void {
}
ngOnDestroy(): void {
}
}
......@@ -11,7 +11,6 @@ import {LecturerDataService} from 'src/app/services/lecturer-data.service';
import {LecturerSubmissionsViewComponent} from 'src/app/LecturerComponents/LecturerSubmissionsView/lecturer-submissions-view.component';
import {LecturerResponseViewComponent} from 'src/app/LecturerComponents/LecturerResponseView/lecturer-response-view.component';
import {LecturerCreateOmpViewComponent} from 'src/app/LecturerComponents/LecturerCreateOMPView/lecturer-create-omp-view.component';
import {LecturerCreateTemplateViewComponent} from 'src/app/LecturerComponents/LecturerCreateTemplateView/lecturer-create-template-view.component';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';
@NgModule({
......@@ -21,8 +20,7 @@ import {LecturerViewService} from 'src/app/services/lecturer-view.service';
LecturerPaperViewComponent,
LecturerSubmissionsViewComponent,
LecturerResponseViewComponent,
LecturerCreateOmpViewComponent,
LecturerCreateTemplateViewComponent
LecturerCreateOmpViewComponent
],
imports: [
CommonModule,
......
......@@ -4,13 +4,15 @@ import {LecturerRootComponent} from 'src/app/LecturerComponents/lecturer-root.co
import {LecturerPaperViewComponent} from './LecturerPaperView/lecturer-paper-view.component';
import {LecturerSubmissionsViewComponent} from './LecturerSubmissionsView/lecturer-submissions-view.component';
import {LecturerResponseViewComponent} from './LecturerResponseView/lecturer-response-view.component';
import {LecturerCreateOmpViewComponent} from './LecturerCreateOMPView/lecturer-create-omp-view.component';
const lecturerRoutes = [
{ path: 'ldashboard', component: LecturerRootComponent },
{ path: 'paperview', component: LecturerPaperViewComponent },
{ path: 'submissionsview', component: LecturerSubmissionsViewComponent },
{ path: 'responseview', component: LecturerResponseViewComponent }
{ path: 'responseview', component: LecturerResponseViewComponent },
{ path: 'creationview', component: LecturerCreateOmpViewComponent }
];
@NgModule({
......
......@@ -8,6 +8,7 @@
<div *ngFor="let paper of closedPaperList; let i = index" [attr.data-index]="i">
<div class="container">
<span class="row">Class Code: {{paper.classCode}} </span>
<span class="row">Minute-paper Name: {{paper.name}}</span>
<span class="row">Minute-paper Topic: {{paper.topic}}</span>
<span class="row">Opened: {{paper.creationDate}}</span>
<span class="row"><button (click)="goToCompletedPage(paper.paperId)">View</button></span>
......@@ -22,6 +23,7 @@
<div *ngFor="let paper of openClassPapers; let i = index" [attr.data-index]="i">
<div class="container">
<span class="row">Class Code: {{paper.classCode}} </span>
<span class="row">Minute-paper Name: {{paper.name}}</span>
<span class="row">Minute-paper Topic: {{paper.topic}}</span>
<span class="row">Opened: {{paper.creationDate}}</span>
<span class="row"><button (click)="goToSubmissionView(paper.paperId)">Respond</button></span>
......
<app-navbar></app-navbar>
<div class="container">
<h4>{{currentPaper.name}}</h4>
<h4>Your submission for class {{classCode}} about {{currentPaper.topic}}</h4>
<div *ngFor="let pair of questionAnswerPairs; let i = index" [attr.data-index]="i">
<div class="row">
......
......@@ -22,6 +22,7 @@
<div *ngFor="let paper of openPaperList; let i = index" [attr.data-index]="i">
<div class="container">
<span class="row">Class Code: {{paper.classCode}} </span>
<span class="row">Minute-paper Name: {{paper.name}}</span>
<span class="row">Minute-paper Topic: {{paper.topic}}</span>
<span class="row">Opened: {{paper.creationDate}}</span>
<span class="row"><button (click)="goToSubmissionView(paper.paperId)">Respond</button></span>
......
<app-navbar></app-navbar>
<div class="container">
<div>
<h4>{{currentPaper.name}}</h4>
<h4>Write a response about {{currentPaper.topic}} for {{currentPaper.classCode}}</h4>
</div>
<form [formGroup]="submissionForm">
......
......@@ -47,17 +47,17 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
this.studentResponse = [];
}
private submit() {
public submit(): void {
this.populateAnswers();
this.studentInfoService.submitResponse(this.studentResponse).subscribe();
}
private save() {
public save(): void {
this.populateAnswers();
this.studentInfoService.saveDraft(this.studentResponse).subscribe();
}
private populateAnswers() {
private populateAnswers(): void {
let index = 0;
this.questionList.forEach(q => {
if (this.submissionForm.get('questions').get(index.toString()) !== null) {
......@@ -68,11 +68,11 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
});
}
private getFormQuestions() {
private getFormQuestions(): FormArray {
return this.submissionForm.get('questions') as FormArray;
}
private organise() {
private organise(): void {
for (let i = 0; i < this.questionList.length; i++) {
if (this.questionList[i] && this.answerList[i]) {
this.getFormQuestions().push(this.formBuilder.control(this.answerList[i].answerText));
......@@ -82,14 +82,14 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
}
}
private getQuestions() {
private getQuestions(): void {
this.studentInfoService.getPaperQuestions(this.studentId, this.currentPaper.paperId).subscribe((data: QuestionDao[]) => {
data.forEach(e => this.questionList.push(e));
this.organise();
});
}
private getAnswers() {
private getAnswers(): void {
this.studentInfoService.getStudentAnswers(this.studentId, this.currentPaper.paperId).subscribe((data: AnswerDao[]) => {
data.forEach(e => this.answerList.push(e));
this.organise();
......
......@@ -4,16 +4,18 @@ export class MinutePaperDao {
paperId: String;
username: String;
classCode: String;
name: String;
topic: String;
template: Boolean;
anonymous: Boolean;
creationDate: String;
constructor(paperId: String, username: String, classCode: String,
topic: String, template: Boolean, anonymous: Boolean, creationDate: String) {
topic: String, name: String, template: Boolean, anonymous: Boolean, creationDate: String) {
this.paperId = paperId;
this.username = username;
this.classCode = classCode;
this.name = name;
this.topic = topic;
this.template = template;
this.anonymous = anonymous;
......
import {Injectable} from '@angular/core';
import {MinutePaperDao} from '../dao/minute-paper.dao';
import {AnswerSetDao} from '../dao/answer-set.dao';
import {QuestionDao} from '../dao/question.dao';
import {MinutePaperDao} from 'src/app/dao/minute-paper.dao';
import {AnswerSetDao} from 'src/app/dao/answer-set.dao';
import {QuestionDao} from 'src/app/dao/question.dao';
@Injectable()
export class LecturerDataService {
......@@ -10,4 +10,5 @@ export class LecturerDataService {
public currentPaper: MinutePaperDao;
public currentAnswerSet: AnswerSetDao;
public currentQuestions: QuestionDao[];
public isTemplate: Boolean;
}
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