Пример #1
0
        public void CreateQualificationTypeWithTest()
        {
            CreateQualificationTypeRequest req = new CreateQualificationTypeRequest();
            req.AutoGranted = false;
            req.QualificationTypeStatus = QualificationTypeStatus.Active;
            req.QualificationTypeStatusSpecified = true;
            req.Keywords = "MTurkQual, MTurkQualWithTest";
            req.Description = "Qualification requiring test";
            req.Name = string.Format("Qualification requiring test ({0:g})", DateTime.Now);
            //req.Test = TurkUtil.SerializeQuestionForm(TurkUtil.ReadQuestionFormFromFile(Path.Combine(TestUtil.DataPath, "QuestionForm.xml")));
            req.Test = QuestionUtil.ConvertMultipleFreeTextQuestionToXML(
                new string[] { "What's the difference between apples and oranges?", "What's 2+plus?" });
            req.TestDurationInSeconds = 60;

            CreateQualificationTypeResponse response = (CreateQualificationTypeResponse)TestUtil.Client.SendRequest(req);
            Assert.IsNotNull(response.QualificationType[0].QualificationTypeId, "Failed to create simple qualification type. ID is null");
        }
Пример #2
0
        public static void CreateSimpleQualificationType(string name, string description)
        {
            CreateQualificationTypeRequest req = new CreateQualificationTypeRequest();
            req.AutoGranted = true;
            req.QualificationTypeStatus = QualificationTypeStatus.Active;
            req.QualificationTypeStatusSpecified = true;
            req.Keywords = "MTurkQual, SimpleMTurkQual";
            req.Description = "Simple qualification requiring no test - autogranted";
            req.Name = string.Format("No test - Autogrant ({0:g}.{1})", DateTime.Now, DateTime.Now.Millisecond);

            CreateQualificationTypeResponse response = (CreateQualificationTypeResponse)TestUtil.Client.SendRequest(req);
            Assert.IsNotNull(response.QualificationType[0].QualificationTypeId, "Failed to create simple qualification type. ID is null");

            TestUtil.CreatedQualificationTypes.Add(response.QualificationType[0].QualificationTypeId);
        }
Пример #3
0
        /// <summary>
        /// The CreateQualificationType operation creates a new Qualification type.
        /// </summary>
        /// <param name="request">Type of the create qualification.</param>
        /// <returns>
        /// A <see cref="QualificationType"/> instance
        /// </returns>
        /// <remarks> Every Qualification has a Qualification type. The creator of the type can assign
        /// Qualifications of that type to Workers, and grant requests for Qualifications of the type 
        /// made by Workers. A Qualification can be considered a statement about a Worker made by the 
        /// Qualification type's owner. A Qualification type may include a Qualification test, a set 
        /// of questions a Worker must answer to request the Qualification. The type may also include 
        /// an answer key for the test. Qualification requests for types with answer keys are granted 
        /// automatically by Mechanical Turk, using a value calculated from the answer key and the 
        /// Worker's test answers. If the Qualification type does not have a test, or does
        /// not have an answer key, the type's owner is responsible for polling for and granting 
        /// Qualification requests.</remarks>
        public QualificationType CreateQualificationType(CreateQualificationTypeRequest request)
        {
            request.Test = EnsureQuestionIsWrappedAndValid(request.Test, false);

            CreateQualificationTypeResponse response = (CreateQualificationTypeResponse)(this.SendRequest(request));

            return response.QualificationType[0];
        }
Пример #4
0
        /// <summary>
        /// See <a href="http://docs.amazonwebservices.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_CreateQualificationTypeOperation.html">online documentation for this operation.</a>
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="keywords">The keywords.</param>
        /// <param name="description">The description.</param>
        /// <param name="status">The status.</param>
        /// <param name="retryDelayInSeconds">The retry delay in seconds.</param>
        /// <param name="test">The test. If the question is not wrapped as XML, it will be wrapped as a simple free text question (<see cref="QuestionUtil"/>)</param>
        /// <param name="answerKey">The answer key.</param>
        /// <param name="testDurationInSeconds">The test duration in seconds.</param>
        /// <param name="autoGranted">The auto granted.</param>
        /// <param name="autoGrantedValue">The auto granted value.</param>
        /// <returns>A <see cref="QualificationType"/> instance</returns>
        public QualificationType CreateQualificationType(string name, string keywords, string description,
            QualificationTypeStatus? status, long retryDelayInSeconds, string test, string answerKey,
            long? testDurationInSeconds, bool?autoGranted, int? autoGrantedValue)
        {
            CreateQualificationTypeRequest request = new CreateQualificationTypeRequest();
            request.Name = name;
            request.Keywords = keywords;
            request.Description = description;
            request.RetryDelayInSeconds = retryDelayInSeconds;
            request.Test = test;
            request.AnswerKey = answerKey;

            if (status.HasValue)
            {
                request.QualificationTypeStatus = status.Value;
                request.QualificationTypeStatusSpecified = true;
            }
            if (testDurationInSeconds.HasValue)
            {
                request.TestDurationInSeconds = testDurationInSeconds.Value;
                request.TestDurationInSecondsSpecified = true;
            }
            if (autoGranted.HasValue)
            {
                request.AutoGranted = autoGranted.Value;
                request.AutoGrantedSpecified = true;
            }
            if (autoGrantedValue.HasValue)
            {
                request.AutoGrantedValue = autoGrantedValue.Value;
                request.AutoGrantedValueSpecified = true;
            }

            return Proxy.CreateQualificationType(request);
        }