JMU-CIME / CPR-Music

1 stars 30 forks source link

give better message to user after uploading a roster #107

Open hcientist opened 8 months ago

hcientist commented 8 months ago

the api endpoint for uploading a CSV roster looks something like below. Right now there's very little feedback to the teacher. Since this response lets them know about 3 categories, it might be nice to display those 3 in a nice way:

  1. existing users that were added to their class
  2. new users created (and added to this class)
  3. invalid (users who were note added to this course, and why)
{
    "users": {
        "invalid": [
            {
                "name": "Bingo Heeler",
                "username": "bheeler",
                "password": "bingo",
                "grade": "6",
                "reason": "Wrong password"
            }
        ],
        "existing": [
            {
                "id": 6,
                "username": "bluey",
                "name": "Bluey Heeler",
                "url": "http://localhost:8000/api/users/bluey/",
                "grade": "2",
                "instrument": null,
                "external_id": "",
                "groups": [

                ]
            }
        ],
        "created": [

        ]
    },
    "enrollments": {
        "existing": [
            {
                "id": 9,
                "course": {
                    "id": 4,
                    "name": "Test NEA Creates",
                    "start_date": "2024-03-11",
                    "end_date": "2024-05-31",
                    "url": "http://localhost:8000/api/courses/test-nea-creates/",
                    "slug": "test-nea-creates",
                    "owner": {
                        "id": 3,
                        "username": "demoalden",
                        "name": "Alden Snell",
                        "url": "http://localhost:8000/api/users/demoalden/",
                        "grade": "",
                        "instrument": 20,
                        "external_id": "",
                        "groups": [
                            "Teacher"
                        ]
                    }
                },
                "instrument": {
                    "id": 18,
                    "name": "Oboe",
                    "transposition": "Concert Pitch TC"
                },
                "role": "Student",
                "user": {
                    "id": 6,
                    "username": "bluey",
                    "name": "Bluey Heeler",
                    "url": "http://localhost:8000/api/users/bluey/",
                    "grade": "2",
                    "instrument": null,
                    "external_id": "",
                    "groups": [

                    ]
                }
            }
        ],
        "created": [

        ]
    }
}
hcientist commented 7 months ago

Suggested approach

  1. run the code locally
  2. upload a starting roster (no errors you know of, novel students)
  3. confirm that many students are enrolled in the course

also test

  1. upload same roster to same course
  2. upload same roster to different course
  3. upload roster with some of those people and some new people?
hcientist commented 7 months ago

what if you upload a roster and there's already a user by that <name? username? password?> that has nothing to do with you?

williamjedrzejczak commented 7 months ago