From 51fc812c6ced000dd7ab09a38189603a7ae9994a Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Mon, 21 Jul 2025 10:55:01 +0200 Subject: [PATCH 1/6] chore: Turtle test exercise and production Python execution environment The Python execution environment is identical to production and a Turtle example was added for easy local testing. --- db/seeds/turtle/default.pylintrc | 419 ++++++++++++++++++ db/seeds/turtle/main.py | 67 +++ db/seeds/turtle/test_style.py | 7 + spec/factories/execution_environment.rb | 8 +- spec/factories/exercise.rb | 14 + spec/factories/file_type.rb | 10 + .../convert_task_to_exercise_spec.rb | 2 +- 7 files changed, 522 insertions(+), 5 deletions(-) create mode 100644 db/seeds/turtle/default.pylintrc create mode 100644 db/seeds/turtle/main.py create mode 100644 db/seeds/turtle/test_style.py diff --git a/db/seeds/turtle/default.pylintrc b/db/seeds/turtle/default.pylintrc new file mode 100644 index 000000000..149d381e4 --- /dev/null +++ b/db/seeds/turtle/default.pylintrc @@ -0,0 +1,419 @@ +[MASTER] + +# Specify a configuration file. +#rcfile= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Pickle collected data for later comparisons. +persistent=no + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Use multiple processes to speed up Pylint. +jobs=1 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist= + +# Allow optimization of some AST trees. This will activate a peephole AST +# optimizer, which will apply various small optimizations. For instance, it can +# be used to obtain the result of joining multiple strings with the addition +# operator. Joining a lot of strings can lead to a maximum recursion error in +# Pylint and this flag can prevent that. It has one side effect, the resulting +# AST will be different than the one from reality. This option is deprecated +# and it will be removed in Pylint 2.0. +optimize-ast=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=all + +# Leo WWW +# disable=delslice-method,parameter-unpacking,zip-builtin-not-iterating,useless-suppression,coerce-builtin,old-ne-operator,dict-iter-method,old-division,long-builtin,getslice-method,unpacking-in-except,suppressed-message,old-raise-syntax,round-builtin,print-statement,indexing-exception,unicode-builtin,execfile-builtin,setslice-method,import-star-module-level,input-builtin,apply-builtin,intern-builtin,raw_input-builtin,coerce-method,dict-view-method,file-builtin,next-method-called,map-builtin-not-iterating,metaclass-assignment,old-octal-literal,basestring-builtin,buffer-builtin,hex-method,long-suffix,backtick,nonzero-method,reload-builtin,unichr-builtin,cmp-method,cmp-builtin,filter-builtin-not-iterating,reduce-builtin,raising-string,using-cmp-argument,oct-method,standarderror-builtin,no-absolute-import,range-builtin-not-iterating,xrange-builtin,missing-docstring,locally-disabled,too-many-instance-attributes,cyclic-import,too-few-public-methods,wrong-import-position,trailing-whitespace,unused-variables,line-too-long + +# Adafruit Learning: https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/.pylintrc +# disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace,consider-using-enumerate,unexpected-keyword-arg + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. + +# based on the 1000 most messages from the Python15 course +enable=bad-whitespace,undefined-variable,bad-indentation,redefined-outer-name,mixed-indentation,unused-variable,redefined-builtin,unnecessary-semicolon,unused-argument,used-before-assignment,pointless-statement,unreachable,inconsistent-return-statements,pointless-string-statement,redefined-argument-from-local,function-redefined,comparison-with-itself,return-outside-function,duplicate-except,bad-indentation,syntax-error,wrong-import-position,self-assigning-variable,duplicate-key,superfluous-parens,multiple-statements,undefined-loop-variable,import-error +#I18n schwer: invalid-name,bad-indentation,syntax-error,wrong-import-position,self-assigning-variable,duplicate-key +#?? vielleicht: missing-final-newline,trailing-newlines,superfluous-parens,multiple-statements,undefined-loop-variable +#!! eher nicht: bad-continuation + + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html. You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +# Doesn't have any effect if run via python script +output-format=text + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". This option is deprecated +# and it will be removed in Pylint 2.0. +files-output=no + +# Tells whether to display a full report or only the messages +reports=no + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + + +[BASIC] + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,v,x,y,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty + +# Regular expression matching correct attribute names +attr-rgx=[a-z][a-z0-9_]{2,30}$ + +# Naming hint for attribute names +attr-name-hint=[a-z][A-Za-z0-9]{2,30}$ + +# Regular expression matching correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Naming hint for class names +class-name-hint=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression matching correct method names +method-rgx=(?:(?:[a-z_][a-z0-9_]{2,30})|(?:test_[a-z0-9_]{2,}))$ + +# Naming hint for method names +method-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct class attribute names +class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ + +# Naming hint for class attribute names +class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ + +# Regular expression matching correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for function names +function-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct inline iteration names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Naming hint for inline iteration names +inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ + +# Regular expression matching correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Naming hint for module names +module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression matching correct argument names +argument-rgx=[a-z][a-z0-9_]{2,30}$ + +# Naming hint for argument names +argument-name-hint=[a-z][A-Za-z0-9]{2,30}$ + +# Regular expression matching correct constant names +const-rgx=(?:database_holder|flask|(([A-Z_][A-Z0-9_]*)|(__.*__)))$ + +# Naming hint for constant names +const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression matching correct variable names +variable-rgx=[a-z][A-Za-z0-9_]{2,30}$ + +# Naming hint for variable names +variable-name-hint=[a-z][A-Za-z0-9]{2,30}$ + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + + +[ELIF] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=120 + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma,dict-separator + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[SPELLING] + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members=DoesNotExist|id + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=(_+[a-zA-Z0-9]*?$)|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins=TurtleScreen,Screen,RawTurtle,Turtle,RawPen,Pen,Shape,Vec2D,addshape,bgcolor,bgpic,bye,clearscreen,colormode,delay,exitonclick,getcanvas,getshapes,listen,mainloop,mode,numinput,onkey,onkeypress,onkeyrelease,onscreenclick,ontimer,register_shape,resetscreen,screensize,setup,setworldcoordinates,textinput,title,tracer,turtles,update,window_height,window_width,back,backward,begin_fill,begin_poly,bk,circle,clear,clearstamp,clearstamps,clone,color,degrees,distance,dot,down,end_fill,end_poly,fd,fillcolor,filling,forward,get_poly,getpen,getscreen,get_shapepoly,getturtle,goto,heading,hideturtle,home,ht,isdown,isvisible,left,lt,onclick,ondrag,onrelease,pd,pen,pencolor,pendown,pensize,penup,pos,position,pu,radians,right,reset,resizemode,rt,seth,setheading,setpos,setposition,settiltangle,setundobuffer,setx,sety,shape,shapesize,shapetransform,shearfactor,showturtle,speed,st,stamp,tilt,tiltangle,towards,turtlesize,undo,undobufferentries,up,width,write,xcor,ycor,write_docstringdict,done + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_,_cb + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,future.builtins + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branches=16 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=12 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=30 + +# Maximum number of boolean expressions in a if statement +max-bool-expr=5 + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=optparse + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/db/seeds/turtle/main.py b/db/seeds/turtle/main.py new file mode 100644 index 000000000..7fd4f5cd4 --- /dev/null +++ b/db/seeds/turtle/main.py @@ -0,0 +1,67 @@ +from turtle import * + +def erstelle_turtle(x, y, rotationsWinkel = 0, shape = "triangle", color = "green"): + steuerung = Turtle() + steuerung.speed(0) # schnellste Animationsgeschwindigkeit, um sichtbare Bewegung zu vermeiden + steuerung.shape(shape) + steuerung.color(color) + steuerung.right(rotationsWinkel) + steuerung.penup() + steuerung.goto(x, y) + steuerung.direction = "stop" # nur für Kopf relevant + return steuerung + +rechts = erstelle_turtle(180, -160) +unten = erstelle_turtle(160, -180, 90) +links = erstelle_turtle(140, -160, 180) +oben = erstelle_turtle(160, -140, 270) +kopf = erstelle_turtle(0, 0, 0, "square", "black") + +def setze_richtung(dahin, dahinNicht): + # Vermeiden, dass Schlangenkopf zurück in sich selbst laufen kann + if kopf.direction != dahinNicht: + kopf.direction = dahin + kopf_bewegen() + +def kopf_bewegen(): + if kopf.direction == "down": + y = kopf.ycor() + kopf.sety(y - 20) + + elif kopf.direction == "right": + x = kopf.xcor() + kopf.setx(x + 20) + + elif kopf.direction == "up": + y = kopf.ycor() + kopf.sety(y + 20) + + elif kopf.direction == "left": + x = kopf.xcor() + kopf.setx(x - 20) + + +def checke_kollision_mit_fensterrand(): + if kopf.xcor() > 190 or kopf.xcor() < -190 or kopf.ycor() > 190 or kopf.ycor() < -190: + spiel_neustarten() + + +def interpretiere_eingabe(x, y): + if (x >= 170 and x <= 190 and y >= -170 and y <= -150): + setze_richtung("right", "left") + elif (x >= 150 and x <= 170 and y >= -190 and y <= -170): + setze_richtung("down", "up") + elif (x >= 130 and x <= 150 and y >= -170 and y <= -150): + setze_richtung("left", "right") + elif (x >= 150 and x <= 170 and y >= -150 and y <= -130): + setze_richtung("up", "down") + else: + return None + checke_kollision_mit_fensterrand() + +def spiel_neustarten(): + kopf.goto(0, 0) + kopf.direction = "stop" + +onclick(interpretiere_eingabe) +mainloop() diff --git a/db/seeds/turtle/test_style.py b/db/seeds/turtle/test_style.py new file mode 100644 index 000000000..35507c159 --- /dev/null +++ b/db/seeds/turtle/test_style.py @@ -0,0 +1,7 @@ +from pylint import epylint as lint +import glob + +pylint_opts = ['--rcfile=default.pylintrc'] +exercise = glob.glob('main.py')[0] +lint.lint(exercise, options=pylint_opts) +exit() diff --git a/spec/factories/execution_environment.rb b/spec/factories/execution_environment.rb index 7724397b9..18d07b0de 100644 --- a/spec/factories/execution_environment.rb +++ b/spec/factories/execution_environment.rb @@ -73,18 +73,18 @@ created_by_teacher default_memory_limit default_cpu_limit - docker_image { 'openhpi/co_execenv_python:3.4' } + docker_image { 'openhpi/co_execenv_python:3.8' } file_type { association :dot_py, user: } help - name { 'Python 3.4' } + name { 'Python 3.8' } network_enabled { false } privileged_execution { false } permitted_execution_time { 10.seconds } pool_size { 0 } - run_command { 'python3 %{filename}' } + run_command { 'python3 -B /usr/lib/python3.8/webpython.py -f %{filename}' } singleton_execution_environment test_command { 'python3 -m unittest --verbose %{module_name}' } - testing_framework { 'PyUnitAdapter' } + testing_framework { 'PyUnitAndPyLintAdapter' } end factory :ruby, class: 'ExecutionEnvironment' do diff --git a/spec/factories/exercise.rb b/spec/factories/exercise.rb index f04daff68..fe23031fb 100644 --- a/spec/factories/exercise.rb +++ b/spec/factories/exercise.rb @@ -75,6 +75,20 @@ def create_seed_file(exercise, path, file_attributes = {}) end end + factory :turtle, class: 'Exercise' do + created_by_teacher + description { 'Interactive Turtle test exercise.' } + execution_environment { association :python, user: } + instructions + title { 'Interactive Turtle' } + + after(:create) do |exercise| + create_seed_file(exercise, 'turtle/main.py', role: 'main_file') + create_seed_file(exercise, 'turtle/test_style.py', feedback_message: 'Your solution is not correctly formated.', hidden: true, role: 'teacher_defined_linter') + create_seed_file(exercise, 'turtle/default.pylintrc', hidden: true, role: 'regular_file') + end + end + factory :fibonacci, class: 'Exercise' do created_by_teacher description { 'Implement a recursive function that calculates a requested Fibonacci number.' } diff --git a/spec/factories/file_type.rb b/spec/factories/file_type.rb index 7001bcac9..4e33a773b 100644 --- a/spec/factories/file_type.rb +++ b/spec/factories/file_type.rb @@ -124,6 +124,16 @@ singleton_file_type end + factory :dot_pylintrc, class: 'FileType' do + created_by_admin + editor_mode { 'ace/mode/plain_text' } + executable + file_extension { '.pylintrc' } + indent_size { 4 } + name { 'Python' } + singleton_file_type + end + factory :dot_rb, class: 'FileType' do created_by_admin editor_mode { 'ace/mode/ruby' } diff --git a/spec/services/proforma_service/convert_task_to_exercise_spec.rb b/spec/services/proforma_service/convert_task_to_exercise_spec.rb index f60cea59b..f11b9ef9c 100644 --- a/spec/services/proforma_service/convert_task_to_exercise_spec.rb +++ b/spec/services/proforma_service/convert_task_to_exercise_spec.rb @@ -146,7 +146,7 @@ before { create(:python) } it 'sets the execution_environment based on proglang name and value' do - expect(convert_to_exercise_service).to have_attributes(execution_environment: have_attributes(name: 'Python 3.4')) + expect(convert_to_exercise_service).to have_attributes(execution_environment: have_attributes(name: 'Python 3.8')) end end From 3fd746816833dcb1c1a42e734a2b2f74581a6b80 Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Tue, 29 Jul 2025 12:34:20 +0200 Subject: [PATCH 2/6] Minimal pylintrc --- db/seeds/turtle/default.pylintrc | 412 ------------------------------- 1 file changed, 412 deletions(-) diff --git a/db/seeds/turtle/default.pylintrc b/db/seeds/turtle/default.pylintrc index 149d381e4..308be6969 100644 --- a/db/seeds/turtle/default.pylintrc +++ b/db/seeds/turtle/default.pylintrc @@ -1,419 +1,7 @@ [MASTER] -# Specify a configuration file. -#rcfile= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Pickle collected data for later comparisons. -persistent=no - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Allow optimization of some AST trees. This will activate a peephole AST -# optimizer, which will apply various small optimizations. For instance, it can -# be used to obtain the result of joining multiple strings with the addition -# operator. Joining a lot of strings can lead to a maximum recursion error in -# Pylint and this flag can prevent that. It has one side effect, the resulting -# AST will be different than the one from reality. This option is deprecated -# and it will be removed in Pylint 2.0. -optimize-ast=no - - [MESSAGES CONTROL] -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=all - -# Leo WWW -# disable=delslice-method,parameter-unpacking,zip-builtin-not-iterating,useless-suppression,coerce-builtin,old-ne-operator,dict-iter-method,old-division,long-builtin,getslice-method,unpacking-in-except,suppressed-message,old-raise-syntax,round-builtin,print-statement,indexing-exception,unicode-builtin,execfile-builtin,setslice-method,import-star-module-level,input-builtin,apply-builtin,intern-builtin,raw_input-builtin,coerce-method,dict-view-method,file-builtin,next-method-called,map-builtin-not-iterating,metaclass-assignment,old-octal-literal,basestring-builtin,buffer-builtin,hex-method,long-suffix,backtick,nonzero-method,reload-builtin,unichr-builtin,cmp-method,cmp-builtin,filter-builtin-not-iterating,reduce-builtin,raising-string,using-cmp-argument,oct-method,standarderror-builtin,no-absolute-import,range-builtin-not-iterating,xrange-builtin,missing-docstring,locally-disabled,too-many-instance-attributes,cyclic-import,too-few-public-methods,wrong-import-position,trailing-whitespace,unused-variables,line-too-long - -# Adafruit Learning: https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/.pylintrc -# disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace,consider-using-enumerate,unexpected-keyword-arg - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. - -# based on the 1000 most messages from the Python15 course -enable=bad-whitespace,undefined-variable,bad-indentation,redefined-outer-name,mixed-indentation,unused-variable,redefined-builtin,unnecessary-semicolon,unused-argument,used-before-assignment,pointless-statement,unreachable,inconsistent-return-statements,pointless-string-statement,redefined-argument-from-local,function-redefined,comparison-with-itself,return-outside-function,duplicate-except,bad-indentation,syntax-error,wrong-import-position,self-assigning-variable,duplicate-key,superfluous-parens,multiple-statements,undefined-loop-variable,import-error -#I18n schwer: invalid-name,bad-indentation,syntax-error,wrong-import-position,self-assigning-variable,duplicate-key -#?? vielleicht: missing-final-newline,trailing-newlines,superfluous-parens,multiple-statements,undefined-loop-variable -#!! eher nicht: bad-continuation - - [REPORTS] -# Set the output format. Available formats are text, parseable, colorized, msvs -# (visual studio) and html. You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -# Doesn't have any effect if run via python script -output-format=text - -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". This option is deprecated -# and it will be removed in Pylint 2.0. -files-output=no - -# Tells whether to display a full report or only the messages -reports=no - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - - [BASIC] - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,v,x,y,ex,Run,_ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct attribute names -attr-rgx=[a-z][a-z0-9_]{2,30}$ - -# Naming hint for attribute names -attr-name-hint=[a-z][A-Za-z0-9]{2,30}$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct method names -method-rgx=(?:(?:[a-z_][a-z0-9_]{2,30})|(?:test_[a-z0-9_]{2,}))$ - -# Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct function names -function-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Naming hint for function names -function-name-hint=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression matching correct argument names -argument-rgx=[a-z][a-z0-9_]{2,30}$ - -# Naming hint for argument names -argument-name-hint=[a-z][A-Za-z0-9]{2,30}$ - -# Regular expression matching correct constant names -const-rgx=(?:database_holder|flask|(([A-Z_][A-Z0-9_]*)|(__.*__)))$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression matching correct variable names -variable-rgx=[a-z][A-Za-z0-9_]{2,30}$ - -# Naming hint for variable names -variable-name-hint=[a-z][A-Za-z0-9]{2,30}$ - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - - -[ELIF] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[FORMAT] - -# Maximum number of characters on a single line. -max-line-length=120 - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - -# Maximum number of lines in a module -max-module-lines=1000 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=DoesNotExist|id - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - - -[VARIABLES] - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=(_+[a-zA-Z0-9]*?$)|dummy - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins=TurtleScreen,Screen,RawTurtle,Turtle,RawPen,Pen,Shape,Vec2D,addshape,bgcolor,bgpic,bye,clearscreen,colormode,delay,exitonclick,getcanvas,getshapes,listen,mainloop,mode,numinput,onkey,onkeypress,onkeyrelease,onscreenclick,ontimer,register_shape,resetscreen,screensize,setup,setworldcoordinates,textinput,title,tracer,turtles,update,window_height,window_width,back,backward,begin_fill,begin_poly,bk,circle,clear,clearstamp,clearstamps,clone,color,degrees,distance,dot,down,end_fill,end_poly,fd,fillcolor,filling,forward,get_poly,getpen,getscreen,get_shapepoly,getturtle,goto,heading,hideturtle,home,ht,isdown,isvisible,left,lt,onclick,ondrag,onrelease,pd,pen,pencolor,pendown,pensize,penup,pos,position,pu,radians,right,reset,resizemode,rt,seth,setheading,setpos,setposition,settiltangle,setundobuffer,setx,sety,shape,shapesize,shapetransform,shearfactor,showturtle,speed,st,stamp,tilt,tiltangle,towards,turtlesize,undo,undobufferentries,up,width,write,xcor,ycor,write_docstringdict,done - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of branch for function / method body -max-branches=16 - -# Maximum number of statements in function / method body -max-statements=50 - -# Maximum number of parents for a class (see R0901). -max-parents=12 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=30 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - - -[IMPORTS] - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception From 28651c6c20435a50d087d07cd2db458a9db40cc0 Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Tue, 29 Jul 2025 13:07:53 +0200 Subject: [PATCH 3/6] Change ace mode to ini --- spec/factories/file_type.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/factories/file_type.rb b/spec/factories/file_type.rb index 4e33a773b..c1bd59e1a 100644 --- a/spec/factories/file_type.rb +++ b/spec/factories/file_type.rb @@ -126,11 +126,10 @@ factory :dot_pylintrc, class: 'FileType' do created_by_admin - editor_mode { 'ace/mode/plain_text' } - executable + editor_mode { 'ace/mode/ini' } file_extension { '.pylintrc' } indent_size { 4 } - name { 'Python' } + name { 'Pylintrc' } singleton_file_type end From 8d35c3d3598f64875708f669e219a405bf9b7e1b Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Tue, 29 Jul 2025 13:33:12 +0200 Subject: [PATCH 4/6] Add source of the material. --- db/seeds/turtle/main.py | 6 ++++++ .../proforma_service/convert_task_to_exercise_spec.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/db/seeds/turtle/main.py b/db/seeds/turtle/main.py index 7fd4f5cd4..3701ea6be 100644 --- a/db/seeds/turtle/main.py +++ b/db/seeds/turtle/main.py @@ -1,3 +1,9 @@ +# Examples are based on the "Learning to program with Python - school version" +# course of the HPI student team for Python consists of the students +# Selina Reinhard, Nina Ihde, Kira Grammel and the doctoral student Sebastian Serth. +# +# Course available at: https://open.hpi.de/courses/pythonjunior-schule2024 + from turtle import * def erstelle_turtle(x, y, rotationsWinkel = 0, shape = "triangle", color = "green"): diff --git a/spec/services/proforma_service/convert_task_to_exercise_spec.rb b/spec/services/proforma_service/convert_task_to_exercise_spec.rb index f11b9ef9c..89bca4099 100644 --- a/spec/services/proforma_service/convert_task_to_exercise_spec.rb +++ b/spec/services/proforma_service/convert_task_to_exercise_spec.rb @@ -32,7 +32,7 @@ ProformaXML::Task.new( title: 'title', description:, - proglang: {name: 'python', version: '3.4'}, + proglang: {name: 'python', version: '3.8'}, uuid: 'uuid', parent_uuid: 'parent_uuid', language: 'language', From b8c0635ea1424efb7c4968e6eb8809e5f0d0edf4 Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Fri, 1 Aug 2025 08:47:54 +0200 Subject: [PATCH 5/6] Course comment update --- db/seeds/turtle/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/seeds/turtle/main.py b/db/seeds/turtle/main.py index 3701ea6be..6f3ec3742 100644 --- a/db/seeds/turtle/main.py +++ b/db/seeds/turtle/main.py @@ -1,8 +1,10 @@ -# Examples are based on the "Learning to program with Python - school version" -# course of the HPI student team for Python consists of the students -# Selina Reinhard, Nina Ihde, Kira Grammel and the doctoral student Sebastian Serth. -# -# Course available at: https://open.hpi.de/courses/pythonjunior-schule2024 +# This example is based on content from the 2020 openHPI course +# "Programmieren lernen mit Python" ("Learning to Program with Python") +# Authors: Kira Grammel, Nina Ihde, Selina Reinhard, and Sebastian Serth +# Published by: openHPI, Hasso-Plattner-Institut für Digital Engineering gGmbH +# License: CC BY-NC-SA 4.0, https://creativecommons.org/licenses/by-nc-sa/4.0 +# +# The course is freely available at: https://open.hpi.de/courses/pythonjunior2020 from turtle import * From 2976b19c78fed5437ad45018e84c298ad3acb83f Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Mon, 4 Aug 2025 14:23:50 +0200 Subject: [PATCH 6/6] Update db/seeds/turtle/main.py Co-authored-by: Sebastian Serth --- db/seeds/turtle/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/seeds/turtle/main.py b/db/seeds/turtle/main.py index 6f3ec3742..e77c3c2c9 100644 --- a/db/seeds/turtle/main.py +++ b/db/seeds/turtle/main.py @@ -1,9 +1,9 @@ -# This example is based on content from the 2020 openHPI course -# "Programmieren lernen mit Python" ("Learning to Program with Python") -# Authors: Kira Grammel, Nina Ihde, Selina Reinhard, and Sebastian Serth -# Published by: openHPI, Hasso-Plattner-Institut für Digital Engineering gGmbH +# This example is based on content from the 2020 openHPI course +# "Programmieren lernen mit Python" ("Learning to Program with Python") +# Authors: Kira Grammel, Nina Ihde, Selina Reinhard, and Sebastian Serth +# Published by: openHPI, Hasso-Plattner-Institut für Digital Engineering gGmbH # License: CC BY-NC-SA 4.0, https://creativecommons.org/licenses/by-nc-sa/4.0 -# +# # The course is freely available at: https://open.hpi.de/courses/pythonjunior2020 from turtle import *