Developers' Forum

Syntax error with all python code

Syntax error with all python code

by Simon king -
Number of replies: 2

Hi all, 

I'm having difficulty with coderunner. Everytime I run perfectly fine python code, there is a syntax error. 


For example: I run print(n) on the compiler cell. This what i get.  
error syntax on perfectly fine code
In reply to Simon king

Re: Syntax error with all python code

by Richard Lobb -

I haven't seen this before. Something is stripping all the newline characters from the program. Some questions:

  1. Are you running a Windows-based Moodle server, perhaps? If not, what OS is Moodle running on, and can you think of anything unusual about it? 
  2. You are (or were originally) using a python3 question type, right?
  3. If you open the question for editing, Customise it, and inspect the template, is it laid out in multiple lines, like the following?

    Python3 template

  4. If you delete all but the first line ({{ STUDENT_ANSWER}}) from the template and uncheck the Is combinator checkbox, does it then work OK for simple "Write a program" questions, which don't have test code but just read from standard input?

In reply to Richard Lobb

Re: Syntax error with all python code

by Simon king -

Thanks so much. 

1. I  am running moodle locally for a capstone project.  Ran it on mac and windows. 

2. yes i am using python 3

3. My template did not look like that. It was all on line number 1.


Code runner worked after I spaced out the template to 12 lines.  Thank you so much Richard. You made my day. 

 I am presenting a demo of my project in a 16 hours. 

-Simon