As belidos said, the best/easiest way to do it is via a new map/level each time.
For the quest fail that will depend on the requirement, I.e. if it's timed or just picking the wrong wire when defusing a bomb etc... Depending on the quest.
That part will need to be scripted though yes.
For changing level there are a few ways but perhaps the best method (to make sure everything copies and loads correctly in standalone) is to make a won zone as normal but make sure the player can only get there when winning/failing the level. (You can set the players position via script).