Moved StudyGuides handler to api.php &improvements

and improved type of attachment recognition