Skip to content

Import merged evaluation - #2747

Merged
janno42 merged 2 commits into
e-valuation:mainfrom
janno42:merge-import
Jul 28, 2026
Merged

Import merged evaluation#2747
janno42 merged 2 commits into
e-valuation:mainfrom
janno42:merge-import

Conversation

@janno42

@janno42 janno42 commented Jun 18, 2026

Copy link
Copy Markdown
Member

fix #2746; support importing evaluations that have been merged into another course

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some trouble understanding how all the parts come together here. In the issue it says that we have an assumption that two things exist together when they don't really have to, but here it is not obvious how this is split into two now

Comment thread evap/cms/json_importer.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test for this behavior

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected test_import_merged_evaluations to fail in this case and don't really understand why it didn't.

Comment thread evap/cms/json_importer.py
evaluation = Evaluation.objects.get(cms_evaluation_links__cms_id=data["gguid"])
# get the course from the evaluation in case it was merged into a different course than defined in the
# import data
course = evaluation.course

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance that we can choose the correct course once before calling import_evaluation? I think it is hard to track what course belongs to what now. In the calling code in import_events we have some if course is None: continue and I am not sure how this should interact with this new assignment here (my intuition is that if the original course is None but we find a course here then we should still run the import).

If this is not possible, then one (or both) of the two course variables needs a new name, I guess the course before this is something like course_from_event and this here is like a selected_course? Although selected_course really should just always be evaluation.course, so I guess we could also just use this everywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried looking up the course outside of _import_evaluation, but that would require a larger refactoring. So, I renamed the parameter to cms_course, the default value for course that is overwritten if the evaluation already exists.

@richardebeling richardebeling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code change looks good but I agree that a test would be nice

@janno42

janno42 commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

Turns out we already have test_import_merged_evaluations and it doesn't fail. I couldn't figure out why the error occurred on production.
However, I still think the changes from this PR are valid :)

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In person discussion:

  • the usage of a course other than evaluation.course outside of _import_evaluation is probably wrong
  • long term, we probably want to get rid of course_by_gguid altogether because this is really just an ad hoc mapping of evaluation's gguids to courses; cms doesn't distinguish between courses and evaluations
  • the notable change regarding the imported evaluation is the removal of the course=course when looking for linked evaluations

Comment thread evap/cms/tests/test_json_importer.py Outdated
Comment on lines +894 to +895
other_evaluation = Evaluation.objects.get(cms_evaluation_links__cms_id="0x44")
self.assertEqual(evaluation.course, other_evaluation.course)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we modified the cms link above, we now have evaluation.id == other_evaluation.id here, so this line always passes

@janno42
janno42 merged commit 0870beb into e-valuation:main Jul 28, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Import fails after merging Evaluation into other Course

3 participants