private void LoadItemScorer(XElement element)
        {
            string format         = element.Attribute("format").Value;
            string typeName       = element.Attribute("type").Value;
            Type   itemScorerType = LookupType(typeName);

            if (itemScorerType == null)
            {
                throw new TypeLoadException(String.Format("Could not find the item scorer type: {0}", typeName));
            }

            IItemScorer itemScorer = CreateInstance(itemScorerType);

            _itemScorerManager.RegisterItemScorer(format, itemScorer);
        }
        private ItemScore InvokeAsynchronousScoring(IItemScorer scorerImpl, ResponseInfo studentResponse, IItemScorerCallback callbackReference)
        {
            // if the scorer supports async mode then let the item scorer server deal with async
            if (scorerImpl.GetScorerInfo(studentResponse.ItemFormat).SupportsAsyncMode)
            {
                return(scorerImpl.ScoreItem(studentResponse, callbackReference));
            }

            // if the scorer does not handle async mode then we need to handle it in our own thread queue
            if (threadPool.Enqueue(new AsyncScoringTask(scorerImpl, studentResponse, callbackReference)))
            {
                return(new ItemScore(-1, -1, ScoringStatus.WaitingForMachineScore, null, null, null, studentResponse.ContextToken));
            }

            // if we get here then the thread queue is filled (probably waiting on a bunch of scores to come back)
            return(new ItemScore(-1, -1, ScoringStatus.WaitingForMachineScore, null, new ScoreRationale()
            {
                Msg = "Cannot enqueue scoring task"
            }, null, studentResponse.ContextToken));
        }
 private ItemScore InvokeSynchronousScoring(IItemScorer scorerImpl, ResponseInfo studentResponse)
 {
     return(scorerImpl.ScoreItem(studentResponse, null));
 }
 public void RegisterItemScorer(string itemFormat, IItemScorer itemScorerImpl)
 {
     scoringEngines.Add(itemFormat, itemScorerImpl);
 }
 public AsyncScoringTask(IItemScorer scorer, ResponseInfo studentResponse, IItemScorerCallback callback) : base(null)
 {
     this.scorerImpl      = scorer;
     this.studentResponse = studentResponse;
     this.callback        = callback;
 }