Exemplo n.º 1
0
        public async Task<ActionResult> CreateTurkSurvey([FromBody] CreateTurkSurveyRequest req)
        {
            Project proj = _context.Project.Where(p => p.Uid == req.projectUid).FirstOrDefault<Project>();
            Concept cpt = _context.Concept.Where(c => c.Uid == req.ConceptUid).FirstOrDefault<Concept>();


            Survey survey = new Survey();
            survey.Uid = req.uniqueId;
            survey.ProjectId = proj.Id;
            survey.Prototypes = req.Prototypes;
            if (cpt != null)
            survey.ConceptId = cpt.Id;
            survey.SurveyName = req.SurveyName;
            survey.Notes = req.Notes;
            survey.Qualifications = req.Qualifications;
            survey.DateCreated = DateTime.Now;
            survey.Questions = req.Questions;
            survey.Status = req.Status;



            TurkSurvey turkSurvey = new TurkSurvey(_appSettings);

            var result = await turkSurvey.createHit(survey, req.reward, req.maxSurveys);
            survey.HitId = result.HIT.HITTypeId;
            _context.Survey.Add(survey);
            _context.SaveChanges();

            var response = "https://workersandbox.mturk.com/projects/" + result.HIT.HITTypeId + "/tasks";
            return Ok(response);
        }
Exemplo n.º 2
0
 public async Task<ActionResult> GetTurkBalance(CreateTurkSurveyRequest req)
 {
     TurkSurvey turkSurvey = new TurkSurvey(_appSettings);
      var balance = await turkSurvey.getBalance();
      return Ok(balance);
 }