The attorney general shall also represent the state and all officials, departments, boards, commissions and agencies of the state in the courts, and before all administrative tribunals or bodies of any nature, in all legal or quasi legal matters, hearings, or proceedings, and advise all officials, departments, boards, commissions, or agencies of the state in all matters involving legal or quasi legal questions, except those declared by law to be the duty of the prosecuting attorney of any county.