Skip to main content

Overview

The Spotify Mystery game combines music with memory. Listen to a classmate’s favorite song via an embedded Spotify player and identify who chose it from four options.
URL Pattern: /minijuegos/spotify/<group_id>/Minimum Students: 4 with Spotify links configured

How to Play

1

Listen to the Song

An embedded Spotify player appears with a classmate’s favorite song. Press play to listen.
2

Review Four Students

Four student options appear below the player, each showing name and profile picture.
3

Make Your Guess

Click on the student you think chose this song as their favorite.
4

Get Instant Feedback

The game reveals if you’re correct and shows whose song it really was.
5

Discover Musical Tastes

Each round helps you learn about classmates’ music preferences.

Spotify Integration

How Students Add Songs

Students add their favorite songs to their profile via the spotify_link field from accounts/models.py:51-57:
spotify_link = models.URLField(
    max_length=500, 
    blank=True, 
    null=True, 
    verbose_name="Enlace de Spotify",
    help_text="Pega aquí el enlace de la canción (Compartir > Copiar enlace de canción)"
)

Automatic Embed Conversion

From accounts/models.py:59-71, Relaciona automatically converts share links to embed format:
@property
def spotify_embed_url(self):
    """
    Lógica para transformar el enlace de compartir de Spotify 
    en un enlace de reproductor (embed).
    """
    if self.spotify_link:
        if "track/" in self.spotify_link:
            clean_url = self.spotify_link.split('?')[0]
            if "embed/" not in clean_url:
                return clean_url.replace("track/", "embed/track/")
            return clean_url
    return None
Conversion Example:
  • Student provides: https://open.spotify.com/track/3n3Ppam7vgaVa1iaRUc9Lp?si=abc123
  • System converts to: https://open.spotify.com/embed/track/3n3Ppam7vgaVa1iaRUc9Lp

Game Mechanics

Student Filtering

From minigames/views.py:399:
students = group.students.exclude(spotify_link__isnull=True).exclude(spotify_link='').exclude(id=request.user.id).distinct()
Filters:
  • ✅ Only students with Spotify links configured
  • ✅ Excludes empty Spotify link fields
  • ✅ Excludes yourself from appearing
  • ✅ Uses .distinct() to avoid duplicates
If fewer than 4 students have added Spotify links, you’ll see an error: “Se necesitan al menos 4 compañeros con su canción de Spotify configurada.”

Option Generation

From minigames/views.py:421-429:
last_id = request.session.get('spotify_last_id')
possible_targets = students.exclude(id=last_id) if students.count() > 1 else students
target = random.choice(possible_targets)

request.session['spotify_target_id'] = target.id
request.session['spotify_last_id'] = target.id

options = list(random.sample(list(students.exclude(id=target.id)), 3)) + [target]
random.shuffle(options)
Process:
  1. Avoid showing the last song again (anti-repetition)
  2. Select random target student
  3. Get their Spotify embed URL
  4. Pick 3 other students as distractors
  5. Shuffle the four options

Scoring

Session variables tracked:
  • spotify_correct: Correct song identifications
  • spotify_total: Total attempts
Displayed as: Correct / Total

Answer Validation

From minigames/views.py:409-413:
is_correct = str(request.POST.get('selected_id')) == str(request.session.get('spotify_target_id'))
request.session['spotify_total'] += 1
if is_correct: request.session['spotify_correct'] += 1

target = UserProfile.objects.get(id=request.session.get('spotify_target_id'))
msg = f"¡Correcto! Es la canción de {target.full_name or target.username}" if is_correct else "¡Ups! No es de ese compañero."

AJAX Implementation

From minigames/views.py:415-418:
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
    return get_ajax_response(request, is_correct, msg, 'spotify')
JSON response includes the reveal message:
{
  "success": true,
  "message": "¡Correcto! Es la canción de María González",
  "correct": 5,
  "total": 8
}

Anti-Repetition Logic

The game stores the last song shown in spotify_last_id and avoids repeating it immediately:
last_id = request.session.get('spotify_last_id')
possible_targets = students.exclude(id=last_id) if students.count() > 1 else students
This ensures variety in gameplay when you have multiple students with Spotify links.

Tips for Success

Pay attention to what genres and artists classmates like. This helps you associate music styles with people.
If classmates talk about their music preferences in class, those memories can help in the game.
Sometimes personality traits correlate with music taste - though not always!
If you know some students’ musical preferences, eliminate those you know are wrong.
Don’t rush - listen to the song long enough to get a feel for the style and mood.

Adding Your Spotify Song

To participate in this game, students need to add their favorite song:
1

Find Your Favorite Song on Spotify

Open Spotify (web or app) and navigate to your favorite song.
2

Get the Share Link

Click the three dots (…) next to the song → ShareCopy link to song
3

Add to Your Profile

Go to your Relaciona profile → Edit → Paste the link in the “Enlace de Spotify” field
4

System Converts Automatically

Relaciona automatically converts your share link to an embed format for the game.
See Completing Your Profile for detailed instructions on adding your Spotify link.

Role-Based Access

For Students

From minigames/views.py:390-394:
if request.user.role == 'student':
    group = request.user.student_groups.first()
    if not group: return render(request, 'minigames/no_students.html')
    group_id = group.id

For Teachers

Teachers select a class from the group selection screen.

Session State

Variables maintained:
  • spotify_correct: Correct matches count
  • spotify_total: Total attempts count
  • spotify_target_id: Current target student ID
  • spotify_last_id: Previous target (for anti-repetition)

Common Issues

Cause: Fewer than 4 students have added Spotify links to their profiles.Solution:
  1. Ask classmates to add their favorite songs to their profiles
  2. Teachers can send reminders about profile completion
  3. See profile completion guide
Cause: Network issues, ad blocker, or invalid Spotify link.Solution:
  1. Disable ad blockers for the site
  2. Check internet connection
  3. Verify the Spotify link is a valid track URL
  4. Try refreshing the page
Cause: Spotify requires users to be logged in to play full songs.Solution:
  1. Log into Spotify in another tab
  2. Even without playback, you can often see the song title and artist
  3. The preview should still work in most cases

Educational Value

This game provides unique benefits:

Cultural Exchange

Discover music from different cultures and genres through classmates

Connection Building

Music creates emotional connections and common interests

Memory Association

Associating songs with people creates strong memory anchors

Diversity Appreciation

Exposure to diverse musical tastes broadens perspectives

Technical Implementation

View Function: spotify_guess_game() in minigames/views.py:388-437 Key Features:
  • Automatic Spotify link to embed conversion
  • Student filtering by Spotify link presence
  • Anti-repetition logic for song variety
  • AJAX instant feedback with reveal message
  • Error handling for insufficient students
  • Embedded Spotify player integration

Privacy Considerations

Students have control over their Spotify integration:
  • Spotify links are optional (not required)
  • Students can remove their link anytime by editing their profile
  • Only the song link is stored, not Spotify account information
  • No tracking of listening history or Spotify activity

Next Steps

Add Your Song

Complete your profile with your favorite Spotify song

Student Interests Game

Another personality-based matching game

User Profiles Feature

Learn about all profile fields and features

Playing Games Guide

Strategies for all game types

Build docs developers (and LLMs) love