Skip to content

Inability to Distinguish Canceled Lessons from Room Changes in Timetable #311

@SleepInfinity

Description

@SleepInfinity

When a lesson experiences a "Changement de salle" (room change), the timetable returns two lessons:

  1. Old Lesson (with the old room):
    • Marked with canceled=True.
    • status is "Cours annulé".
    • This lesson represents the original scheduling before the room change.
  2. New Lesson (with the new room):
    • Marked with canceled=False.
    • status is "Changement de salle".
    • There is no explicit flag indicating that this lesson is the updated one due to a room change.

This setup makes it challenging to differentiate between a normal canceled lesson and the old lesson from a room change event, as both have canceled=True and status as "Cours annulé".

Examples:

  • Old Lesson (from a room change):
    {
      'canceled': True,
      'classroom': 'H01',
      'status': 'Cours annulé',
      # ... other fields
    }
  • New Lesson (with the new room):
    {
      'canceled': False,
      'classroom': 'C05',
      'status': 'Changement de salle',
      # ... other fields
    }
  • Normal Canceled Lesson:
    {
      'canceled': True,
      'classroom': 'H02',
      'status': 'Cours annulé',
      # ... other fields
    }

As shown, there's no way to differentiate between a normal canceled lesson and the old lesson from a room change based solely on the canceled field and status.

Findings:

Upon inspecting the Pronote API response, there's an additional field "G" that helps differentiate between these cases:

  • Normal Canceled Lesson:
    {
      "G": 0,
      "Statut": "Cours annulé",
      "estAnnule": true,
      # ... other fields
    }
  • Old Lesson in a Room Change:
    {
      "G": 3,
      "Statut": "Cours annulé",
      "estAnnule": true,
      # ... other fields
    }
  • New Lesson with the New Room:
    {
      "G": 2,
      "Statut": "Changement de salle",
      "estAnnule": false,
      # ... other fields
    }

Snippet from Pronote API Response:

  • Old Lesson (from a room change):

    {
      "N": "31#uCU_JwkQIc2BwdzqLyVLP4f7LDR7xWRGQMLgViWv53Y",
      "G": 3,
      "P": 2757,
      "Statut": "Cours annulé",
      "estAnnule": true,
      "place": 110,
      "duree": 2,
      "DateDuCours": {
        "_T": 7,
        "V": "27/09/2024 15:00:00"
      },
      "CouleurFond": "#C0C0C0",
      "ListeContenus": {
        "_T": 24,
        "V": [
          {
            "L": "ACCOMPAGNEMT. PERSO.",
            "N": "83#b9i8QITZ-qYY9YJN8L4y-XAwoMEe-JmEGt4ChfdrKNU",
            "G": 16
          },
          {
            "G": 3,
            "L": "GRAVELOT G."
          },
          {
            "L": "H01",
            "N": "139#ixgNW1OOOHhOj2Uv5ypWeEqPaB-RPCaYnl14wbKrs0k",
            "G": 17
          }
        ]
      },
      "AvecTafPublie": false
    }
  • Normal Canceled Lesson:

    {
      "N": "31#zZ-nFKSDsfG0hnrp8oz4q5w05a9UhCGaB158ytvpWS8",
      "G": 0,
      "P": 1428,
      "Statut": "Cours annulé",
      "estAnnule": true,
      "place": 108,
      "duree": 2,
      "DateDuCours": {
        "_T": 7,
        "V": "27/09/2024 14:00:00"
      },
      "CouleurFond": "#5B215F",
      "ListeContenus": {
        "_T": 24,
        "V": [
          {
            "L": "ANGLAIS LV1",
            "N": "83#x8CbirRhIvXDj2QAxmHBdi_BmsGxiS-6Ntut2rGaCQA",
            "G": 16
          },
          {
            "G": 3,
            "L": "CHENU J."
          },
          {
            "L": "[T01-RISC_1]",
            "N": "64#nevVVmPlC62e9jE1kA8Ycvd6RyEjsoFRL-73NvuBE8g",
            "G": 2
          },
          {
            "L": "H02",
            "N": "139#Zg-8fspDK22Jl6LuvyxShWlNTBkAI72TN6zOuzh0ZLk",
            "G": 17
          }
        ]
      },
      "AvecTafPublie": false
    }

In these snippets, you can see:

  • The old lesson from a room change has "G": 3, "Statut": "Cours annulé", and "estAnnule": true.
  • The normal canceled lesson has "G": 0, "Statut": "Cours annulé", and "estAnnule": true.

Suggested Solution:

Modify the library to handle room changes appropriately by introducing a room_changed parameter and filtering out the old lessons from room changes.

  • Add a room_changed Property:

    • Introduce a new property room_changed in the Lesson class.
    • This property should be True for lessons that are the result of a room change (i.e., the new lesson with the new room and status == "Changement de salle").
    • For all other lessons, room_changed should be False.
  • Filter Out the Old Lesson:

    • Modify the library to exclude the old lesson (the one with canceled=True, status="Cours annulé", and "G": 3) from the timetable results.
    • Only include the new lesson (with the new room) in the timetable data.

Implementation Details:

  • Parsing Logic Adjustments:

    • When parsing lessons from the API response, check the "G" and status fields:
      • If G == 3 and estAnnule == True:
        • Recognize this lesson as the old lesson from a room change.
        • Do not include this lesson in the timetable.
      • If status == "Changement de salle":
        • Set room_changed = True for this lesson.
        • Include this lesson in the timetable.
      • For all other lessons, proceed as usual.
  • Resulting Behavior:

    • The timetable will only display:
      • Normal lessons.
      • Normal canceled lessons.
      • New lessons from room changes, marked with room_changed=True.
    • Old lessons from room changes will be excluded, reducing confusion and redundancy.

Benefits:

  • Clarity: By excluding the old lessons and adding a room_changed flag, the timetable becomes clearer and more accurate.
  • Simplicity: Developers won't need to implement additional logic to filter out old lessons or detect room changes.
  • Consistency: Aligns the library's output with user expectations by only showing relevant and actionable lessons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions