public SurveyScriptFragmentViewModel(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file, bool isLoading = false, string loading = "") { Loading = loading; IsLoading = isLoading; ServerUrl = serverUrl; SurveyId = surveyDetails.SurveyId; SurveyName = $"{surveyDetails.SurveyName} Script Fragments"; if (file != null) { Task.Run(async() => { await UploadScriptFragment(token, file); }); } else { var fragUrl = $"{ServerUrl}/v1/Surveys/{SurveyId}/ScriptFragments"; Task.Run(async() => ScriptFragments = await GetFragmentsAsync(fragUrl, token)); } }
public ActionResult SurveyDetail(int id) { SurveyData surveyData = new SurveyData(); SurveyDetails details = surveyData.Details.Single(survey => survey.ID == id); return(View(details)); }
public void SaveSurveyResponse(SurveyDetails survey) { var respondent = _mapper.Map <Respondent>(survey); _dbContext.Respondent.Add(respondent); _dbContext.SaveChanges(); }
public SamplingPointsViewModel(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file, bool isLoading = false, string loading = "") { ServerUrl = serverUrl; SurveyId = surveyDetails.SurveyId; Loading = loading; IsLoading = isLoading; SurveyName = $"{surveyDetails.SurveyName} Sampling Points"; if (file != null) { Task.Run(async() => { await UploadSamplingPoints(token, file); }); } else { var samplingUrl = $"{serverUrl}/v1/Surveys/{SurveyId}/SamplingPoints"; Task.Run(async() => SamplingPoints = await GetSamplingPointsAsync(samplingUrl, token)); } }
public InterviewersViewModel(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file, bool isLoading = false, string loading = "") { ServerUrl = serverUrl; SurveyId = surveyDetails.SurveyId; Loading = loading; IsLoading = isLoading; SurveyName = $"{surveyDetails.SurveyName} Interviewers"; if (file != null) { Task.Run(async() => { await UploadInterviewers(token, file); }); } else { var url = $"{ServerUrl}/v1/Interviewers"; Task.Run(async() => { Interviewers = await GetInterviewersAsync(url, token); }); } }
public SurveyPreviewPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); SurveyName = surveyDetails.SurveyName; SurveyTestUri = SurveyTestUrl(token, serverUrl, surveyDetails.SurveyId); BindingContext = this; }
public SamplingPointsPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; SurveyDetails = surveyDetails; SampleData = new SamplingPointsViewModel(Token, ServerUrl, SurveyDetails, null); BindingContext = SampleData; }
public InterviewersPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; SurveyDetails = surveyDetails; Interviewers = new InterviewersViewModel(Token, ServerUrl, SurveyDetails, null); BindingContext = Interviewers; }
public SurveyFragmentsPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; SurveyDetails = surveyDetails; ScriptFragments = new SurveyScriptFragmentViewModel(token, serverUrl, surveyDetails, null); BindingContext = ScriptFragments; }
private void Percentages(SurveyDetails surveyDetails) { try { var total = (SurveyCounts.SuccessfulCount + SurveyCounts.DroppedOutCount + SurveyCounts.ScreenedOutCount + SurveyCounts.RejectedCount); if (total == null) { total = 0; } var successPerc = total != 0 ? Math.Round((((decimal)SurveyCounts.SuccessfulCount / (decimal)total) * 100), 1) : 0; var dropPerc = total != 0 ? Math.Round((((decimal)SurveyCounts.DroppedOutCount / (decimal)total) * 100), 1) : 0; var screenPerc = total != 0 ? Math.Round((((decimal)SurveyCounts.ScreenedOutCount / (decimal)total) * 100), 1) : 0; var rejectPerc = total != 0 ? Math.Round((((decimal)SurveyCounts.RejectedCount / (decimal)total) * 100), 1) : 0; var totalPerc = total != 0 ? Math.Round((successPerc + dropPerc + screenPerc + rejectPerc), 1) : 0; SurveyInfo = new ObservableCollection <SurveyInfo> { new SurveyInfo { SurveyName = surveyDetails.SurveyName, Success = $"{SurveyCounts.SuccessfulCount} total successful interviews", ActiveLive = $"{SurveyCounts.ActiveLiveCount} active live interviews", ActiveTest = $"{SurveyCounts.ActiveTestCount} active test interviews", Total = (SurveyCounts.SuccessfulCount + SurveyCounts.DroppedOutCount + SurveyCounts.ScreenedOutCount + SurveyCounts.RejectedCount).ToString(), PercSuccess = $"{successPerc}%", PercDrop = $"{dropPerc}%", PercScreen = $"{screenPerc}%", PercReject = $"{rejectPerc}%", PercTotal = $"{totalPerc}%", SurveyCounts = SurveyCounts } }; if (SurveyCounts.QuotaCounts != null) { SurveyInfo[0].HasNoQuota = false; SurveyInfo[0].TargetVisible = true; var targetPercentage = Math.Round((((decimal)SurveyCounts.SuccessfulCount / (decimal)SurveyCounts.QuotaCounts.Target) * 100), 1); SurveyInfo[0].PercOfTarget = $"{targetPercentage}% of Target"; SurveyInfo[0].Target = SurveyCounts.QuotaCounts.Target.ToString(); SetUpQuotas(); } } catch (Exception) { throw; } }
public SurveyStatisticsPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; SurveyId = surveyDetails.SurveyId; SurveyDetails = surveyDetails; Task.Run(async() => { await GetCounts(); }); }
public SurveyStatisticsPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; SurveyId = surveyDetails.SurveyId; SurveyDetails = surveyDetails; GetCounts(); Percentages(); BindingContext = this; }
public ScriptFragmentPage(AccessToken token, string serverUrl, string scriptFragmentName, SurveyDetails surveyDetails) { InitializeComponent(); Token = token; ServerUrl = serverUrl; FragmentNme = scriptFragmentName; SurveyId = surveyDetails.SurveyId; SurveyDetails = surveyDetails; ScriptFragment = new ScriptFragmentUpdateViewModel(token, serverUrl, scriptFragmentName, surveyDetails.SurveyId, surveyDetails.SurveyName); BindingContext = ScriptFragment; }
public ActionResult UploadData() { if (Request.Files.Count > 0) { try { SurveyData surveyData = new SurveyData(); SurveyDetails surveyDetails = new SurveyDetails(); HttpPostedFileBase file = Request.Files[0]; string fname; if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } var fname2 = Path.Combine(Server.MapPath("~/Uploads/"), fname); file.SaveAs(fname2); surveyDetails.Name = Request.Form.Get("Name"); surveyDetails.Age = Convert.ToInt16(Request.Form.Get("Age")); surveyDetails.Gender = Request.Form.Get("Gender"); surveyDetails.Email = Request.Form.Get("Email"); surveyDetails.City = Request.Form.Get("City"); surveyDetails.Resume = fname; surveyDetails.Education = Request.Form.Get("Education"); string id = surveyData.AddSurvey(surveyDetails); return(Json(id)); } catch (Exception ex) { return(Json("Error occurred. Error details: " + ex.Message)); } } else { return(Json("Data not entered.")); } }
private async Task RetrieveCounts(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { var url = $"{serverUrl}/v1/Surveys/{surveyDetails.SurveyId}/Counts"; var request = new RestApi().Get(url, token); using (WebResponse response = await request.GetResponseAsync()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { var content = reader.ReadToEnd(); SurveyCounts = JsonConvert.DeserializeObject <SurveyCountsModel>(content); } } Percentages(surveyDetails); }
public SamplingPointsImageViewModel(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file, bool isLoading = false, string loading = "") { Loading = loading; IsLoading = isLoading; if (file != null) { Task.Run(async() => { await UploadSamplingPointsImage(token, serverUrl, surveyDetails, file); }); } }
public async Task <string> Download(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file) { var officesUrl = $"{serverUrl}/v1/Offices"; var offices = await GetFieldWorkOfficeIdAsync(officesUrl, token); var samplingUrl = $"{serverUrl}/v1/Surveys/{surveyDetails.SurveyId}/SamplingPoints"; var samplingPoints = await Retrieve(samplingUrl, token); var sampleCsv = new StringBuilder(); var headers = $"SamplingPointId,Name,Description,Instruction,FieldworkOffice,GroupId,Preference,Stratum{Environment.NewLine}"; sampleCsv.Append(headers); foreach (var samplingPoint in samplingPoints) { var office = offices.FirstOrDefault(x => x.OfficeId == samplingPoint.FieldworkOfficeId)?.OfficeName; var kind = SamplingPointKind.Regular.ToString(); switch (samplingPoint.Kind) { case SamplingPointKind.Spare: kind = SamplingPointKind.Spare.ToString(); break; case SamplingPointKind.SpareActive: kind = SamplingPointKind.SpareActive.ToString(); break; case SamplingPointKind.Replaced: kind = SamplingPointKind.Replaced.ToString(); break; } var row = $"{samplingPoint.SamplingPointId},{samplingPoint.Name},{samplingPoint.Description},{samplingPoint.Instruction},{office},{samplingPoint.GroupId},{kind},{samplingPoint.Stratum}{Environment.NewLine}"; sampleCsv.Append(row); } return(sampleCsv.ToString()); }
public StreetLightingDomainDalMapperTests() { var config = new MapperConfiguration(mc => mc.AddProfile(new DalMapper())); _mapper = config.CreateMapper(); _surveyDetails = new SurveyDetails { Name = "nameStub", EmailAddress = "*****@*****.**", Address = new SurveyAddress { AddressLine1 = "nameStub", AddressLine2 = null, City = "cityStub", PostCode = "postCodeStub" }, Satisfied = true, Brightness = 1 }; }
public void OnValidRespondentAnswersSurveyDetailsCreatedOkay() { var expected = new SurveyDetails { Name = "nameStub", EmailAddress = "*****@*****.**", Address = new SurveyAddress { AddressLine1 = "nameStub", AddressLine2 = null, City = "cityStub", PostCode = "postCodeStub" }, Satisfied = true, Brightness = 1 }; var result = _mapper.Map <SurveyDetails>(_respondentAnswers); result.Should().BeEquivalentTo(expected); }
public IHttpActionResult Post([FromBody] SurveyDetails studentEmails) { try { // save to DB var surveyDetailsRepository = new SurveyDetailsRepository(); surveyDetailsRepository.SendToStudents(studentEmails); // send emails to respondents Utilities.Utilities.SendRespondentsEmail(studentEmails.Respondents); // update survey status var surveyRepository = new SurveyRepository(); surveyRepository.UpdateSurveyStatus(studentEmails.SurveyId, 0); return(Created <SurveyDetails>(Request.RequestUri, studentEmails)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <string> Download(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file) { var url = $"{serverUrl}/v1/Interviewers"; var interviewers = await Retrieve(url, token); var interviewerCsv = new StringBuilder(); var headers = $"InterviewerId,UserName,FirstName,LastName,EmailAddress,TelephoneNumber,LastPasswordChangeTime,ClientInterviewerId,SuccessfulCount,UnsuccessfulCount,DroppedOutCount,RejectedCount,LastSyncDate,IsFullSynced,IsLastSyncSuccessful,IsSupervisor{Environment.NewLine}"; interviewerCsv.Append(headers); foreach (var interviewer in interviewers) { var row = $"{interviewer.InterviewerId},{interviewer.UserName},{interviewer.FirstName},{interviewer.LastName},{interviewer.EmailAddress},{interviewer.TelephoneNumber},{interviewer.LastPasswordChangeTime},{interviewer.ClientInterviewerId},{interviewer.SuccessfulCount},{interviewer.UnsuccessfulCount},{interviewer.DroppedOutCount},{interviewer.RejectedCount},{interviewer.LastSyncDate},{interviewer.IsFullSynced},{interviewer.IsLastSyncSuccessful},{interviewer.IsSupervisor}{Environment.NewLine}"; interviewerCsv.Append(row); } return(interviewerCsv.ToString()); }
public StreetLightingDataServiceNegativeTests() { _surveyDetails = new SurveyDetails { Name = "nameStub", EmailAddress = "*****@*****.**", Address = new SurveyAddress { AddressLine1 = "addressLine1Stub", AddressLine2 = null, City = "cityStub", PostCode = "postCodeStub" }, Satisfied = true, Brightness = 1 }; _mockRespondentDBSet = new Mock <DbSet <Respondent> >(); _mockStreetLightingDBContext = new Mock <StreetLightingDBContext>(); _mockStreetLightingDBContext.Setup(m => m.Respondent).Throws(new Exception("MockedException")); _mockMapper = new Mock <IMapper>(); _mockMapper.Setup(m => m.Map <Respondent>(_surveyDetails)).Returns(It.IsAny <Respondent>()); _streetLightingDataService = new StreetLightingDataService(_mockStreetLightingDBContext.Object, _mockMapper.Object); }
public static SekerPerut ToDTO(SurveyDetails s) { return(new SekerPerut { SurveyDetailsId = s.SurveyDetailsId, QuestionSubject = s.QuestionSubject, SurveyHedearId = s.SurveyHedearId, ExtrnalNum1 = s.ExtrnalNum1, ExtrnalNum2 = s.ExtrnalNum2, ExtrnalNum3 = s.ExtrnalNum3, ExtrnalNum4 = s.ExtrnalNum4, ExtrnalNum5 = s.ExtrnalNum5, ExtrnalChar1 = s.ExtrnalChar1, ExtrnalChar2 = s.ExtrnalChar2, ExtrnalChar3 = s.ExtrnalChar3, ExtrnalChar4 = s.ExtrnalChar4, ExtrnalChar5 = s.ExtrnalChar5, ExtrnalCount1 = s.ExtrnalCount1, ExtrnalCount2 = s.ExtrnalCount2, ExtrnalCount3 = s.ExtrnalCount3, ExtrnalCount4 = s.ExtrnalCount4, ExtrnalCount5 = s.ExtrnalCount5, }); }
public static async Task <SurveyDetails> GetSurveyDetailsExpanded(long surveyId) { SurveyDetails response = await SurveyMonkeyRequest.GetRequest <SurveyDetails>(string.Format("/surveys/{0}/details", surveyId)); return(response); }
private async Task UploadSamplingPointsImage(AccessToken token, string serverUrl, SurveyDetails surveyDetails, FileData file) { using (var memoryStream = new MemoryStream(file.DataArray)) { using (var reader = new StreamReader(memoryStream)) { var csvFile = await reader.ReadToEndAsync(); var columnsLine = new StringReader(csvFile).ReadLine(); var delim = new[] { ',', ';' }; var columns = columnsLine.Split(delim); var csvData = csvFile.Split('\n').Skip(1); foreach (var data in csvData) { try { if (string.IsNullOrEmpty(data)) { continue; } var columnData = data.Split(delim); var samplingPointId = columns.IndexOf("SamplingPointId") != -1 ? columnData[columns.IndexOf("SamplingPointId")] : ""; var imagePath = columns.IndexOf("ImagePath") != -1 ? columnData[columns.IndexOf("ImagePath")] : ""; if (string.IsNullOrEmpty(samplingPointId) || string.IsNullOrEmpty(imagePath)) { continue; } var fileName = Path.GetFileName(imagePath); File.SetAttributes(imagePath, FileAttributes.Normal); var contentBytes = File.ReadAllBytes(imagePath); var url = $"{serverUrl}/v1/Surveys/{surveyDetails.SurveyId}/SamplingPoint/{samplingPointId}/Image/{fileName}"; await PostSamplingPointImage(url, token, contentBytes); } catch (System.Exception e) { IsLoading = false; throw; } } IsLoading = false; } } }
public ActionsPage(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { InitializeComponent(); ActionsTitle = $"{surveyDetails.SurveyName} Actions"; Actions = new ObservableCollection <ActionsToTake> { //new ActionsToTake //{ // Action = "Addresses", // Icon = "map.png", // ServerUrl = serverUrl, // SurveyDetails = surveyDetails, // AccessToken = token //}, new ActionsToTake { Action = "Interviewers", Icon = "meeting.png", ServerUrl = serverUrl, SurveyDetails = surveyDetails, AccessToken = token }, new ActionsToTake { Action = "Sampling Points", Icon = "network.png", ServerUrl = serverUrl, SurveyDetails = surveyDetails, AccessToken = token }, //new ActionsToTake //{ // Action = "Survey Data Overview", // Icon = "analytics.png", // ServerUrl = serverUrl, // SurveyDetails = surveyDetails, // AccessToken = token //}, //new ActionsToTake //{ // Action = "Survey Settings", // Icon = "survey.png", // ServerUrl = serverUrl, // SurveyDetails = surveyDetails, // AccessToken = token //}, new ActionsToTake { Action = "Survey Statistics", Icon = "barchart.png", ServerUrl = serverUrl, SurveyDetails = surveyDetails, AccessToken = token }, new ActionsToTake { Action = "Survey Fragments", Icon = "puzzle.png", ServerUrl = serverUrl, SurveyDetails = surveyDetails, AccessToken = token }, }; //if (surveyDetails.SurveyType != SurveyType.EuroBarometer.ToString()) //{ // var index = Actions.Single(c => c.Action == "Addresses"); // Actions.Remove(index); //} if (surveyDetails.SurveyType == SurveyType.OnlineBasic.ToString()) { var index = Actions.Single(c => c.Action == "Interviewers"); Actions.Remove(index); //index = Actions.Single(c => c.Action == "Survey Data Overview"); //Actions.Remove(index); } if (surveyDetails.SurveyType != SurveyType.Advanced.ToString() && surveyDetails.SurveyType != SurveyType.EuroBarometer.ToString()) { var index = Actions.Single(c => c.Action == "Sampling Points"); Actions.Remove(index); } BindingContext = this; }
public async Task TestGetSurveys() { SurveyMonkey.AuthToken = ConfigurationManager.AppSettings["SurveyMonkeyAuthToken"]; SurveyMonkey.ApiKey = ConfigurationManager.AppSettings["SurveyMonkeyApiKey"]; List <Survey> surveys = await Surveys.GetSurveys(); Assert.IsNotNull(surveys); SurveyDetails details = await Surveys.GetSurveyDetails(surveys[0].id); Assert.IsNotNull(details); SurveyDetails detailsExpanded = await Surveys.GetSurveyDetailsExpanded(surveys[0].id); Assert.IsNotNull(detailsExpanded.pages); List <Page> pages = await Surveys.GetSurveyPages(surveys[0].id); Assert.AreNotEqual(0, pages.Count); Page page = await Surveys.GetSurveyPageDetails(surveys[0].id, pages[0].id); Assert.IsNotNull(page); List <Question> questions = await Surveys.GetSurveyPageQuestions(surveys[0].id, pages[0].id); Assert.AreNotEqual(0, questions.Count); Question questionDetails = await Surveys.GetSurveyPageQuestionDetails(surveys[0].id, pages[0].id, questions[0].id); Assert.IsNotNull(questionDetails); List <Collector> collectors = await Surveys.GetSurveyCollectors(surveys[0].id); Assert.AreNotEqual(0, collectors.Count); CreateMessage createMsg = new CreateMessage() { body_html = "[SurveyLink], [FooterLink] and [OptOutLink]", subject = "new survey", type = "invite", body_text = "[SurveyLink], [FooterLink] and [OptOutLink]", is_branding_enabled = false }; Message message = await Collectors.CreateCollectorMessage(collectors[0].id, createMsg); Assert.IsNotNull(message); List <Message> messages = await Collectors.GetCollectorMessages(collectors[0].id); Assert.AreNotEqual(0, messages.Count); var recipientData = new CreateRecipient() { email = "*****@*****.**", first_name = "non", last_name = "existent" }; var collectorRecipient = await Collectors.CreateCollectorMessageRecipient(collectors[0].id, message.id, recipientData); Assert.IsNotNull(collectorRecipient); Assert.AreNotEqual(0, collectorRecipient.id); var sentMsg = await Collectors.SendMessageToRecipients(collectors[0].id, message.id); Assert.IsNotNull(sentMsg); Assert.AreNotEqual(false, sentMsg.is_scheduled); var recipient = await Collectors.GetCollectorRecipient(collectors[0].id, collectorRecipient.id); Assert.IsNotNull(recipient); Assert.AreNotEqual(0, recipient.id); }
public SurveyStatisticsViewModel(AccessToken token, string serverUrl, SurveyDetails surveyDetails) { Task.Run(async() => await RetrieveCounts(token, serverUrl, surveyDetails)); }