Exemple #1
0
        /// <summary>
        /// Download HIT info from AMT
        /// </summary>
        /// <param name="amtHitId">AMT HITId</param>
        /// <returns>A HitInfo object</returns>
        private AmtHit GetHit(string amtHitId)
        {
            AmtHit myHitInfo = new AmtHit();
            try
            {
                SimpleClient myMturkClient = new SimpleClient(_mturkConfig);
                HIT myHit = myMturkClient.GetHIT(amtHitId);
                myHitInfo.AmtHitId = amtHitId;
                myHitInfo.Title = myHit.Title;
                myHitInfo.Description = myHit.Description;
                myHitInfo.Keywords = myHit.Keywords;
                myHitInfo.GroupId = myHit.HITGroupId;
                myHitInfo.LayoutId = myHit.HITLayoutId;
                myHitInfo.TypeId = myHit.HITTypeId;
                myHitInfo.Question = myHit.Question;
                myHitInfo.RequesterAnnotation = myHit.RequesterAnnotation;
                myHitInfo.CreationTime = myHit.CreationTime;
                myHitInfo.Expiration = myHit.Expiration;
                myHitInfo.AssignmentDuration = myHit.AssignmentDurationInSeconds;
                myHitInfo.MaxAssignments = myHit.MaxAssignments;
                myHitInfo.NumberOfAssignmentsCompleted = myHit.NumberOfAssignmentsCompleted;
                myHitInfo.NumberOfAssignmentsPending = myHit.NumberOfAssignmentsPending;
                myHitInfo.NumberOfAssignmentsAvailable = myHit.NumberOfAssignmentsAvailable;
                myHitInfo.Reward = myHit.Reward.Amount;
            }
            catch (Exception ex)
            {
                myHitInfo.Exception = ex.ToString();
            }

            return myHitInfo;
        }
 /// <summary>
 /// Prints the submitted results of a HIT when provided with a HIT ID and allows for
 /// acceptance or rejection of work
 /// </summary>
 /// <remarks>
 /// If you don't know a valid HIT ID, you can use a HIT created by another example, such
 /// as HelloWorld.
 /// 
 /// NOTE: The CreateHitUI example copies the ID of the created HIT in the clipboard, which
 /// makes it easy to use in conjunction with the Reviewer example
 /// </remarks>
 /// <param name="hitID">ID of hit to review</param>
 public void ReviewAnswers(string hitID)
 {
     SimpleClient client = new SimpleClient();
     HIT myHIT = client.GetHIT(hitID);
     int count = 0;
     assignments = GetAssignments(hitID);
     if (assignments == null || assignments.Count == 0)
     {
         Console.WriteLine("No assignments found for HIT {0}", hitID);
     }
     else
     {
         foreach (Assignment a in assignments)
         {
             // check submitted assignments for answer data
             Console.WriteLine(count + " : " + "Assignment {0} for worker {2} ({1})", a.AssignmentId, a.AssignmentStatus, a.WorkerId);
             if (a.AssignmentStatus == AssignmentStatus.Submitted)
             {
                 QuestionForm myForm = QuestionUtil.DeserializeQuestionForm(myHIT.Question);
                 foreach (QuestionFormQuestion q in myForm.Question)
                 {
                     PrintQuestion(q);
                 }
                 QuestionFormAnswers answers = QuestionUtil.DeserializeQuestionFormAnswers(a.Answer);
                 foreach (QuestionFormAnswersAnswer answer in answers.Answer)
                 {
                     PrintAnswer(answer);
                 }
             }
             count++;
         }
     }
 }