Allow Q&A rounds without upvotes and limit upvotes per question
- max_upvotes = 0 disables upvoting: the voting stage is skipped (collect -> discuss), questions are discussed in submission order - new setting max_upvotes_per_question caps a participant's upvotes on a single question (0 = no limit besides max_upvotes) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e44ded107
commit
bc86ec2db6
16 files changed
+235
-38
No files matched your search
@@ -104,9 +104,10 @@ class Slide extends Entity
|
||||
self::TYPE_QUIZ => ['time_limit' => 30],
|
||||
// url as entered, video_id parsed from it, start in seconds
|
||||
self::TYPE_YOUTUBE => ['url' => '', 'video_id' => '', 'start' => 0, 'autoplay' => false],
|
||||
// upvotes per participant in the voting stage (1..QA_MAX_UPVOTES);
|
||||
// max_upvotes: upvotes per participant in the voting stage (0..QA_MAX_UPVOTES, 0 = no voting stage);
|
||||
// max_upvotes_per_question: own upvotes per question (0 = no limit besides max_upvotes);
|
||||
// allow_self_upvote: upvotes on own questions (for prioritizing topics, off by default)
|
||||
self::TYPE_QA => ['max_upvotes' => 3, 'allow_self_upvote' => false],
|
||||
self::TYPE_QA => ['max_upvotes' => 3, 'max_upvotes_per_question' => 0, 'allow_self_upvote' => false],
|
||||
// The correct order is the order of the slide_options (position), revealed when voting closes.
|
||||
self::TYPE_ORDER => [],
|
||||
];
|
||||
@@ -316,6 +317,39 @@ class Slide extends Entity
|
||||
return in_array($this->stage, self::QA_STAGES, true) ? (string)$this->stage : self::QA_COLLECT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a Q&A slide has a voting stage (setting `max_upvotes` > 0).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasQaUpvotes(): bool
|
||||
{
|
||||
return (int)$this->setting('max_upvotes') > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stages of a Q&A slide in order: without upvotes the voting stage is skipped.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function qaStages(): array
|
||||
{
|
||||
return $this->hasQaUpvotes() ? self::QA_STAGES : [self::QA_COLLECT, self::QA_DISCUSS];
|
||||
}
|
||||
|
||||
/**
|
||||
* Upvotes one participant may give a single Q&A question (never more than `max_upvotes`).
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function qaUpvotesPerQuestion(): int
|
||||
{
|
||||
$max = (int)$this->setting('max_upvotes');
|
||||
$perQuestion = (int)$this->setting('max_upvotes_per_question');
|
||||
|
||||
return $perQuestion > 0 ? min($perQuestion, $max) : $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a participant may answer the slide several times (word cloud: one
|
||||
* row per word, Q&A: questions and upvotes).
|
||||
|
||||
Reference in new issue
Block a user