numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
200 stars 118 forks source link

Marking: an add_credit_if function #859

Closed christianp closed 1 year ago

christianp commented 2 years ago

This is a common pattern: I have a list of independent criteria that a student's answer must fulfil. For each of them, I want to add a certain amount of credit if it's satisfied, and give some negative feedback otherwise.

At the moment, it's possible with this:

if(criterion_satisfied,
  add_credit(amount, "You did it!")
, negative_feedback("You didn't do it.")
)

It would be convenient to have a function add_credit_if(condition, amount, positive_feedback, negative_feedback) which is equivalent to the above code.

corgoss commented 2 years ago

Hi, I would like to try.

christianp commented 2 years ago

@hafhaf10 thanks for offering to help! Please look at our guide on contributing code to Numbas. The marking functions are defined in runtime/scripts/marking.js - you should add a new function 'add_credit_if'.

chanuka-dsc commented 2 years ago

Hi, i would also like to try to contribute to this issue.