### Setting Up KlickerUZH Development Environment
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
This snippet provides essential commands to initialize the KlickerUZH development environment. It covers installing project dependencies, starting the full development stack with Doppler environment variables, and preparing production-like components such as the database, Redis, and reverse proxy.
```bash
# Install dependencies
pnpm install
# Start development environment with Doppler environment variables
pnpm dev
# Start database, Redis, and reverse proxy only
pnpm run dev:prepare-prod
```
--------------------------------
### Project Setup Commands
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/analytics/README.md
Essential commands for setting up the KlickerUZH Analytics project, covering dependency installation using Poetry and PNPM, Prisma schema synchronization, and explicit Python environment configuration.
```Shell
poetry install
```
```Shell
pnpm install
```
```Shell
util/sync-schema.sh
```
```Shell
poetry env use /Users/.../bin/python
```
--------------------------------
### Common Development Commands for Docusaurus
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/docs/CLAUDE.md
These commands are used to manage the KlickerUZH documentation application, including installing dependencies, starting the development server, building for production, deploying, and serving the built site locally.
```bash
# Install dependencies
pnpm install
# Start development server
pnpm start
# Build for production
pnpm build
# Deploy the docs site
pnpm deploy
# Serve the built site locally
pnpm serve
```
--------------------------------
### Frontend Management Application Development Commands (pnpm)
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/frontend-manage/CLAUDE.md
This snippet provides a list of common 'pnpm' commands used for developing the KlickerUZH frontend-manage application. It covers essential operations such as installing dependencies, starting the development server (with an option for Doppler environment variables), building for production, performing type checks, linting, and starting the production server. These commands are fundamental for setting up and managing the development environment.
```bash
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Start with Doppler environment variables
pnpm dev:doppler
# Build for production
pnpm build
# Type checking
pnpm check
# Linting
pnpm lint
# Start production server
pnpm start
```
--------------------------------
### Development Workflow: Building and Running the Shared Components Package
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/shared-components/CLAUDE.md
These commands outline the standard development workflow for the `shared-components` package. They cover installing project dependencies, starting a local development server with live CSS reloading, building the package for production, and performing type-checking. These steps are essential for local development and deployment preparation.
```bash
# Install dependencies (from project root)
pnpm install
# Start development with live CSS reloading
pnpm run dev
# Build the package
pnpm run build
# Type-check the package
pnpm run check
```
--------------------------------
### Cypress Local Testing Environment Setup
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/cypress/CLAUDE.md
This snippet provides command-line instructions for setting up and running Cypress tests locally. It covers installing project dependencies, opening the Cypress test runner for interactive development, and executing tests headlessly for continuous integration or batch runs.
```bash
# Install dependencies
cd cypress
pnpm install
# Open Cypress test runner
pnpm cypress open
# Run tests headlessly
pnpm cypress run
```
--------------------------------
### TypeScript JSDoc Function Documentation Example
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
An example demonstrating the required JSDoc comment structure for TypeScript functions, including descriptions for parameters and return values, ensuring clear API documentation.
```typescript
/**
* Brief summary.
*
* @param param1 - Description.
* @returns Description.
*/
function example(param1: string): number {
// implementation
}
```
--------------------------------
### Cypress User Workflow Test Example
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/cypress/CLAUDE.md
This snippet demonstrates a typical Cypress test structure for a user workflow. It includes setup and cleanup using `before` and `after` hooks, data loading from fixtures with `beforeEach`, user login, performing actions, and asserting results using `data-cy` attributes and fixture data.
```typescript
describe('User workflow', () => {
before(() => cy.seed())
after(() => cy.cleanup())
beforeEach(function () {
cy.fixture('fixture-name.json').then((data) => {
this.data = data
})
})
it('completes a workflow successfully', function () {
// Login
cy.loginLecturer()
// Perform actions
cy.get('[data-cy="element"]').click()
// Assert results
cy.get('[data-cy="result"]').should('contain', this.data.expectedValue)
})
})
```
--------------------------------
### Install Node.js Dependencies
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/office-addin/README.md
Installs all necessary Node.js packages for the KlickerUZH PowerPoint add-in. This command should be executed after cloning the repository to set up the project environment.
```sh
npm install
```
--------------------------------
### Python Function Docstring Example (Google Style)
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
This snippet demonstrates the recommended Google style for writing docstrings in Python functions. It includes sections for a brief summary, arguments (Args), and return types (Returns), ensuring clear and consistent documentation for functions.
```Python
def example():
"""
Brief summary.
Args:
param1 (type): Description.
Returns:
type: Description.
"""
```
--------------------------------
### Common Task: Implementing a New Feature
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/frontend-manage/CLAUDE.md
Comprehensive guide for implementing a new feature, from planning component hierarchy and state management to GraphQL operations, UI development, custom hooks, validation, error handling, and cross-device testing.
```APIDOC
1. Plan the component hierarchy and state management approach
2. Create necessary GraphQL operations in the graphql package
3. Implement UI components in the appropriate directories
4. Create custom hooks for complex logic or data fetching
5. Add form validation if needed
6. Implement error handling and loading states
7. Test across different devices and scenarios
```
--------------------------------
### Common Task: Adding a New Component
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/frontend-manage/CLAUDE.md
Step-by-step guide for creating and integrating a new React component into the project, including prop typing, state management, internationalization, styling, and usage.
```APIDOC
1. Create a new component file in the appropriate feature directory
2. Define TypeScript interface for props
3. Implement the component with proper hooks and state management
4. Add internationalization using the messages from `@klicker-uzh/i18n`
5. Style using Tailwind classes
6. Import and use in parent components
```
--------------------------------
### Common Task: Creating a New Page
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/frontend-manage/CLAUDE.md
Instructions for adding a new page to the Next.js application, covering file structure, component imports, data fetching with Apollo Client or SWR, layout setup, and authentication/permissions.
```APIDOC
1. Add a new file in the `/src/pages/` directory following Next.js routing
2. Import necessary components and hooks
3. Implement data fetching using Apollo Client or SWR
4. Set up proper layouts and page structure
5. Handle authentication and permissions appropriately
```
--------------------------------
### Start Development Server and Sideload Add-ins
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/office-addin/README.md
Initiates the development server and automatically sideloads both KlickerUZH add-ins into PowerPoint. This command enables live development with auto-reloading of source code changes.
```sh
npm run dev
```
--------------------------------
### Building KlickerUZH for Production
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
This snippet contains commands for building the KlickerUZH project. It includes commands to build all packages and applications for a production release, as well as a specific command for building them for testing purposes, ensuring different build configurations are supported.
```bash
# Build all packages and applications
pnpm build
# Build packages and applications for testing
pnpm build:test
```
--------------------------------
### TypeScript Examples for KlickerUZH Element Data Processing
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/util/CLAUDE.md
These TypeScript examples illustrate the usage of core functions for handling and transforming element data within the KlickerUZH platform. They demonstrate how to convert raw database element objects into a frontend-ready format, and how to initialize data structures for new element instance results and statistics tracking, ensuring consistent data handling across the application.
```typescript
// Transform a database element into frontend-ready data
const elementData = processElementData(element)
// Get initial results structure for a new element instance
const results = getInitialInstanceResults(elementData)
// Get initial statistics for a new element instance
const statistics = getInitialInstanceStatistics(instanceType)
```
--------------------------------
### Embed Microlearning Preparation Video
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/docs/docs/tutorials/microlearning.mdx
This HTML snippet embeds a video tutorial from UZH MediaSpace, guiding users through the process of preparing a microlearning activity. It specifies the video source, dimensions, and various permissions for playback and interaction within the embedded frame.
```HTML
```
--------------------------------
### Client-Side Response Validation Example
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/shared-components/CLAUDE.md
Shows how to use a utility function for validating user responses based on the question type, typically used within component logic.
```tsx
import { validateResponse } from '../utils/validateResponse'
// In component
const isValid = validateResponse(response, questionType)
```
--------------------------------
### Managing KlickerUZH Database with Prisma
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
This snippet outlines commands for managing the KlickerUZH database using Prisma. It includes syncing the Prisma schema between packages, deploying schema changes to the database, browsing data with Prisma Studio, and creating new database migration files.
```bash
# Sync Prisma schema between packages/prisma and apps/analytics
./util/sync-schema.sh
# Deploy Prisma schema changes to the database
pnpm run prisma:deploy
# Run Prisma Studio to browse data
pnpm run prisma:studio
# Create a new Prisma migration
pnpm run prisma:migrate
```
--------------------------------
### Execute Database Schema Migration and Sync Commands
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
These commands are used to update the database schema after modifications to Prisma schema files. `pnpm run prisma:migrate` creates a new migration, and `./util/sync-schema.sh` synchronizes the schema across different packages.
```Shell
pnpm run prisma:migrate
```
```Shell
./util/sync-schema.sh
```
--------------------------------
### Python Environment Setup and Module Imports
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/apps/analytics/src/notebooks/aggregated_analytics.ipynb
This code block sets up the Python environment by modifying the system path to allow module imports from a parent directory and imports all necessary libraries for database interaction, date manipulation, and the core analytics computation function.
```python
import os
import json
from datetime import datetime
from prisma import Prisma
import pandas as pd
# set the python path correctly for module imports to work
import sys
sys.path.append("../../")
from src.modules.aggregated_analytics.compute_aggregated_analytics import (
compute_aggregated_analytics,
)
```
--------------------------------
### TypeScript Examples for Recomputing Derived Permissions
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/util/CLAUDE.md
These TypeScript code snippets demonstrate how to invoke the utility functions responsible for recomputing derived permissions within the KlickerUZH system. The examples show how to trigger a recomputation for a specific object (e.g., an element) or for a particular user's permissions on an element, typically after changes to direct permissions or object relationships. The `prisma` client is passed as a dependency for database operations.
```typescript
// Recompute permissions for a specific object
await recomputeDerivedPermissions({ elementId: 123 }, prisma)
// Recompute permissions for a specific user on an object
await recomputeElementPermissionsUser({ id: 123, userId: 'user-id' }, prisma)
```
--------------------------------
### Managing KlickerUZH Releases
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/CLAUDE.md
This snippet details commands for managing releases of the KlickerUZH project. It includes commands for creating standard releases, as well as specific commands for alpha, beta, and release candidate versions, facilitating a structured release process.
```bash
# Create a new release
pnpm release
# Create an alpha release
pnpm release:alpha
# Create a beta release
pnpm release:beta
# Create a release candidate
pnpm release:rc
```
--------------------------------
### Configuring NextIntlClientProvider for i18n in Next.js
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/i18n/CLAUDE.md
Shows the setup of `NextIntlClientProvider` in a Next.js application, integrating i18n messages, locale, and custom error handling functions for robust internationalization.
```typescript
{/* Application content */}
```
--------------------------------
### Implement Transactional Service Function
Source: https://github.com/uzh-bf/klicker-uzh/blob/v3/packages/graphql/CLAUDE.md
Example of an asynchronous service function demonstrating how to use a `PrismaTransactionContext` to ensure database operations are part of an atomic transaction. Operations performed via `ctx.prisma` will automatically be included in the transaction provided by the context.
```typescript
export async function createObject(
args: CreateObjectArgs,
ctx: PrismaTransactionContext
): Promise