I am trying to insert a record into the database inside of a webservice and it seems to be erroring out on me. I have tried surrounding the code block in a try-catch but it does not seem to be catching the exception.
echo 'before insert ';
//actually create the attempt record
$transaction = $DB->start_delegated_transaction();
echo 'start delegated ';
$attempt->uniqueid = $quba->get_id();
echo 'get unique id ';
$attempt->id = $DB->insert_record('quiz_attempts', $attempt);
echo 'after insert ';
echo 'after commit ';
Only the first echo is being called which leads me to believe that the problem is the transaction start. I have commented that out and do not get past the insert_record call either.
The function is defined in services.php as type write:
'local_assess_attempt_quiz' => array(
'classname' => 'local_assess_external',
'methodname' => 'attempt_quiz',
'classpath' => 'local/assess/externallib.php',
'description' => 'Create a new attempt for the quiz and return the questions',
'type' => 'write',
Anything obvious I am missing here. I have no problems doing database reads in other web service functions.
Any help would be appreciated.