A man jailed for stealing a gingerbread man during the London riots died after he was failed by a prison - described by its own staff as a “shambles” - an inquest has heard.

James Best, 37, was being held on remand at Wandsworth Prison when he collapsed following a “heavy gym session” and died on September 8, 2011.

Mr Best had a history of medical problems including Crohn’s disease, asthma and high blood pressure and, under the system in place, should not have been allowed to use the gym without seeing a GP first, the inquest heard.

But staff who worked in the prison gym at the time criticised the system of safety checks and said there was no way of knowing if inmates had in fact been passed fit by a doctor.

Former PE officer, Shane Donnelly, agreed the system of reporting health problems had weaknesses, describing it as “hit and miss”.

Asked if it was possible for staff to distinguish between those who had been passed fit and those who had not, Mr Donnelly replied: “Not in August that year, no.”

A second PE officer, Emanuel Joe, told the inquest a medical form filled out by each prisoner was supposed to be passed to the prison’s healthcare department before they were allowed to train.

But in reality these forms were never passed on and prisoners such as Mr Best were wrongly allowed to use the facilities.

Mr Joe agreed with coroner Dr Fiona Wilcox that the system was a “shambles” and described some of his colleagues as “lazy”.

Dr Wilcox, sitting at Westminster Coroner’s Court on Tuesday, added: “It appears that there was no system at all.”

A third PE officer, Ravinder Sandou, told the court that medical forms were being signed by prisoners working as gym orderlies, rather than prison staff as required.

Mr Best, who later worked as a chef, was adopted at 18 months but then fostered at 15 by Dolly Daniel.

Fighting back tears Mrs Daniel said: “James quickly became a hero to our two boys. He would organise games in the house and the boys would play cricket in the hallway.

Following the London riots, Mrs Daniel read online that her foster son was awaiting sentence after admitting stealing an item from Munchies bakery, in Croydon, during the disorder.

She added: “We are devastated that James tragically died in prison in fear and pain and without the comfort and support of family.”

In 2011 Wandsworth Prison, which holds 1,665 prisoners, was branded the most "unsafe" in the country for inmates following a scathing report by the country's chief jail inspector.

Between January 2010 and June 2011, there were 11 deaths at the jail and this week’s inquest is the third this year into the death of a prisoner.

The inquest is expected to last for five days.