Open up the console and type "caqs" (without the quotes). This will complete all of the game's quests.
I'm no expert in this area, but I did a bit of googling and I think there are some interesting aspects to this question. caqs is complete all quest stages? If so, besides completing all quests (which I would think would be problematic for most players) I don't think it will affect many of the challenges.
In re to challenges, I'v never dealt with them while modding, but they are a whole separate category and form type from quests. I haven't tried it, but I doubt any of the quest functions will work on them, and the challenge specific functions are limited
Is it possible to create a mod or some code that allows you to complete all the challenges, and gain all the perks with this?
i can't speak for everyone, but i always found the challenges annoying, not only my always showing my progress on the screen, but also that it is pretty much impossible to complete every single one. if anyone knows how this would be possible, or even if there are commands or mods that already complete this, please let me know!
Unfortunately, we don't have a function (that I could find) that completes a challenge
They may be in the game and in a future nvse version we might see one or more added. There is a GETCHALLENGECOMPLETED (can't find any documentation on it) but not a setChallengeCompleted.....which is what we need for what your request
So off the top of my head, the only suggestion I'd have is to delete all the challenges in the geck and write a script to add the perks from them.
It looks like there is just 20(ish) perks connected to challenges so the script wouldn't be a big deal and you'd no longer see any challenges. It's a round about way of doing it, but I think it would be equivalent to what your asking, barring any unforeseen consequences.