blockpy-server icon indicating copy to clipboard operation
blockpy-server copied to clipboard

Implement question pools that vary together for coordinated multi-question scenarios

Open Copilot opened this issue 5 months ago • 0 comments

This PR implements the ability for question pools in quizzes to "vary together" based on a shared group identifier, enabling multi-question scenarios that span related pools.

Problem

Previously, question pools were completely independent. This made it impossible to create scenarios where:

  • One pool shows a code block to students
  • Another pool asks follow-up questions about that same code block
  • The questions needed to be coordinated (if student gets Code A, they should get Analysis questions for Code A)

Solution

Added support for an optional group field in question pools. Pools sharing the same group name will use identical seeds for question selection, ensuring their random choices are coordinated.

Key Features:

Grouped Pool Coordination:

{
  "pools": [
    {
      "name": "CodeDisplayPool",
      "questions": ["CodeA", "CodeB", "CodeC"], 
      "amount": 1,
      "group": "scenario1"
    },
    {
      "name": "AnalysisPool",
      "questions": ["AnalysisA", "AnalysisB", "AnalysisC"],
      "amount": 1, 
      "group": "scenario1"
    }
  ]
}

Students who receive "CodeA" will always receive "AnalysisA", ensuring questions make contextual sense together.

Backward Compatibility:

  • Pools without a group field continue to work exactly as before
  • No changes needed to existing quizzes
  • Automatic detection - no configuration required

Multiple Groups: A single quiz can have multiple independent groups of coordinated pools, plus individual pools that remain independent.

Implementation Details

  • hidePoolsGroups(): New method that groups pools by their group field and applies the same seed to pools in the same group
  • hidePools(): Updated to automatically detect when groups are present and use the appropriate logic
  • hashString(): Helper method for consistent group-based seed generation
  • Documentation: Updated quiz schema to explain the new group field

The implementation uses the existing random selection utilities and maintains all current pool randomness modes (SEED, ATTEMPT, NONE).

Fixes #69.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Aug 31 '25 13:08 Copilot