Improve state models for contents and content groups
Publish range
New properties have been added to set the range of published Contents of a ContentGroup instead of setting the state for each Content individually.
A Content is now published if its ContentGroup is published
and for
its index i
inside contentIds
applies:
firstPublishedIndex <= i <= lastPublishedIndex
or
firstPublishedIndex <= i && lastPublishedIndex == -1
Furthermore, the contentIds are now stored as a List (instead of a LinkedHashSet) because to entry index inside the Collection gained importance. The uniqueness is now checked by domain logic. This is an implementation detail and does not affect the API and persisted data. The use of a List makes checking if a Content's index is in the published range much easier.
Additional model and logic changes
Addtitional model changes:
- Added
statisticsPublished
andcorrectOptionsPublished
to ContentGroup model - Removed obsolete properties from Content model.
- Renamed Content's state properties for consistency.
Logic changes:
- Use
answeringEndTime
instead of a boolean value to check the permission for Answer creation. - Logic which still used those properties has been also removed or refactored.
Migration handling
A migration has been added which moves some state information previously stored for
individual Contents to ContentGroups. The new publishing state and range
for ContentGroups is determined by first checking if all or none of the
individual Contents are published (state.visible
). In this case, the
published is set accordingly and -1
is set for firstPublishedIndex
and lastPublishedIndex
. Otherwise, published is set to true and the
range is determined by taking the first published Content and the last
published Content in a row. Later Contents, which are not published
consecutively, will be excluded from the range.
Furthermore, this migration adds additional properties which have been introduced to the models and removes obsolete ones.
Closes: #93 (closed)