apluslms / gitmanager

Git manager service for A+. Separated from the MOOC-Grader.
0 stars 6 forks source link

Course build does not save multilingual exercise configurations in the mooc-grader when both languages use the same configs #30

Open markkuriekkinen opened 1 year ago

markkuriekkinen commented 1 year ago

This issue has occurred on a few multilingual courses within the last year. I am not sure if I have pinpointed the exact cause, but at least the symptoms are the same on all courses.

MOOC-Grader crashes here when the exercise is loaded (it might only crash on one of the course languages, Finnish or English): https://github.com/apluslms/mooc-grader/blob/e6fdfe826acd50b055148a696587afad619cb53c/util/importer.py#L51 https://github.com/apluslms/mooc-grader/blob/e6fdfe826acd50b055148a696587afad619cb53c/access/views.py#L288 In import_named, path is None because in the function exercise, exercise['view_type'] returns None. Most values in the dictionary exercise are None, because mooc-grader has stored/received exercise configurations only for one language. The other language gets only None values that crash the code.

In the mooc-grader filesystem, the configuration JSON file for the exercise contains language keys in the top level. For example,

{
  "fi": ....,
  "en": ....
}

In this issue, only one language exists in the exercise configuration file, hence the other language is loaded with broken None values.

After I fix the course settings with a workaround, then the mooc-grader filesystem contains both languages in the exercise configuration JSON. The workaround is to change the title in the exercise config.yaml file in the course git repo. The title is changed from the monolingual version to the multilingual title|i18n format. For example, a title like title: Multidimensional arrays is changed to the following:

title|i18n:
  en: Multidimensional arrays
  fi: Moniulotteiset taulukot

In the C course (spring 2023), this issue occurred when the multilingual course has some assignments that are only provided in English. In the A+ RST configurations, both root index RST files for the Finnish and English versions point to the same module index RST file and thus the same chapter RST file. In the chapter RST file, the assignment is of course defined only with one config.yaml file (it is not possible to define different language versions inside a single chapter RST file). Both languages use the same exercise config.yaml file. However, since the content is defined only in one language even though the course is multilingual, it is natural that the exercise config.yaml defines the exercise title only in one language. The platform should work with it, but currently, it is mandatory to add the title in the multilingual format or the system just crashes.

In this case, gitmanager should send the exercise configurations in the multilingual format to the mooc-grader even though the configurations are the same in both languages. Or alternatively, mooc-grader should not crash when the requested language version is missing in the exercise configurations. But that might become misleading when you are trying to create different language versions and some language has been lost somewhere (there would be no clear error that some intended language is really missing).

lainets commented 1 year ago

As far as I understand this issue, I think the fix should be either done in a-plus-rst-tools or MOOC-grader. Git Manager making changes to the config is unneccessary complexity that would be hard to understand for anyone new and hard to debug. People would probably try to find a bug/related stuff in either a-plus-rst-tools (or the course files) where the config originates, or in MOOC-grader which is what uses the config, and not Git Manager that would transparently modify the config on the fly.

It sound like the fix should be done in a-plus-rst-tools as the course is supposed to be bilingual but is missing configuration for one of the languages, if I understood correctly. Otherwise, we could make MOOC-grader default to some other language if the configuration for an exercise is missing but I at least think the former would make things simpler and toward the expected behaviour

markkuriekkinen commented 1 year ago

Today, I faced a similar issue. This time, the mooc-grader crashed in the /configure view at the end of the course build in the gitmanager. The grader crashed during the exercise export in the function util/export.py i18n_urls() due to TypeError: 'NoneType' object is not iterable. The paths variable is None because one language version out of the two languages has only None values.

https://github.com/apluslms/gitmanager/blob/ad2378708f00649ec3702e1b8a88984637c1349d/util/export.py#L264

The gitmanager course build log has this error in the end after an otherwise successful build. The build fails and the new version can not be published.

Configuring graders...
{'url': 'https://grader.cs.aalto.fi/configure', 'error': "Couldn't access https://grader.cs.aalto.fi/configure"}
Failed to store built course

The course has been multilingual, but at the moment, only a monolingual version is active. The conf.py master_doc refers to a monolingual index_fi.rst file. Both language versions refer to same RST files that contain the submit directives and the exercise config.yaml files are the same for both languages.