예제 #1
0
파일: operations.go 프로젝트: jesand/crowds
// GetReviewableHITs retrieves the HITs with Status equal to Reviewable or
// Status equal to Reviewing that belong to the Requester calling the operation.
func (client amtClient) GetReviewableHITs(hitTypeId, status,
	sortProperty string, sortAscending bool,
	pageSize, pageNumber int) (amtgen.TxsdGetReviewableHITsResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetReviewableHITs
		args     amtgen.TGetReviewableHITsRequest
		response amtgen.TxsdGetReviewableHITsResponse
	)
	args.HITTypeId = xsdt.String(hitTypeId)
	args.Status = amtgen.TReviewableHITStatus(status)
	args.SortProperty = amtgen.TGetReviewableHITsSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetReviewableHITs", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #2
0
파일: operations.go 프로젝트: jesand/crowds
// GetQualificationsForQualificationType returns all of the Qualifications
// granted to Workers for a given Qualification type.
func (client amtClient) GetQualificationsForQualificationType(
	qualificationTypeId string, isGranted bool,
	pageSize, pageNumber int) (
	amtgen.TxsdGetQualificationsForQualificationTypeResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetQualificationsForQualificationType
		args     amtgen.TGetQualificationsForQualificationTypeRequest
		response amtgen.TxsdGetQualificationsForQualificationTypeResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	if isGranted {
		args.Status = amtgen.TQualificationStatus("Granted")
	} else {
		args.Status = amtgen.TQualificationStatus("Revoked")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetQualificationsForQualificationType", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #3
0
파일: operations.go 프로젝트: jesand/crowds
// GetReviewResultsForHIT retrieves the computed results and the actions taken
// in the course of executing your Review Policies during a CreateHIT operation.
func (client amtClient) GetReviewResultsForHIT(hitId string,
	policyLevels []string,
	retrieveActions, retrieveResults bool,
	pageSize, pageNumber int) (amtgen.TxsdGetReviewResultsForHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetReviewResultsForHIT
		args     amtgen.TGetReviewResultsForHITRequest
		response amtgen.TxsdGetReviewResultsForHITResponse
	)
	args.HITId = xsdt.String(hitId)
	for _, level := range policyLevels {
		args.PolicyLevels = append(args.PolicyLevels,
			amtgen.TReviewPolicyLevel(level))
	}
	args.RetrieveActions = xsdt.Boolean(retrieveActions)
	args.RetrieveResults = xsdt.Boolean(retrieveResults)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetReviewResultsForHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #4
0
파일: operations.go 프로젝트: jesand/crowds
// SearchQualificationTypes searches for Qualification types using the specified
// search query, and returns a list of Qualification types.
func (client amtClient) SearchQualificationTypes(
	query, sortProperty string, sortAscending bool,
	pageSize, pageNumber int, mustBeRequestable, mustBeOwnedByCaller bool) (
	amtgen.TxsdSearchQualificationTypesResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdSearchQualificationTypes
		args     amtgen.TSearchQualificationTypesRequest
		response amtgen.TxsdSearchQualificationTypesResponse
	)
	args.Query = xsdt.String(query)
	args.SortProperty = amtgen.TSearchQualificationTypesSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	args.MustBeRequestable = xsdt.Boolean(mustBeRequestable)
	args.MustBeOwnedByCaller = xsdt.Boolean(mustBeOwnedByCaller)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("SearchQualificationTypes", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #5
0
파일: operations.go 프로젝트: jesand/crowds
// GetAssignmentsForHIT retrieves completed assignments for a HIT.
func (client amtClient) GetAssignmentsForHIT(hitId string,
	assignmentStatuses []string, sortProperty string, sortAscending bool,
	pageSize, pageNumber int) (
	amtgen.TxsdGetAssignmentsForHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetAssignmentsForHIT
		args     amtgen.TGetAssignmentsForHITRequest
		response amtgen.TxsdGetAssignmentsForHITResponse
	)
	args.HITId = xsdt.String(hitId)
	for _, status := range assignmentStatuses {
		args.AssignmentStatuses = append(args.AssignmentStatuses,
			amtgen.TAssignmentStatus(status))
	}
	args.SortProperty = amtgen.TGetAssignmentsForHITSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetAssignmentsForHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #6
0
파일: operations.go 프로젝트: jesand/crowds
// SearchHITs returns all of a Requester's HITs, on behalf of the Requester.
func (client amtClient) SearchHITs(sortProperty string, sortAscending bool,
	pageSize, pageNumber int) (
	amtgen.TxsdSearchHITsResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdSearchHITs
		args     amtgen.TSearchHITsRequest
		response amtgen.TxsdSearchHITsResponse
	)
	args.SortProperty = amtgen.TSearchHITsSortProperty(sortProperty)
	if sortAscending {
		args.SortDirection = amtgen.TSortDirection("Ascending")
	} else {
		args.SortDirection = amtgen.TSortDirection("Descending")
	}
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("SearchHITs", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #7
0
파일: question.go 프로젝트: jesand/crowds
// Add numeric value constraints for a free text answer specification
func (question *QuestionForm) AddFreeTextAnswerNumericConstraints(min, max int) {
	answer := question.getCurrentAnswer()
	if answer.FreeTextAnswer == nil {
		answer.FreeTextAnswer = &questionform.TFreeTextAnswerType{}
	}
	if answer.FreeTextAnswer.Constraints == nil {
		answer.FreeTextAnswer.Constraints = &questionform.TxsdFreeTextAnswerTypeSequenceConstraints{}
	}
	if answer.FreeTextAnswer.Constraints.IsNumeric == nil {
		answer.FreeTextAnswer.Constraints.IsNumeric = &questionform.TxsdFreeTextAnswerTypeSequenceConstraintsSequenceIsNumeric{}
	}
	answer.FreeTextAnswer.Constraints.IsNumeric.MinValue = xsdt.Int(min)
	answer.FreeTextAnswer.Constraints.IsNumeric.MaxValue = xsdt.Int(max)
}
예제 #8
0
파일: operations.go 프로젝트: jesand/crowds
// CreateQualificationType creates a new Qualification type.
func (client amtClient) CreateQualificationType(name, description string,
	keywords []string, retryDelayInSeconds int,
	qualificationTypeStatus, test, answerKey string,
	testDurationInSeconds int, autoGranted bool,
	autoGrantedValue int) (amtgen.TxsdCreateQualificationTypeResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdCreateQualificationType
		args     amtgen.TCreateQualificationTypeRequest
		response amtgen.TxsdCreateQualificationTypeResponse
	)
	args.Name = xsdt.String(name)
	args.Description = xsdt.String(description)
	args.Keywords = xsdt.String(strings.Join(keywords, ","))
	args.RetryDelayInSeconds = xsdt.Long(retryDelayInSeconds)
	args.QualificationTypeStatus = amtgen.TQualificationTypeStatus(
		qualificationTypeStatus)
	args.Test = xsdt.String(test)
	args.AnswerKey = xsdt.String(answerKey)
	args.TestDurationInSeconds = xsdt.Long(testDurationInSeconds)
	args.AutoGranted = xsdt.Boolean(autoGranted)
	args.AutoGrantedValue = xsdt.Int(autoGrantedValue)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("CreateQualificationType", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #9
0
파일: operations.go 프로젝트: jesand/crowds
// CreateHITFromHITTypeId creates a new Human Intelligence Task (HIT) from a
// HITTypeId.
func (client amtClient) CreateHITFromHITTypeId(hitTypeId, question string,
	hitLayoutId string, hitLayoutParameters map[string]string,
	lifetimeInSeconds, maxAssignments int,
	assignmentReviewPolicy, hitReviewPolicy *amtgen.TReviewPolicy,
	requesterAnnotation, uniqueRequestToken string) (
	amtgen.TxsdCreateHITResponse, error) {

	// Prepare the request
	var (
		args amtgen.TCreateHITRequest
	)
	args.HITTypeId = xsdt.String(hitTypeId)
	args.Question = xsdt.String(question)
	args.HITLayoutId = xsdt.String(hitLayoutId)
	var hitLayoutParameterOrder []string
	for name, _ := range hitLayoutParameters {
		hitLayoutParameterOrder = append(hitLayoutParameterOrder, name)
	}
	sort.Strings(hitLayoutParameterOrder)
	for _, name := range hitLayoutParameterOrder {
		value := hitLayoutParameters[name]
		var param amtgen.THITLayoutParameter
		param.Name = xsdt.String(name)
		param.Value = xsdt.String(value)
		args.HITLayoutParameters = append(args.HITLayoutParameters, &param)
	}
	args.LifetimeInSeconds = xsdt.Long(lifetimeInSeconds)
	args.MaxAssignments = xsdt.Int(maxAssignments)
	args.AssignmentReviewPolicy = assignmentReviewPolicy
	args.HITReviewPolicy = hitReviewPolicy
	args.RequesterAnnotation = xsdt.String(requesterAnnotation)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	return client.CreateHITFromArgs(args)
}
예제 #10
0
파일: main.go 프로젝트: jesand/crowds
func getObjectFields(object interface{}, vals map[string]string) {
	v := reflect.Indirect(reflect.ValueOf(object))
	if !v.IsValid() {
		return
	}
	t := v.Type()
	switch t.Kind() {
	case reflect.Slice:
		for i := 0; i < v.Len(); i++ {
			getObjectFields(v.Index(i).Interface(), vals)
		}
	case reflect.Struct:
		for i := 0; i < t.NumField(); i++ {
			field := t.Field(i)
			switch field.Type.Kind() {
			case reflect.Struct, reflect.Ptr, reflect.Slice:
				getObjectFields(v.Field(i).Interface(), vals)
			default:
				if field.Type == reflect.TypeOf(xsdt.Int(0)) {
					vals[field.Name] = fmt.Sprintf("%d", v.Field(i).Interface())
				} else if field.Type == reflect.TypeOf(xsdt.Long(0)) {
					vals[field.Name] = fmt.Sprintf("%d", v.Field(i).Interface())
				} else {
					vals[field.Name] = v.Field(i).String()
				}
			}
		}
	}
}
예제 #11
0
파일: operations.go 프로젝트: jesand/crowds
// GetBlockedWorkers retrieves a list of Workers who are blocked from working
// on your HITs.
func (client amtClient) GetBlockedWorkers(pageSize, pageNumber int) (
	amtgen.TxsdGetBlockedWorkersResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetBlockedWorkers
		args     amtgen.TGetBlockedWorkersRequest
		response amtgen.TxsdGetBlockedWorkersResponse
	)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetBlockedWorkers", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #12
0
파일: operations.go 프로젝트: jesand/crowds
// GetHITsForQualificationType returns the HITs that use the given Qualification
// type for a Qualification requirement.
func (client amtClient) GetHITsForQualificationType(qualificationTypeId string,
	pageSize, pageNumber int) (
	amtgen.TxsdGetHITsForQualificationTypeResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetHITsForQualificationType
		args     amtgen.TGetHITsForQualificationTypeRequest
		response amtgen.TxsdGetHITsForQualificationTypeResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetHITsForQualificationType", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #13
0
파일: operations.go 프로젝트: jesand/crowds
// GetBonusPayments retrieves the amounts of bonuses you have paid to Workers
// for a given HIT or assignment.
func (client amtClient) GetBonusPayments(hitId, assignmentId string,
	pageSize, pageNumber int) (
	amtgen.TxsdGetBonusPaymentsResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetBonusPayments
		args     amtgen.TGetBonusPaymentsRequest
		response amtgen.TxsdGetBonusPaymentsResponse
	)
	args.HITId = xsdt.String(hitId)
	args.AssignmentId = xsdt.String(assignmentId)
	args.PageSize = xsdt.Int(pageSize)
	args.PageNumber = xsdt.Int(pageNumber)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetBonusPayments", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #14
0
파일: operations.go 프로젝트: jesand/crowds
// CreateHIT creates a new Human Intelligence Task (HIT) without a HITTypeId.
func (client amtClient) CreateHIT(title, description, question string,
	hitLayoutId string, hitLayoutParameters map[string]string,
	reward float32, assignmentDurationInSeconds,
	lifetimeInSeconds, maxAssignments, autoApprovalDelayInSeconds int,
	keywords []string,
	qualificationRequirements []*amtgen.TQualificationRequirement,
	assignmentReviewPolicy, hitReviewPolicy *amtgen.TReviewPolicy,
	requesterAnnotation, uniqueRequestToken string) (
	amtgen.TxsdCreateHITResponse, error) {

	// Prepare the request
	var (
		args amtgen.TCreateHITRequest
	)
	args.Title = xsdt.String(title)
	args.Description = xsdt.String(description)
	args.Question = xsdt.String(question)
	args.HITLayoutId = xsdt.String(hitLayoutId)
	var hitLayoutParameterOrder []string
	for name, _ := range hitLayoutParameters {
		hitLayoutParameterOrder = append(hitLayoutParameterOrder, name)
	}
	sort.Strings(hitLayoutParameterOrder)
	for _, name := range hitLayoutParameterOrder {
		value := hitLayoutParameters[name]
		var param amtgen.THITLayoutParameter
		param.Name = xsdt.String(name)
		param.Value = xsdt.String(value)
		args.HITLayoutParameters = append(args.HITLayoutParameters, &param)
	}
	args.Reward = &amtgen.TPrice{}
	args.Reward.Amount = xsdt.Decimal(fmt.Sprint(reward))
	args.Reward.CurrencyCode = CURRENCY_USD
	args.AssignmentDurationInSeconds = xsdt.Long(assignmentDurationInSeconds)
	args.LifetimeInSeconds = xsdt.Long(lifetimeInSeconds)
	args.MaxAssignments = xsdt.Int(maxAssignments)
	args.AutoApprovalDelayInSeconds = xsdt.Long(autoApprovalDelayInSeconds)
	args.Keywords = xsdt.String(strings.Join(keywords, ","))
	args.QualificationRequirements = qualificationRequirements
	args.AssignmentReviewPolicy = assignmentReviewPolicy
	args.HITReviewPolicy = hitReviewPolicy
	args.RequesterAnnotation = xsdt.String(requesterAnnotation)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	return client.CreateHITFromArgs(args)
}
예제 #15
0
파일: operations.go 프로젝트: jesand/crowds
// GrantQualification issues a payment of money from your account to a Worker.
func (client amtClient) GrantQualification(qualificationRequestId string,
	integerValue int) (
	amtgen.TxsdGrantQualificationResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGrantQualification
		args     amtgen.TGrantQualificationRequest
		response amtgen.TxsdGrantQualificationResponse
	)
	args.QualificationRequestId = xsdt.String(qualificationRequestId)
	args.IntegerValue = xsdt.Int(integerValue)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GrantQualification", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #16
0
파일: operations.go 프로젝트: jesand/crowds
// GetRequesterStatistic retrieves statistics about you (the Requester calling
// the operation).
func (client amtClient) GetRequesterStatistic(statistic, timePeriod string,
	count int) (amtgen.TxsdGetRequesterStatisticResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdGetRequesterStatistic
		args     amtgen.TGetRequesterStatisticRequest
		response amtgen.TxsdGetRequesterStatisticResponse
	)
	args.Statistic = amtgen.TRequesterStatistic(statistic)
	args.TimePeriod = amtgen.TimePeriod(timePeriod)
	args.Count = xsdt.Int(count)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("GetRequesterStatistic", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #17
0
파일: operations.go 프로젝트: jesand/crowds
// UpdateQualificationScore changes the value of a Qualification previously
// granted to a Worker.
func (client amtClient) UpdateQualificationScore(qualificationTypeId,
	subjectId string, integerValue int) (
	amtgen.TxsdUpdateQualificationScoreResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdUpdateQualificationScore
		args     amtgen.TUpdateQualificationScoreRequest
		response amtgen.TxsdUpdateQualificationScoreResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.SubjectId = xsdt.String(subjectId)
	args.IntegerValue = xsdt.Int(integerValue)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("UpdateQualificationScore", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #18
0
파일: operations.go 프로젝트: jesand/crowds
// AssignQualification gives a Worker a Qualification.
func (client amtClient) AssignQualification(qualificationTypeId,
	workerId string, integerValue int, sendNotification bool) (
	amtgen.TxsdAssignQualificationResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdAssignQualification
		args     amtgen.TAssignQualificationRequest
		response amtgen.TxsdAssignQualificationResponse
	)
	args.QualificationTypeId = xsdt.String(qualificationTypeId)
	args.WorkerId = xsdt.String(workerId)
	args.IntegerValue = xsdt.Int(integerValue)
	args.SendNotification = xsdt.Boolean(sendNotification)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("AssignQualification", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #19
0
파일: operations.go 프로젝트: jesand/crowds
// ExtendHIT increases the maximum number of assignments, or extends the
// expiration date, of an existing HIT.
func (client amtClient) ExtendHIT(hitId string,
	maxAssignmentsIncrement, expirationIncrementInSeconds int,
	uniqueRequestToken string) (
	amtgen.TxsdExtendHITResponse, error) {

	// Prepare the request
	var (
		request  amtgen.TxsdExtendHIT
		args     amtgen.TExtendHITRequest
		response amtgen.TxsdExtendHITResponse
	)
	args.HITId = xsdt.String(hitId)
	args.MaxAssignmentsIncrement = xsdt.Int(maxAssignmentsIncrement)
	args.ExpirationIncrementInSeconds = xsdt.Long(expirationIncrementInSeconds)
	args.UniqueRequestToken = xsdt.String(uniqueRequestToken)
	request.Requests = append(request.Requests, &args)

	// Send the request
	req, err := client.signRequest("ExtendHIT", &request)
	if err == nil {
		err = client.sendRequest(req, &response)
	}
	return response, err
}
예제 #20
0
func TestAnswerKey(t *testing.T) {
	Convey("Given XML for an AnswerKey", t, func() {
		keyxml := `<AnswerKey xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd">
  <Question>
    <QuestionIdentifier>nextmove</QuestionIdentifier>
    <AnswerOption>
      <SelectionIdentifier>D</SelectionIdentifier>
      <AnswerScore>5</AnswerScore>
    </AnswerOption>
  </Question>
  <Question>
    <QuestionIdentifier>favoritefruit</QuestionIdentifier>
    <AnswerOption>
      <SelectionIdentifier>apples</SelectionIdentifier>
      <AnswerScore>10</AnswerScore>
    </AnswerOption>
  </Question>
  <QualificationValueMapping>
    <PercentageMapping>
      <MaximumSummedScore>15</MaximumSummedScore>
    </PercentageMapping>
  </QualificationValueMapping>
</AnswerKey>`
		Convey("When I Unmarshal the XML", func() {
			var result AnswerKey
			err := xml.Unmarshal([]byte(keyxml), &result)
			So(err, ShouldBeNil)

			Convey("Then I get the expected AnswerKey", func() {
				expected := AnswerKey{}
				expected.XMLName.Space = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd"
				expected.XMLName.Local = "AnswerKey"
				expected.Questions = append(expected.Questions,
					&answerkey.TxsdAnswerKeySequenceQuestion{},
					&answerkey.TxsdAnswerKeySequenceQuestion{})

				expected.Questions[0].QuestionIdentifier = xsdt.String("nextmove")
				expected.Questions[0].AnswerOptions = append(expected.Questions[0].AnswerOptions, &answerkey.TxsdAnswerKeySequenceQuestionSequenceAnswerOption{})
				expected.Questions[0].AnswerOptions[0].SelectionIdentifiers = []xsdt.String{"D"}
				expected.Questions[0].AnswerOptions[0].AnswerScore = xsdt.Int(5)

				expected.Questions[1].QuestionIdentifier = xsdt.String("favoritefruit")
				expected.Questions[1].AnswerOptions = append(expected.Questions[1].AnswerOptions, &answerkey.TxsdAnswerKeySequenceQuestionSequenceAnswerOption{})
				expected.Questions[1].AnswerOptions[0].SelectionIdentifiers = []xsdt.String{"apples"}
				expected.Questions[1].AnswerOptions[0].AnswerScore = xsdt.Int(10)

				expected.QualificationValueMapping = &answerkey.TxsdAnswerKeySequenceQualificationValueMapping{}
				expected.QualificationValueMapping.PercentageMapping = &answerkey.TxsdAnswerKeySequenceQualificationValueMappingChoicePercentageMapping{}
				expected.QualificationValueMapping.PercentageMapping.MaximumSummedScore = xsdt.Int(15)

				So(result, ShouldResemble, expected)
			})

			Convey("When I Marshal the AnswerKey", func() {
				newxml, err := EncodeQuestion(result)

				Convey("Then I get the expected XML", func() {
					So(err, ShouldBeNil)
					expected := `<AnswerKey xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd">` +
						`<Question>` +
						`<QuestionIdentifier>nextmove</QuestionIdentifier>` +
						`<AnswerOption>` +
						`<SelectionIdentifier>D</SelectionIdentifier>` +
						`<AnswerScore>5</AnswerScore>` +
						`</AnswerOption>` +
						`<DefaultScore>0</DefaultScore>` +
						`</Question>` +
						`<Question>` +
						`<QuestionIdentifier>favoritefruit</QuestionIdentifier>` +
						`<AnswerOption>` +
						`<SelectionIdentifier>apples</SelectionIdentifier>` +
						`<AnswerScore>10</AnswerScore>` +
						`</AnswerOption>` +
						`<DefaultScore>0</DefaultScore>` +
						`</Question>` +
						`<QualificationValueMapping>` +
						`<PercentageMapping>` +
						`<MaximumSummedScore>15</MaximumSummedScore>` +
						`</PercentageMapping>` +
						`</QualificationValueMapping>` +
						`</AnswerKey>`
					So(string(newxml), ShouldEqual, expected)
				})
			})
		})
	})
}