SQL ERROR Line 184 database.php queryError

SELECT at.* ,ans.* ,u.username , u.username as student ,at.atimestamp ,q.qquestion as number ,e.ename as exercise ,c.ccourse as course ,at.apage as webpage ,at.attempt as answer ,FROM_UNIXTIME(at.atimestamp) as attempt_time ,ans.ans_correct as correct ,ans.ans_feedback as feedback ,(CASE WHEN at.attempt = ans.possible_answer THEN 1 ELSE 0 END ) as marked FROM et_question_attempt at LEFT JOIN et_question_answer ans ON ans.ansqid = atm.atmqid AND atm.attempt = ans.possible_answer AND ans.ans_deleted = 0 LEFT JOIN et_question q ON q.id = atm.atmqid JOIN et_exercise e ON e.id = q.eid JOIN et_course c ON c.id = e.cid LEFT JOIN et_user u ON (u.id = atm.auid ) ORDER BY at.atimestamp DESC , ans.qid

SQL Error

Unknown column 'atm.atmqid' in 'on clause'

Ln 1088 courseMethods.php getRecentSubmissions Failed query=> SELECT at.* ,ans.* ,u.username , u.username as student ,at.atimestamp ,q.qquestion as number ,e.ename as exercise ,c.ccourse as course ,at.apage as webpage ,at.attempt as answer ,FROM_UNIXTIME(at.atimestamp) as attempt_time ,ans.ans_correct as correct ,ans.ans_feedback as feedback ,(CASE WHEN at.attempt = ans.possible_answer THEN 1 ELSE 0 END ) as marked FROM et_question_attempt at LEFT JOIN et_question_answer ans ON ans.ansqid = atm.atmqid AND atm.attempt = ans.possible_answer AND ans.ans_deleted = 0 LEFT JOIN et_question q ON q.id = atm.atmqid JOIN et_exercise e ON e.id = q.eid JOIN et_course c ON c.id = e.cid LEFT JOIN et_user u ON (u.id = atm.auid ) ORDER BY at.atimestamp DESC , ans.qid
Unknown column 'atm.atmqid' in 'on clause'