How to determine quality of spices
Well, let me just cover bottled spices here, since that seems like enough to bite off: 


Age: while often difficult to determine, age is the #1 determinant of spice quality.   Unfortunately, most mass market brands of spices do not print packaging dates on bottles (deliberately).  Try asking the staff at your market.  Dried herbs are at their best for 3-6 months, and ground seeds (cumin etc.) are good for 6-12 months.
Vendor: different brands of spices have different levels of quality of sourcing, preparing, and packaging spices.  For example, I buy spices from Penzey's specifically because I know their high-quality sourcing and preparation.  Cook's Illustrated rated Spice Islands superior among supermarket brands.
Variety: some varieties of certain common spices are better than others.  Ceylon cinnamon is superior to Mexican; Tellicherry peppercorns are superior to the common variety; and Turkish bay leaves are better than Californian.  Also, because they are more expensive, finer varieties of spices are often packaged and stored better. 
Storage Conditions: heat, moisture, and/or direct sunlight all cause spices to age much faster.  To check for moisture, look for caking.  To check for exposure to sunlight, look for faded colors, especially on only one side of the bottle.
Smell: if you're buying in bulk, or you already have the bottle open, most spices should have a strong and distinctive aroma.  If they don't, they're probably old.
Taste: Spices should taste of themselves and not have extra musty or bitter flavors. These off tastes are generally indications of age and/or poor storage.