Merge branch 'master' of https://git.wmi.amu.edu.pl/s416178/Punktonerzy into groups
This commit is contained in:
commit
a340f2e847
@ -45,10 +45,12 @@ import { WaitingResourcesComponent } from './groups/waiting-resources/waiting-re
|
||||
import { BagdesComponent } from './user/bagdes/bagdes.component';
|
||||
import { RankingComponent } from './groups/ranking/ranking.component';
|
||||
import { HistoryOfActivityInGroupComponent } from './groups/history-of-activity-in-group/history-of-activity-in-group.component';
|
||||
import { LoginUsosComponent } from './login/login-usos/login-usos.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: 'login/usos', component: LoginUsosComponent },
|
||||
{ path: '', component: HomePageComponent },
|
||||
{ path: 'home', component: HomePageComponent },
|
||||
{ path: 'flashcards', component: FlashcardsComponent },
|
||||
|
@ -27,6 +27,7 @@ import { SharedModule } from './shared/shared.module';
|
||||
import { RoutingStateService } from './routing-state.service';
|
||||
|
||||
import { AutofocusDirective } from './autofocus.directive';
|
||||
import { LoginUsosComponent } from './login/login-usos/login-usos.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -37,7 +38,8 @@ import { AutofocusDirective } from './autofocus.directive';
|
||||
FooterComponent,
|
||||
HomePageComponent,
|
||||
WorkInProgressComponent,
|
||||
AutofocusDirective
|
||||
AutofocusDirective,
|
||||
LoginUsosComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -6,6 +6,7 @@ import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { USOSUrl, LoginKey } from './login';
|
||||
|
||||
@Injectable()
|
||||
export class AuthenticationService {
|
||||
@ -13,6 +14,7 @@ export class AuthenticationService {
|
||||
private headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
||||
private storageSub = new Subject<boolean>();
|
||||
public token: string;
|
||||
|
||||
constructor(private http: HttpClient, public snackBar: MatSnackBar) {
|
||||
}
|
||||
|
||||
@ -48,6 +50,27 @@ export class AuthenticationService {
|
||||
}).catch((error: any) => Observable.throw(error.json().error || 'Server error'));
|
||||
}
|
||||
|
||||
usosLogin(username, token) {
|
||||
if (token) {
|
||||
// store username and jwt token w local storage aby nie wylogowało przy zmianie stron
|
||||
localStorage.setItem('currentUser', JSON.stringify({ username: username, authorization: token }));
|
||||
this.getLoggedInName.emit('logged');
|
||||
this.storageSub.next(true);
|
||||
this.snackBar.open('Zalogowano pomyślnie!', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-success'] });
|
||||
// return true jeśli ok
|
||||
return true;
|
||||
} else {
|
||||
// return false jeśli nie
|
||||
this.getLoggedInName.emit('notLogged');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getUSOSTokens(): Observable<USOSUrl> {
|
||||
return this.http.get<USOSUrl>(encodeURI('usos/request_token?oauth_callback=http://localhost:4200/login/usos'));
|
||||
}
|
||||
|
||||
getToken(): String {
|
||||
const currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
||||
if (currentUser.authorization == null) {
|
||||
@ -57,6 +80,16 @@ export class AuthenticationService {
|
||||
}
|
||||
}
|
||||
|
||||
getAccessByUSOS(outh_t: string, outh_t_secret: string, outh_ver: string): Observable<LoginKey> {
|
||||
const headers = new HttpHeaders({
|
||||
'oauth_token' : outh_t,
|
||||
'oauth_token_secret': outh_t_secret,
|
||||
'oauth_verifier' : outh_ver
|
||||
});
|
||||
|
||||
return this.http.get<LoginKey>('usos/access_token' , {headers: headers});
|
||||
}
|
||||
|
||||
isLoggedIn(): boolean {
|
||||
const token: String = this.getToken();
|
||||
return token && token.length > 0;
|
||||
|
@ -16,7 +16,7 @@ export class FlashcardsAddCsvComponent implements OnInit {
|
||||
progress: { percentage: number } = { percentage: 0 };
|
||||
currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
||||
user: string;
|
||||
permission: Boolean = true;
|
||||
permission: Boolean = false;
|
||||
constructor(private uploadService: FlashcardsService, private router: Router, public snackBar: MatSnackBar) { }
|
||||
|
||||
ngOnInit() { this.isLoggedIn(); }
|
||||
|
@ -14,7 +14,7 @@ export class FlashcardsAddTableComponent implements OnInit {
|
||||
public fieldArray: Array<any> = [];
|
||||
newAttribute: any = {};
|
||||
currentUser;
|
||||
permission: Boolean = true;
|
||||
permission: Boolean = false;
|
||||
|
||||
constructor(private flashcardsService: FlashcardsService, public snackBar: MatSnackBar) { }
|
||||
|
||||
|
14
FrontEnd/src/app/login.ts
Normal file
14
FrontEnd/src/app/login.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export class USOSUrl {
|
||||
|
||||
url: string;
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export class LoginKey {
|
||||
|
||||
key: string;
|
||||
username: string;
|
||||
|
||||
constructor() {}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoginUsosComponent } from './login-usos.component';
|
||||
|
||||
describe('LoginUsosComponent', () => {
|
||||
let component: LoginUsosComponent;
|
||||
let fixture: ComponentFixture<LoginUsosComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoginUsosComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoginUsosComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
29
FrontEnd/src/app/login/login-usos/login-usos.component.ts
Normal file
29
FrontEnd/src/app/login/login-usos/login-usos.component.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AuthenticationService } from '../../authentication.service';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login-usos',
|
||||
templateUrl: './login-usos.component.html',
|
||||
styleUrls: ['./login-usos.component.css']
|
||||
})
|
||||
export class LoginUsosComponent implements OnInit {
|
||||
|
||||
constructor(private authenticationService: AuthenticationService,
|
||||
private router: Router) {}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
const urlArray: string[] = this.router.url.toString().replace('?', '&').split('&');
|
||||
localStorage.setItem('oauth_verifier', urlArray[2].replace('oauth_verifier=', ''));
|
||||
|
||||
this.authenticationService.getAccessByUSOS(localStorage.getItem('outh_token'),
|
||||
localStorage.getItem('outh_token_secret'), localStorage.getItem('oauth_verifier')).subscribe(
|
||||
message => {
|
||||
this.authenticationService.usosLogin(message.username, message.key);
|
||||
this.router.navigate(['/home']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<div class="content">
|
||||
<div id="container-login">
|
||||
<button class="btn btn-study-cave" (click)="loginWithUsos()">Zaloguj przez USOS</button>
|
||||
<br /><br /><br /><br />
|
||||
<div>
|
||||
<form (ngSubmit)="login()">
|
||||
Nazwa użytkownika:<br />
|
||||
|
@ -16,6 +16,8 @@ export class LoginComponent implements OnInit {
|
||||
model: any = {};
|
||||
loading = false;
|
||||
error = '';
|
||||
private outh_token = '';
|
||||
private outh_token_secret = '';
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
@ -27,8 +29,8 @@ export class LoginComponent implements OnInit {
|
||||
|
||||
login() {
|
||||
this.loading = true;
|
||||
this.authenticationService.login(this.model.username, this.model.password)
|
||||
.subscribe(result => {
|
||||
this.authenticationService.login(this.model.username, this.model.password).subscribe(
|
||||
result => {
|
||||
if (result === true) {
|
||||
// login successful
|
||||
this.isLogin = true;
|
||||
@ -47,6 +49,22 @@ export class LoginComponent implements OnInit {
|
||||
this.error = error;
|
||||
this.snackBar.open('Niepoprawne hasło lub login.', null,
|
||||
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
loginWithUsos() {
|
||||
let array = [] as string[];
|
||||
this.authenticationService.getUSOSTokens().subscribe(el => {
|
||||
array = el.url.split('?');
|
||||
array = array[1].split('&');
|
||||
this.outh_token = array[0];
|
||||
this.outh_token = this.outh_token.replace('oauth_token=', '');
|
||||
this.outh_token_secret = array[1];
|
||||
this.outh_token_secret = this.outh_token_secret.replace('oauth_token_secret=', '');
|
||||
localStorage.setItem('outh_token', array[0].replace('oauth_token=', ''));
|
||||
localStorage.setItem('outh_token_secret', array[1].replace('oauth_token_secret=', ''));
|
||||
window.location.href = el.url;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@
|
||||
<a (click)="navToProfile()"><i class="fas fa-user-circle"></i> Profil</a>
|
||||
<a (click)="logout()"><i class="fas fa-sign-out-alt"></i> Wyloguj</a>
|
||||
</div>
|
||||
<a *ngIf="isLogin">Witaj, {{currentUser?.username}}!</a>
|
||||
<!--<a *ngIf="isLogin">Witaj, {{currentUser?.username}}!</a>-->
|
||||
</div>
|
||||
</div>
|
@ -18,7 +18,7 @@ export class MaterialsAddComponent implements OnInit {
|
||||
currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
||||
user: string;
|
||||
title: string;
|
||||
permission: Boolean = true;
|
||||
permission: Boolean = false;
|
||||
constructor(private uploadService: MaterialsService, private router: Router, public snackBar: MatSnackBar) { }
|
||||
|
||||
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Wpisz tekst widoczny i tekst luki (luka może mieć więcej niż 1 dobrą odpowiedź - każdą odpowiedź oddziel <b>średnikiem</b>).</p>
|
||||
<div>
|
||||
|
@ -20,6 +20,7 @@ export class GapsQuestionComponent implements OnInit {
|
||||
answersCorrect: Array<Object> = [];
|
||||
answers: Array<Object> = [];
|
||||
question: String = 'Uzupełnij luki w tekście:';
|
||||
time = 0;
|
||||
points: Number = 1;
|
||||
id: Number = null;
|
||||
|
||||
@ -31,6 +32,7 @@ export class GapsQuestionComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
if (this.edit) {
|
||||
this.content['edit'] = true;
|
||||
this.time = this.content['content']['time'];
|
||||
this.question = this.content['content']['question'];
|
||||
const answ = this.content['content']['answers'];
|
||||
this.id = this.content['content']['id'];
|
||||
@ -42,6 +44,7 @@ export class GapsQuestionComponent implements OnInit {
|
||||
id: null,
|
||||
type: 'gaps',
|
||||
question: 'Uzupełnij luki w tekście.',
|
||||
time: 0,
|
||||
answers: [],
|
||||
points: 1
|
||||
};
|
||||
@ -185,6 +188,7 @@ export class GapsQuestionComponent implements OnInit {
|
||||
this.content['content']['question'] = this.question;
|
||||
this.content['content']['answers'] = this.answers;
|
||||
this.content['content']['points'] = this.points;
|
||||
this.content['content']['time'] = this.time;
|
||||
this.content['content']['id'] = this.id;
|
||||
if (this.edit) {
|
||||
this.editing.emit(this.content);
|
||||
@ -210,6 +214,7 @@ export class GapsQuestionComponent implements OnInit {
|
||||
this.content = {};
|
||||
this.edit = false;
|
||||
this.question = '';
|
||||
this.time = 0;
|
||||
this.answers = [];
|
||||
this.noGapText = '';
|
||||
this.gapText = '';
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Wpisz możliwe odpowiedzi i zaznacz prawidłową:</p>
|
||||
<div>
|
||||
|
@ -21,6 +21,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
|
||||
};
|
||||
question: String = '';
|
||||
points: Number = 1;
|
||||
time = 0;
|
||||
id: Number = null;
|
||||
|
||||
@Output() private add: EventEmitter<Object> = new EventEmitter();
|
||||
@ -32,6 +33,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
|
||||
if (this.edit) {
|
||||
this.content['edit'] = true;
|
||||
this.question = this.content['content']['question'];
|
||||
this.time = this.content['content']['time'];
|
||||
this.answers = [];
|
||||
const answ = this.content['content']['answers'];
|
||||
this.id = this.content['content']['id'];
|
||||
@ -49,6 +51,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
|
||||
id: this.id,
|
||||
type: 'multiple-choice',
|
||||
question: '',
|
||||
time: 0,
|
||||
answers: [],
|
||||
points: 1
|
||||
};
|
||||
@ -141,6 +144,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
|
||||
this.content['content']['question'] = this.question;
|
||||
this.answers = this.answersCorrect;
|
||||
this.content['content']['answers'] = this.answers;
|
||||
this.content['content']['time'] = this.time;
|
||||
this.content['content']['points'] = this.points;
|
||||
this.content['content']['id'] = this.id;
|
||||
if (this.edit) {
|
||||
@ -169,6 +173,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
|
||||
this.edit = false;
|
||||
this.isChecked = false;
|
||||
this.question = '';
|
||||
this.time = 0;
|
||||
this.answers = [];
|
||||
this.answersCorrect = [];
|
||||
this.newAttribute = {};
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Wpisz wszystkie dopasowania:</p>
|
||||
<div>
|
||||
|
@ -20,6 +20,7 @@ export class PairsQuestionComponent implements OnInit {
|
||||
};
|
||||
question: String = 'Połącz w pary:';
|
||||
points: Number = 1;
|
||||
time = 0;
|
||||
id: Number = null;
|
||||
|
||||
@Output() add: EventEmitter<Object> = new EventEmitter();
|
||||
@ -32,6 +33,7 @@ export class PairsQuestionComponent implements OnInit {
|
||||
this.answers = [];
|
||||
this.content['edit'] = true;
|
||||
this.question = this.content['content']['question'];
|
||||
this.time = this.content['content']['time'];
|
||||
this.id = this.content['content']['id'];
|
||||
const answ = this.content['content']['answers'];
|
||||
for (let i = 0; i < answ.length; i++) {
|
||||
@ -48,6 +50,7 @@ export class PairsQuestionComponent implements OnInit {
|
||||
id: null,
|
||||
type: 'pairs',
|
||||
question: 'Połącz w pary.',
|
||||
time: 0,
|
||||
answers: [],
|
||||
points: 1
|
||||
};
|
||||
@ -131,6 +134,7 @@ export class PairsQuestionComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
if (!exists) {
|
||||
this.content['content']['time'] = this.time;
|
||||
this.content['content']['question'] = this.question;
|
||||
this.answers = this.answersCorrect;
|
||||
this.content['content']['answers'] = this.answers;
|
||||
@ -161,6 +165,7 @@ export class PairsQuestionComponent implements OnInit {
|
||||
this.content = {};
|
||||
this.edit = false;
|
||||
this.question = '';
|
||||
this.time = 0;
|
||||
this.answers = [];
|
||||
this.answersCorrect = [];
|
||||
this.newAttribute = {};
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Wpisz <b>kolejno</b> wszystkie elementy rozsypanki:</p>
|
||||
<div>
|
||||
|
@ -19,6 +19,7 @@ export class PuzzleQuestionComponent implements OnInit {
|
||||
};
|
||||
question: String = 'Ułóż elementy w prawidłowej kolejności:';
|
||||
points: Number = 1;
|
||||
time = 0;
|
||||
id: Number = null;
|
||||
idAnsw: Number = null;
|
||||
|
||||
@ -31,6 +32,7 @@ export class PuzzleQuestionComponent implements OnInit {
|
||||
if (this.edit) {
|
||||
this.content['edit'] = true;
|
||||
this.question = this.content['content']['question'];
|
||||
this.time = this.content['content']['time'];
|
||||
this.id = this.content['content']['id'];
|
||||
this.answers = [];
|
||||
const answ = this.content['content']['answers'][0]['correct'];
|
||||
@ -47,6 +49,7 @@ export class PuzzleQuestionComponent implements OnInit {
|
||||
type: 'puzzle',
|
||||
question: 'Ułóż elementy w prawidłowej kolejności.',
|
||||
answers: [],
|
||||
time: 0,
|
||||
points: 1
|
||||
};
|
||||
this.content['edit'] = false;
|
||||
@ -120,6 +123,7 @@ export class PuzzleQuestionComponent implements OnInit {
|
||||
this.content['content']['question'] = this.question;
|
||||
this.content['content']['answers'] = this.answers;
|
||||
this.content['content']['points'] = this.points;
|
||||
this.content['content']['time'] = this.time;
|
||||
this.content['content']['id'] = this.id;
|
||||
if (this.edit) {
|
||||
this.editing.emit(this.content);
|
||||
@ -157,6 +161,7 @@ export class PuzzleQuestionComponent implements OnInit {
|
||||
this.content = {};
|
||||
this.edit = false;
|
||||
this.question = '';
|
||||
this.time = 0;
|
||||
this.answers = [];
|
||||
this.answersCorrect = [];
|
||||
this.newAttribute = {};
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Wpisz możliwe odpowiedzi i zaznacz prawidłową:</p>
|
||||
<div>
|
||||
|
@ -21,6 +21,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
|
||||
};
|
||||
question: String = '';
|
||||
points: Number = 1;
|
||||
time = 0;
|
||||
id: Number = null;
|
||||
|
||||
@Output() add: EventEmitter<Object> = new EventEmitter();
|
||||
@ -34,6 +35,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
|
||||
this.question = this.content['content']['question'];
|
||||
this.answers = [];
|
||||
const answ = this.content['content']['answers'];
|
||||
this.time = this.content['content']['time'];
|
||||
this.id = this.content['content']['id'];
|
||||
for (let i = 0; i < answ.length; i++) {
|
||||
this.answersCorrect.push({
|
||||
@ -50,7 +52,8 @@ export class SingleChoiceQuestionComponent implements OnInit {
|
||||
type: 'single-choice',
|
||||
question: '',
|
||||
answers: [],
|
||||
points: 1
|
||||
points: 1,
|
||||
time: 0
|
||||
};
|
||||
this.content['edit'] = false;
|
||||
}
|
||||
@ -157,6 +160,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
|
||||
this.answers = this.answersCorrect;
|
||||
this.content['content']['answers'] = this.answers;
|
||||
this.content['content']['points'] = this.points;
|
||||
this.content['content']['time'] = this.time;
|
||||
if (this.edit) {
|
||||
this.editing.emit(this.content);
|
||||
} else {
|
||||
@ -184,6 +188,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
|
||||
this.edit = false;
|
||||
this.isChecked = false;
|
||||
this.question = '';
|
||||
this.time = 0;
|
||||
this.answers = [];
|
||||
this.answersCorrect = [];
|
||||
this.newAttribute = {};
|
||||
|
@ -29,6 +29,10 @@ label {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.table {
|
||||
color: #FFF !important;
|
||||
}
|
||||
|
||||
.table td {
|
||||
border-top-width: 0;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ export class TestEditComponent implements OnInit, OnDestroy {
|
||||
id: d[i]['id'],
|
||||
type: d[i]['type'],
|
||||
question: d[i]['question'],
|
||||
time: d[i]['time'],
|
||||
answers: d[i]['answers'],
|
||||
points: d[i]['points']
|
||||
},
|
||||
@ -213,6 +214,7 @@ export class TestEditComponent implements OnInit, OnDestroy {
|
||||
nr: this.test[i]['nr'],
|
||||
type: this.test[i]['content']['type'],
|
||||
question: this.test[i]['content']['question'],
|
||||
time: this.test[i]['content']['time'],
|
||||
answers: this.test[i]['content']['answers'],
|
||||
points: this.test[i]['content']['points'],
|
||||
id: this.test[i]['content']['id']
|
||||
|
@ -29,6 +29,10 @@ label {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.table {
|
||||
color: #FFF !important;
|
||||
}
|
||||
|
||||
.table td {
|
||||
border-top-width: 0;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
<th>Lp.</th>
|
||||
<th>Typ</th>
|
||||
<th class="mobile">Punkty</th>
|
||||
<th class="mobile">Czas na odpowiedź</th>
|
||||
<th class="mobile">Pytanie</th>
|
||||
<th>Usuń</th>
|
||||
<th class="mobile">Przenieś</th>
|
||||
@ -72,6 +73,8 @@
|
||||
*ngIf='question.content.type == "pairs"'>Łączenie w pary</td>
|
||||
<td (click)='showComponents(question.content.type, question.nr)'
|
||||
class="mobile">{{ question.content.points }}</td>
|
||||
<td (click)='showComponents(question.content.type, question.nr)'
|
||||
class="mobile">{{ question.content.time }}</td>
|
||||
<td (click)='showComponents(question.content.type, question.nr)'
|
||||
class="mobile">{{ question.shortcut }}</td>
|
||||
<td><button class="btn btn-study-cave" (click)="delete(question.nr)"><i class="fas fa-trash-alt"></i> Usuń</button></td>
|
||||
|
@ -11,7 +11,7 @@ export class TestMakerComponent implements OnInit {
|
||||
|
||||
owner: Number = 0;
|
||||
title: String = '';
|
||||
permission: Boolean = true;
|
||||
permission: Boolean = false;
|
||||
|
||||
test: Array<Object> = [];
|
||||
shown: Boolean = false;
|
||||
@ -159,6 +159,7 @@ export class TestMakerComponent implements OnInit {
|
||||
nr: this.test[i]['nr'],
|
||||
type: this.test[i]['content']['type'],
|
||||
question: this.test[i]['content']['question'],
|
||||
time: this.test[i]['content']['time'],
|
||||
answers: this.test[i]['content']['answers'],
|
||||
points: this.test[i]['content']['points'],
|
||||
id: this.test[i]['content']['id']
|
||||
|
@ -18,6 +18,7 @@ export class TestResource {
|
||||
public id: number;
|
||||
public points: number;
|
||||
public question: string;
|
||||
public time: string;
|
||||
public nr: number;
|
||||
public answers: Answer[];
|
||||
|
||||
|
@ -12,6 +12,10 @@
|
||||
<p>Wprowadź treść pytania:</p>
|
||||
<input type="text" name="question" class="form-control" [(ngModel)]="content['content']['question']" required />
|
||||
</label>
|
||||
<label class="block">
|
||||
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
|
||||
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="content['content']['time']" required/>
|
||||
</label>
|
||||
<br />
|
||||
<p>Zaznacz prawidłową odpowiedź:</p>
|
||||
<label>
|
||||
|
@ -16,18 +16,22 @@ export class TrueFalseQuestionComponent implements OnInit {
|
||||
@Output() add: EventEmitter<Object> = new EventEmitter();
|
||||
@Output() editing: EventEmitter<Object> = new EventEmitter();
|
||||
|
||||
time = 0;
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.edit) {
|
||||
this.content['edit'] = true;
|
||||
this.id = this.content['content']['id'];
|
||||
this.time = this.content['content']['time'];
|
||||
} else {
|
||||
this.content = {};
|
||||
this.content['content'] = {
|
||||
id: null,
|
||||
type: 'true-false',
|
||||
question: '',
|
||||
time: 0,
|
||||
answers: [
|
||||
{id: null, content: 'Prawda', is_good: false},
|
||||
{id: null, content: 'Fałsz', is_good: false}
|
||||
@ -50,6 +54,7 @@ export class TrueFalseQuestionComponent implements OnInit {
|
||||
id: this.id,
|
||||
type: 'true-false',
|
||||
question: value['question'],
|
||||
time: value['time'],
|
||||
answers: [
|
||||
{id: this.content['content']['answers'][0]['id'], content: 'Prawda', is_good: true},
|
||||
{id: this.content['content']['answers'][1]['id'], content: 'Fałsz', is_good: false}
|
||||
@ -61,6 +66,7 @@ export class TrueFalseQuestionComponent implements OnInit {
|
||||
id: this.id,
|
||||
type: 'true-false',
|
||||
question: value['question'],
|
||||
time: value['time'],
|
||||
answers: [
|
||||
{id: this.content['content']['answers'][0]['id'], content: 'Prawda', is_good: false},
|
||||
{id: this.content['content']['answers'][1]['id'], content: 'Fałsz', is_good: true}
|
||||
@ -68,6 +74,7 @@ export class TrueFalseQuestionComponent implements OnInit {
|
||||
points: value['points']
|
||||
};
|
||||
}
|
||||
console.log(this.content);
|
||||
if (this.edit) {
|
||||
this.editing.emit(this.content);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user