fccn / nau-richie-site-factory

Site factory to build NAU web sites based on https://github.com/openfun/richie
https://www.nau.edu.pt/
GNU Affero General Public License v3.0
0 stars 1 forks source link

Error showing courses from edx.org on NAU Richie #228

Closed igobranco closed 6 months ago

igobranco commented 6 months ago

The courses to be shown on NAU Richie that as course runs on edx.org aren't being shown correctly.

Example: https://www.nau.edu.pt/pt/curso/iniciacao-a-lingua-portuguesa/

There are 2 course runs, but any are showing on side page of the course. Using the API https://www.nau.edu.pt/api/v1.0/courses/?limit=21&offset=0&organizations=942 we can view that there are 2 course runs.

"course_runs": [
    {
        "enrollment_start": "2024-05-01T23:00:00+00:00",
        "languages": [
            "pt"
        ],
        "enrollment_end": "2024-07-30T23:00:00+00:00",
        "start": "2024-05-05T23:00:00+00:00",
        "end": "2024-07-30T23:00:00+00:00"
    },
    {
        "enrollment_start": "2023-04-05T00:00:00+00:00",
        "languages": [
            "pt"
        ],
        "enrollment_end": "2023-08-01T00:00:00+00:00",
        "start": "2023-05-02T00:00:00+00:00",
        "end": "2023-08-08T23:30:00+00:00"
    }
],

I've got a feeling that the Synchronization mode wasn't put in Manual, and Richie backend isn't validating it. Then the frontend crashes because of the synchronization mode, impossibility the user to fix the its data.

Documented from a meeting with @carolinamado

sandroscosta commented 6 months ago

After some investigation, I can conclude that the courses were created as manual runs. From what I've checked, there are 4 course_runs registered, all with the same dates, times and resource_links.

# There are 4 objects in this query
<TranslatableQuerySet [
    <CourseRun: Course run 645 starting 24/05/05 23:00 - >, 
    <CourseRun: Course run 714 starting 24/05/05 23:00 - >, 
    <CourseRun: Course run 717 starting 24/05/05 23:00 - >, 
    <CourseRun: Course run 533 starting 23/05/02 00:00 - >
    ]>

All of them have manual has their sync_mode.

I have no idea why it happened like this but the option currently on top of the table is to remove these 3 Course Run entries.

sandroscosta commented 6 months ago

On of the course run was set to automatically sync, as referenced by @igobranco. All of the course runs created were erased via python shell.

The course run is now displaying the information properly.

igobranco commented 6 months ago

@sandroscosta please write the command that was run?

sandroscosta commented 6 months ago

Commands to check this issue

Run these commands inside the Richie container by running python manage.py shell.

Import course model and fetch course instance

from richie.apps.courses.models import Course

# get course instance
course = Course.objects.filter(code='ILP')

Check course run Every course has on or two page instances, if it has one or two languages defined. By default, PT and EN are created. Course runs do not duplicate between languages.

# this returns a <TranslatableQuerySet> of course_runs
course[0].course_runs

# you can also use course_runs_dict
course[0].course_runs_dict

**Remove course runs that might have sync issues. You can always use sync_mode to check the course_run sync mode.

course[0].course_run[0].sync_mode

# to remove the course run
course[0].course_run[0].delete()

Once the offending course_run is taking care of, the page will again display all course_runs