openHPI / codeharbor

Exchange of Programming Exercises acrossdiverse Code Assessment Systems through CodeHarbor
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

GptService::GenerateTests creates invalid test files #1576

Closed MrSerth closed 1 week ago

MrSerth commented 1 month ago

The GptService::GenerateTests currently creates test files as follows:

https://github.com/openHPI/codeharbor/blob/992aeab7e085e286b48cf4d5710e467617af2fd3/app/services/gpt_service/generate_tests.rb#L16

However, the option visible: false is invalid, since visible is a string (no boolean) with fixed values (according to the ProFormA standard). When saved in the database, the boolean false is saved as f.

When downloading such a task as ProFormA ZIP file, the following error is raised:

ProformaXML::PostGenerateValidationError at /tasks/59/download
[#<Nokogiri::XML::SyntaxError: 281:0: ERROR: Element '{urn:proforma:v2.1}file', attribute 'visible': [facet 'enumeration'] The value 'f' is not an element of the set {'yes', 'no', 'delayed'}.>]

We should:

  1. fix the error in the unit test generation
  2. add a validation to the filed
  3. test the behavior
  4. (maybe) write a migration to resolve invalid values in our production database
MrSerth commented 1 week ago

Fixed by #1588.