When there is no answer in a question using the numerical options (numerical, calculated ...) the function get_question_options(&$question) return without setting default values for numerical options.
When editing the question, the code setting the default_values
if (isset($question->options)){
$default_values['unitgradingtypes'] = 1 ;
should be replaced by
if (isset($question->options->unitgradingtypes)){
$default_values['unitgradingtypes'] = 1 ;
and so on...