On a beautiful autumn day, Annan Academy is looking its best. The impressive main building, with its sandstone tower, dates from Victorian times; its streamlined modern wing was added in the 1960s. Inside, the reception area is quiet and welcoming, with a noticeboard displaying pictures of a visit by the Princess Royal in March to mark the 200th anniversary of the school's founding.
Upstairs in his office, headteacher James Leggat looks rather pleased with life and admits that Annan Academy has a lot going for it. "But it's not all rosy," he points out. "One of our biggest problems here is a lack of employment prospects for young people."
That hasn't always been the case. Anne Ramsbottom, curator of Annandale and Eskdale Museums, says there were "loads of jobs" available when the academy opened in 1802 as a fee-paying burgh school. These included apprenticeships and agricultural work, The local newspaper carried notices such as "A stout lad wanted, to look after a pony and make himself useful about the farm" and Annan Academy advertised for three 14-year-old girls to act as pupil teachers.
What children did when they left school was one of the subjects covered in a recent exhibition celebrating three centuries of local schooling at the Annan Historic Resources Centre. Although the show focused on the academy, it told the story of education from around 1690, when the town's first parish school was established as part of Scotland's drive towards national literacy.
The writer and philosopher Thomas Carlyle attended the academy as a boarder not long after the academy opened and hated the experience, describing his fellow pupils as "mostly rude boys who obeyed the impulse of rude nature".
Numerous private schools operated in Annan during the 18th and 19th centuries, with varying degrees of success. A school set up in 1871 for employees of a weaving mill became so popular when it was run by artistteacher Willie Wright (who lived until 1944) that parents moved children from the academy to attend it.
Although firmly established in the community by then, the academy had gone through a rough patch in the 1820s when, five years into his job, the headteacher was sacked after the town council decided the school had "greatly fallen off in respectability".
Ms Ramsbottom says there are still people in the town who can remember hearing about the fights that used to break out between pupils from the still fee-paying Annan Academy and the non-fee paying parish school when the two amalgamated, on the Academy's present site, in 1921. Although the children were segregated in the playground, the fighting is said to have continued until fees were abolished in 1932.
"It's tempting fate to say this," says Mr Leggat, who has been head for nine years, "but we haven't had a fight in the playground for months. Pupils today are certainly noisier but I am convinced they are better behaved.
"There are teachers in the school who would say that some pupils are over-willing to question authority but, on the whole, I think kids are more responsible, more tolerant and more sensible than they were a generation ago. That's largely due to the fact that there are established channels at most schools now where pupils can have their voices heard.
"As well as pupil councils for all year groups, our school captains attend school board meetings where they are expected to give their views and ask questions. We also send two pupils - on their own - to represent the school at community council meetings."
The academy is the only secondary school in Annan and one of the biggest in this area of Dumfries and Galloway, with 1,140 pupils, 73 teaching staff and 20 non-teaching staff. This contrasts with the days when there might have been half-a-dozen teachers and a cook.
So, what would past headteachers make of the academy now? "I think they would be surprised at the amount of work that teachers do on a whole-school basis," Mr Leggat says. "Collectively, we tackle things such as raising attendance levels, encouraging a responsible attitude in pupils and so on, whereas in the past, a teacher went into his or her classroom, shut the door, taught, then went away at the end of the day.
"It's also interesting to note, looking through the old log books, how much time previous rectors spent managing problems that cropped up due to infectious diseases such as diphtheria. Sometimes the whole school had to be closed because of an epidemic."
Such problems are not entirely restricted to the past. Annan Academy was seriously affected by last year's foot and mouth outbreak with emergency restrictions forcing pupils and teachers who lived on farms to stay at home or move in with non-farming relatives. "It was a difficult time," Mr Leggat admits, "and there were some youngsters who needed a lot of support."