apluslms / mooc-jutut

Course feedback gathering and management tool. Used with A+ learning management system.
1 stars 12 forks source link

Crash when parsing localized strings #73

Closed PasiSa closed 1 year ago

PasiSa commented 1 year ago

Jutut crashes when trying to parse localized text on a multilingual course, in lib/helpers.py, str_in_selected_language. The backtrace ends as follows:

File "/srv/jutut/venv/lib/python3.8/site-packages/django/template/base.py", line 847, in resolve value = self._resolve_lookup(context) File "/srv/jutut/venv/lib/python3.8/site-packages/django/template/base.py", line 890, in _resolve_lookup current = getattr(current, bit) File "/srv/jutut/mooc-jutut/feedback/models.py", line 194, in context_name return str_in_selected_language(s) File "/srv/jutut/mooc-jutut/lib/helpers.py", line 28, in str_in_selected_language lang_alts = dict(map(

One question that comes to mind: Apparently this is pretty much the same functionality as pick_localized in aplus front. Why not just reuse that implementation also here?

markkuriekkinen commented 1 year ago

I assume that this error message is part of the same log that you were looking at:

Internal Server Error: /manage/COURSEID/feedbacks/
ValueError at /manage/COURSEID/feedbacks/
dictionary update sequence element #0 has length 3; 2 is required

@jsorva this error is repeated in the logs now that you are trying to do something.

markkuriekkinen commented 1 year ago

https://github.com/apluslms/mooc-jutut/blob/017cd675d421c2c196c4323e211ef16934219da6/lib/helpers.py#L29 s.split(':', 1) Limiting the number of splits so that only the first colon is used seems like a decent quick workaround.