Skip to main content

Overview

The Hangman game challenges you to guess a classmate’s name by selecting letters one at a time. You have 6 incorrect guesses before the game ends.
URL Pattern: /minijuegos/ahorcado/<group_id>/Minimum Students: 1 with profile picture

How to Play

1

See the Profile Picture

The game shows you a classmate’s profile picture to give you a visual clue.
2

See the Blank Spaces

The student’s name is displayed as underscores (_) for each letter. Spaces and non-alphabetic characters are shown.
3

Click Letters

Click letters from the alphabet grid to make your guesses. Used letters become disabled.
4

Watch Your Mistakes

Each incorrect letter adds to your mistake counter. You can make 6 mistakes before losing.
5

Win or Lose

Complete the name before 6 mistakes to win, or run out of attempts and see the answer.
6

Play Again

After winning or losing, refresh or continue to get a new classmate to guess.

Game Mechanics

Text Normalization

The game uses advanced text normalization from minigames/views.py:12-18:
def normalize_text(text):
    """Elimina tildes y convierte a mayúsculas."""
    if not text: return ""
    return ''.join(
        c for c in unicodedata.normalize('NFD', text)
        if unicodedata.category(c) != 'Mn'
    ).upper()
This means:
  • José becomes JOSE
  • María becomes MARIA
  • Case doesn’t matter
  • Accents are removed

Scoring System

The game tracks two session variables:
  • hangman_correct: Number of games won
  • hangman_total: Total games played
Your score displays as: Correct / Total (e.g., 3 / 5)

Letter Tracking

The game maintains a list of guessed letters in your session:
  • Already guessed letters are disabled and grayed out
  • Correct letters appear in the name
  • Incorrect letters increment the mistake counter

Game State

Session variables tracked:
  • hangman_target_id: Current student ID
  • hangman_target_name: Normalized name to guess
  • hangman_guessed_letters: Array of guessed letters
  • hangman_incorrect_count: Number of mistakes (max 6)
  • hangman_game_over: Boolean indicating game end
  • hangman_last_id: Previous student (to avoid repetition)

Alphabet

The game uses the Spanish alphabet including Ñ:
A B C D E F G H I J K L M N Ñ O P Q R S T U V W X Y Z

Anti-Repetition Logic

From minigames/views.py:188-194:
last_id = request.session.get('hangman_last_id')
possible_students = students.exclude(id=last_id) if students.count() > 1 else students
student = random.choice(possible_students)
The game remembers the last student shown and avoids selecting them again on the next round (if there are at least 2 students).

AJAX Implementation

The game uses AJAX for letter guesses to provide instant feedback without page reloads. When you click a letter:
return JsonResponse({
    'success': True,
    'displayed_name': displayed,
    'incorrect_count': request.session['hangman_incorrect_count'],
    'max_incorrect': 6,
    'game_over': request.session['hangman_game_over'],
    'won': won,
    'target_name': target_name,
    'correct': request.session['hangman_correct'],
    'total': request.session['hangman_total']
})

Tips for Success

Begin with frequently used letters in Spanish names like A, E, O, R, I, N.
The profile picture can help you remember or guess the student’s name.
Spanish names often follow patterns. Look for common endings like -A, -O, -EZ.
With only 6 mistakes allowed, think strategically about your letter choices.

Game Over Handling

From minigames/views.py:178-186, the game automatically resets when you start a new round:
if request.session.get('hangman_game_over', False) and request.method == 'GET':
    keys_to_reset = [
        'hangman_target_id', 'hangman_target_name', 
        'hangman_guessed_letters', 'hangman_incorrect_count', 
        'hangman_game_over'
    ]
    for key in keys_to_reset:
        request.session.pop(key, None)
Your overall score (correct/total) persists across rounds and stays throughout your session.

Student Requirements

For this game to work:
  • Students must have a profile picture uploaded
  • Students must have a name (uses full_name or falls back to username)
If no students in the class have profile pictures, the game will display a “no students” error page.

Technical Implementation

View Function: hangman_game() in minigames/views.py:163-255 Key Features:
  • Session-based state management
  • Text normalization for flexible matching
  • Anti-repetition logic
  • AJAX for instant letter feedback
  • Automatic game reset after completion
  • Student filtering by profile picture presence

Next Steps

Try Face Guess

Type the full name instead of guessing letters

Complete Your Profile

Add your profile picture so others can play with you

Build docs developers (and LLMs) love