Here is an outline that I would try. First, use a context that can make Set MathObjects. The Interval context can do this.

https://webwork.maa.org/wiki/Set_(MathObject_Class)

https://webwork.maa.org/wiki/Introduction_to_Contexts

Next, make a..j be constants in this context. Give them distinct values that a student would never happen to guess. For example, j might be pi/sqrt(2). Set them to always display as their letter, not as a numerical value.

https://webwork.maa.org/wiki/Introduction_to_Contexts#Constants

Now make

$full = Set("{a,b,c,d,e,f,g,h,i,j}");

and make one example answer

$answer = Set("{ab,c,d,e}");

Then build a custom answer checker.

https://webwork.maa.org/wiki/Custom_Answer_Checkers

The custom answer checker code should check that the student answer is a subset of $full, and that it has five elements. You could use the "contains" method or the "isSubsetOf" method here:

https://webwork.maa.org/wiki/Set_(MathObject_Class)#Methods

And you need to check the student answer has five elements. I'm guessing that if $student is a Set object, then $student->value will be an array with its entries, and you wnat to access the length of that array. One explicit way to do that is using :

scalar ($student->value)

as in:

if (scalar ($student->value) == 5) {...}

I think you could just do:

if ($student->value == 5) {...}