mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can block the creation of new responses on a survey
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:comunic/models/survey_choice.dart';
|
||||
import 'package:comunic/utils/account_utils.dart' as account;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Survey information
|
||||
@ -13,6 +14,7 @@ class Survey {
|
||||
final String question;
|
||||
int userChoice;
|
||||
final Set<SurveyChoice> choices;
|
||||
bool allowNewChoicesCreation;
|
||||
|
||||
Survey({
|
||||
@required this.id,
|
||||
@ -22,6 +24,7 @@ class Survey {
|
||||
@required this.question,
|
||||
@required this.userChoice,
|
||||
@required this.choices,
|
||||
@required this.allowNewChoicesCreation,
|
||||
}) : assert(id != null),
|
||||
assert(userID != null),
|
||||
assert(postID != null),
|
||||
@ -29,13 +32,17 @@ class Survey {
|
||||
assert(question != null),
|
||||
assert(userChoice != null),
|
||||
assert(choices != null),
|
||||
assert(choices.length > 0);
|
||||
assert(choices.length > 0),
|
||||
assert(allowNewChoicesCreation != null);
|
||||
|
||||
bool get hasResponded => this.userChoice != null && this.userChoice > 0;
|
||||
|
||||
bool get hasResponses =>
|
||||
this.choices.where((f) => f.responses > 0).length > 0;
|
||||
|
||||
bool get canBlockNewChoicesCreation =>
|
||||
allowNewChoicesCreation && account.userID() == this.userID;
|
||||
|
||||
SurveyChoice get userResponse {
|
||||
if (!hasResponded) return null;
|
||||
|
||||
|
Reference in New Issue
Block a user