pythonwhat icon indicating copy to clipboard operation
pythonwhat copied to clipboard

check_function() not working as documented (or what am I missing?)

Open gordonje opened this issue 4 years ago • 0 comments

Hello!

Just recently stumbled across this project in conjunction with datacamp-light, and I'm really keen to incorporate into some online assignments for my students.

However, I'm having trouble using check_function() in my SCT. Can't even get the first example in under "Basic functionality" (in your docs) to work.

Here's my markup:

<div data-datacamp-exercise data-lang="python">
  <code data-type="sample-code">

    round(2.718282, ndigits = 3)

  </code>
  <code data-type="sct">
    Ex().check_function("round").multi(
      check_args("number").has_equal_value(),
      check_args("ndigits").has_equal_value()
    )
  </code>
</div>

The result when I hit "Run" looks correct. But when I hit "Submit, here's the error I get:

DataCamp encountered the following error:
Traceback (most recent call last):
  File "/var/lib/python/site-packages/protobackend/output.py", line 70, in wrapper
    output = f(*args, **kwargs)
  File "/var/lib/python/site-packages/pythonbackend/commands.py", line 63, in worker_dispatch
    return d.dispatch(cmd)
  File "/var/lib/python/site-packages/protobackend/dispatcher.py", line 28, in dispatch
    cmd_output = cmd(pre_payload)
  File "/var/lib/python/site-packages/pythonbackend/Exercise.py", line 123, in runSubmit
    self.dc_force_diagnose,
  File "/var/lib/python/site-packages/pythonwhat/test_exercise.py", line 67, in test_exercise
    raise e
  File "/var/lib/python/site-packages/pythonwhat/test_exercise.py", line 57, in test_exercise
    exec(sct, sct_cntxt)
  File "<string>", line 1, in <module>
  File "/var/lib/python/site-packages/protowhat/sct_syntax.py", line 258, in __call__
    ChainedCall(self.function, args, kwargs), previous=self.chain
  File "/var/lib/python/site-packages/protowhat/sct_syntax.py", line 225, in __init__
    self._state = chained_call(state)
  File "/var/lib/python/site-packages/protowhat/sct_syntax.py", line 113, in __call__
    return self.callable(state, *self.args, **self.kwargs)
  File "/var/lib/python/site-packages/protowhat/sct_syntax.py", line 78, in wrapper
    force=isinstance(error, InstructorError),
  File "/var/lib/python/site-packages/protowhat/failure.py", line 88, in _debug
    raise failure_type(state.get_feedback(FeedbackComponent(feedback)), state.state_history)
protowhat.failure.InstructorError: `check_function()` couldn't find a call of `round()` in the solution code. Make sure you get the mapping right!

Debug on error:
SCT function state history: `check_function`
Last test: `<Fail {'result': False, 'feedback': <FeedbackComponent {'append': True, 'message': "`check_function()` couldn't find a call of `round()` in the solution code. Make sure you get the mapping right!", 'kwargs': {}}>}>`

gordonje avatar Feb 03 '20 21:02 gordonje