OpenSlides/client/src/app/shared/models/assignments/poll.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

import { PollOption } from './poll-option';
import { Deserializable } from '../deserializable.model';
/**
* Content of the 'polls' property of assignments
* @ignore
*/
export class Poll implements Deserializable {
2018-08-29 13:21:25 +02:00
public id: number;
public pollmethod: string;
public description: string;
public published: boolean;
public options: PollOption[];
public votesvalid: number;
public votesinvalid: number;
public votescast: number;
public has_votes: boolean;
public assignment_id: number;
/**
* Needs to be completely optional because assignment has (yet) the optional parameter 'polls'
2018-09-04 11:33:28 +02:00
* @param input
*/
2018-09-04 11:33:28 +02:00
public constructor(input?: any) {
this.options = [new PollOption()];
if (input) {
this.deserialize(input);
}
}
2018-09-04 11:33:28 +02:00
public deserialize(input: any): void {
Object.assign(this, input);
if (input.options instanceof Array) {
this.options = [];
input.options.forEach(pollOptionData => {
2018-09-04 11:33:28 +02:00
this.options.push(new PollOption(pollOptionData));
});
}
}
}