York Crown Court heard that Davidson - who had been regarded as “something of an institution” at the secondary school after working there for 20 years - had blown over £200,000 on gambling over seven years.

Prosecutor Chloe Fairley said Davidson had been trusted to manage the school’s catering finances, but in 2007 she began siphoning money from a “revaluation” machine which allows pupils and staff to deposit money into credit accounts for school meals.

“The machine was managed entirely by the defendant,” said Ms Fairley. “She was solely responsible for emptying the machine, counting the money and paying it in (to the system).”

In December last year, the school’s finance director noticed that the school’s catering department was running at a loss and that thousands of pounds had vanished from the budget.

An investigation was launched which showed that over £98,100 had disappeared from the catering funds since 2007, added Ms Fairley.

The financial director said Davidson had managed to get away with the “massive” money-grabbing ruse for so long because her reputation as a highly-trusted employee meant she didn’t initially come under suspicion or scrutiny.

Ms Fairley said that in January this year the director asked Davidson for a money-management account of catering funds, but she made “various excuses for not being able to meet him”.

She eventually admitted taking just £1,300 on just one occasion, prompting a disciplinary hearing at the school. Davidson handed in her resignation and promised to pay the money back. She was duly suspended.

Ms Fairley said the vast sums stolen by Davidson began to escalate in 2011 - at the same time as her gambling habit spiralled out of control.

Davidson, of Poplar Way, Harrogate, blew £202,000 on online gambling between 2008 and 2015. She also racked up £110,000 of credits on gambling websites.

Ms Fairley said that as Davidson’s gambling addiction grew, the more confident she became of getting away with it, although none of the students had been affected.

Davidson appeared for sentence on Tuesday after pleading guilty to the astronomical thefts.

Her barrister Alisdair Campbell said that Davidson’s husband, to whom she had been married for over 40 years, had no idea about his wife’s gambling problem because she managed to hide it from all her friends and family.

Judge Paul Batty QC described Davidson’s thieving as “massive dishonesty on a massive scale”, adding: “No-one questioned your authority; no-one questioned the amounts that you emptied from the machine because you were known as something of an institution at the school.

“This is not a case where you needed the money. You were stealing to fund an addiction which has ultimately ruined you.”

Mr Batty gave Davidson a 16-month jail sentence and adjourned financial-confiscation proceedings until June next year. The Proceeds of Crime hearing will determine how much Davidson has to repay.

A Rossett School spokesman said: “Betty Davidson was a trusted employee. We were deeply shocked to find that she had betrayed the trust we put in her.

“Although our finances are regularly audited and monitored, this deception was carried out in a very tactical way to make it almost impossible to detect until a new financial regime was introduced and the theft was uncovered.”