Files
survey-beta/survey-beta/Controllers/AnalyticsController.cs
majed adel 5c735417f2 feat: Allow full survey editing & restrict editing to unpublished surveys
- Enabled full survey editing functionality
- Restricted survey editing to unpublished surveys only
- Added various improvements and optimizations
2025-02-14 05:10:28 -08:00

30 lines
1012 B
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace survey_beta.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AnalyticsController : ControllerBase
{
private readonly AnalyticsServices _analyticsServices;
public AnalyticsController(AnalyticsServices analyticsServices)
{
_analyticsServices = analyticsServices;
}
[HttpGet("survey/{surveyId}")]
public IActionResult GetSurveyAnalytics(string surveyId)
{
var analytics = _analyticsServices.GetAggregatedSurveyResponses(surveyId);
if (analytics == null) return NotFound("Survey analytics not found.");
return Ok(analytics);
}
[HttpGet("export/{surveyId}")]
public async Task<IActionResult> ExportSurveyData(string surveyId)
{
return await _analyticsServices.ExportResponsesToCsv(surveyId);
}
}
}