Using Java file attachments in a java_program question

Using Java file attachments in a java_program question

by Kenneth Johnson -
Number of replies: 1

Dear Code Runner Community

I'm quite new to CodeRunner. I've successfully created questions asking students to design a Java class according to some given following requirements. 

I'd like to now have students answer questions about designing classes referencing previous Java classes they have designed.

For example, I have a question which asks the student to design a Grade class (using a single integer value to store percentage). In the next question, I'd like the students to design the UniversityCourse class which has instance variables of type Grade. 

I've tried using the sample answer attachments (uploading Grade.java) when I fill in the answer box with the UniversityCourse class, but I get a Disallowed File Name (Grade.java).

Ideally, I'd like the student to complete their UniversityCourse class, uploading their Grade.java to pass the test cases. 

I've had a look at the "Demo of some use of attachments" examples, but it is not quite my use case. 

Should I approach this problem in a different way? 

Thank you for any help and suggestions

Best regards

Ken

In reply to Kenneth Johnson

Re: Using Java file attachments in a java_program question

by Richard Lobb -
I haven't ever used CodeRunner for teaching Java and my Java's about 15-years rusty, but in the absence of a response from any Java teachers ...

The error "Disallowed File Name" suggests that the regular expression you set for the allowed/required attachments wasn't right. It should be "Grade\.java" although "Grade.java" should also have worked.

I attach an xml export of a rudimentary question that requires an attachment file of Grade.java defining a class that simply wraps a grade string. The answer defines a UniversityCourse class that uses that attachment. It looks like this when run:
 
image.png