예제 #1
0
        /// <summary>
        /// Serializes the question form into XML accepted by Mechanical Turk
        /// </summary>
        /// <param name="form">A <see cref="QuestionForm"/> instance to serialize</param>
        /// <returns>XML string</returns>
        public static string SerializeQuestionForm(QuestionForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException("form", "Can't serialize null form");
            }

            string s1 = XmlUtil.SerializeXML(form);

            int i1 = s1.IndexOf("<Overview>");
            if (i1 == -1)
            {
                i1 = s1.IndexOf("<Question>");
            }

            if (i1 == -1)
            {
                throw new ArgumentException("Cannot serialize question form (contains no questions)");
            }

            s1 = InjectCDataBlocksForFormattedContents(s1);
            s1= string.Format(TPL_FREE_TEXT_QUESTION_FORM,
                s1.Substring(i1, s1.IndexOf("</QuestionForm>") - i1));

            return s1;
        }
예제 #2
0
 /// <summary>
 /// See <a href="http://docs.amazonwebservices.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_CreateHITOperation.html">online documentation for this operation.</a>
 /// </summary>
 /// <param name="hitTypeId">The hit type id.</param>
 /// <param name="title">The title.</param>
 /// <param name="description">The description.</param>
 /// <param name="keywords">The keywords.</param>
 /// <param name="question">The question.</param>
 /// <param name="reward">The reward.</param>
 /// <param name="assignmentDurationInSeconds">The assignment duration in seconds.</param>
 /// <param name="autoApprovalDelayInSeconds">The auto approval delay in seconds.</param>
 /// <param name="lifetimeInSeconds">The lifetime in seconds. If 0, defaults to 3 days.</param>
 /// <param name="maxAssignments">The max assignments.</param>
 /// <param name="requesterAnnotation">The requester annotation.</param>
 /// <param name="qualificationRequirements">The qualification requirements.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns>A <see cref="HIT"/> instance</returns>
 public HIT CreateHIT(string hitTypeId, string title, string description, string keywords, QuestionForm question,
     decimal? reward, long? assignmentDurationInSeconds, long? autoApprovalDelayInSeconds, long lifetimeInSeconds,
     int? maxAssignments, string requesterAnnotation, List<QualificationRequirement> qualificationRequirements,
     string[] responseGroup)
 {
     return CreateHIT(hitTypeId, title, description, keywords,
         QuestionUtil.SerializeQuestionForm(question),
         reward, assignmentDurationInSeconds, autoApprovalDelayInSeconds, lifetimeInSeconds,
         maxAssignments, requesterAnnotation, qualificationRequirements, responseGroup);
 }