Exemplo n.º 1
0
    public void BuildCharts(string criteria, string math)
    {
        CSS Director = new CSS();


        //get event info
        Event theEvent = new Event();

        theEvent.EventID    = ((Event)Session["Event"]).EventID;
        theEvent            = Director.GetEvent(theEvent);
        theEvent.Evaluators = Director.GetEvaluatorsForEvent(theEvent.EventID);
        DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM");


        if (criteria != "All Evaluations")
        {
            theEvent.Evaluators.RemoveAll(o => o.Criteria != criteria);
        }

        foreach (Evaluator ev in theEvent.Evaluators)
        {
            ev.EvaluatorEvaluations.RemoveAll(x => x.Rating == 999);
        }

        //if event has evaluator data, construct the chart
        if (theEvent.Evaluators.Count > 0)
        {
            Highcharts chart = Director.CreateChart(theEvent);
            ltrChart.Text = chart.ToHtmlString();

            //generate chart with mean/mode/median
            Highcharts mathChart = Director.MakeMathChart(theEvent, math);
            meanChart.Text = mathChart.ToHtmlString();
        }
    }
Exemplo n.º 2
0
    //build table with evaluator info
    public void BuildTable()
    {
        DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM");

        //lbUpdateTime.Text = DateTime.Now.ToLocalTime().ToString();
        CSS RequestDirector = new CSS();

        //get event evaluation data
        List <Evaluation> currentEvals = new List <Evaluation>();
        Event             activeEvent  = new Event();

        activeEvent.EventID = ((Event)Session["Event"]).EventID;

        activeEvent            = RequestDirector.GetEvent(activeEvent);
        activeEvent.Evaluators = RequestDirector.GetEvaluatorsForEvent(activeEvent.EventID);

        //get most recent evaluation from each evaluator
        currentEvals = RequestDirector.GetCurrentEventData(activeEvent);

        Button btn;

        foreach (Evaluator ev in activeEvent.Evaluators)
        {
            TableRow  tRow  = new TableRow();
            TableCell tCell = new TableCell();

            //name
            if (ev.Name.ToString().Equals("Default"))
            {
                tCell.Text = "ID:" + ev.EvaluatorID.ToString();
            }
            else
            {
                tCell.Text = ev.Name;
            }

            tRow.Cells.Add(tCell);

            //what criteria user is rating on
            tCell      = new TableCell();
            tCell.Text = ev.Criteria;
            tRow.Cells.Add(tCell);

            if (ev.EvaluatorEvaluations.Last().Rating == 999)
            {
                //first Rating time
                tCell      = new TableCell();
                tCell.Text = "--:--:--";
                tRow.Cells.Add(tCell);

                //last rating time
                tCell      = new TableCell();
                tCell.Text = "--:--:--";
                tRow.Cells.Add(tCell);

                //last rating
                tCell      = new TableCell();
                tCell.Text = "-";
                tRow.Cells.Add(tCell);
            }
            else
            {
                ev.EvaluatorEvaluations.RemoveAll(x => x.Rating == 999);

                //first Rating time
                tCell      = new TableCell();
                tCell.Text = (ev.EvaluatorEvaluations.First().TimeStamp.ToLocalTime() - activeEvent.EventStart).ToString();
                tRow.Cells.Add(tCell);

                //last rating time
                tCell      = new TableCell();
                tCell.Text = (ev.EvaluatorEvaluations.Last().TimeStamp.ToLocalTime() - activeEvent.EventStart).ToString();
                tRow.Cells.Add(tCell);

                //last rating
                tCell      = new TableCell();
                tCell.Text = ev.EvaluatorEvaluations.Last().Rating.ToString();
                tRow.Cells.Add(tCell);
            }



            //delete button
            tCell             = new TableCell();
            btn               = new Button();
            btn.Text          = "Remove";
            btn.ID            = String.Format("Remove{0}", ev.EvaluatorID.ToString());
            btn.Click        += new EventHandler(RemoveEvaluator_Click);
            btn.OnClientClick = "return confirm('Are you sure you want to remove this evaluator?');";
            btn.CssClass      = "btn btn-light";
            tCell.Controls.Add(btn);
            tRow.Cells.Add(tCell);

            Table1.Rows.Add(tRow);
        }

        //if event is over calculate the average rating for the whole event.
        //else calculate the current average if the event is currently active
        if (activeEvent.EventEnd != defaultTime)
        {
            if (currentEvals.Count != 0)
            {
                double            totalAverage;
                List <Evaluation> allEvaluations = new List <Evaluation>();

                //change the label
                RatingTitle.Text = "Total Average Rating:";

                lbTotalEvalsNum.Text = activeEvent.Evaluators.Count.ToString();

                //create list of all evals for event then average
                foreach (Evaluator ev in activeEvent.Evaluators)
                {
                    ev.EvaluatorEvaluations.RemoveAll(x => x.Rating == 999);
                    allEvaluations.AddRange(ev.EvaluatorEvaluations);
                }

                if (allEvaluations.Count > 0)
                {
                    totalAverage   = allEvaluations.Average(o => o.Rating);
                    Ratinglbl.Text = totalAverage.ToString("#.##");
                }
            }
        }
        else
        {
            if (currentEvals.Count > 0)
            {
                lbTotalEvalsNum.Text = activeEvent.Evaluators.Count.ToString();
                currentEvals.RemoveAll(x => x.Rating == 999);

                if (currentEvals.Count > 0)
                {
                    Ratinglbl.Text = currentEvals.Average(x => (double)x.Rating).ToString("#.##");
                }
            }
        }
    }
Exemplo n.º 3
0
    //export event data to .csv for external use
    protected void Export_Click(object sender, EventArgs e)
    {
        //Initialize instances of all neccessary classes and director
        CSS         Director    = new CSS();
        Event       theEvent    = new Event();
        Facilitator Facilitator = new Facilitator();
        //List<Evaluation> Evaluations = new List<Evaluation>();
        StringBuilder csvcontent = new StringBuilder();
        DateTime      addEval;
        DateTime      defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM");

        //Set the Event.ID of our empty event, and use said event to pull event information from DB
        theEvent.EventID    = ((Event)Session["Event"]).EventID;
        theEvent            = Director.GetEvent(theEvent);
        theEvent.Evaluators = Director.GetEvaluatorsForEvent(theEvent.EventID);

        foreach (Evaluator eva in theEvent.Evaluators)
        {
            eva.EvaluatorEvaluations.RemoveAll(x => x.Rating == 999);
        }

        List <Question> questions = new List <Question>();

        questions = Director.GetQuestions(theEvent.EventID);

        List <Question> answers = new List <Question>();
        Question        que;

        foreach (Question q in questions)
        {
            foreach (Evaluator ev in theEvent.Evaluators)
            {
                que = new Question();

                que.QID         = q.QID;
                que.EvaluatorID = ev.EvaluatorID;
                que             = Director.GetResponse(que);

                ev.Responses.Add(que);
            }
        }

        Facilitator = Director.GetFacilitator(1);

        //Creates the first section of data in the CSV, regarding the Facilitators info. Data is formatted in two lines, the first line being the data description, the second line being the respective data.
        csvcontent.AppendLine("Event Creator,Organization");
        csvcontent.AppendLine(Facilitator.FirstName + " " + Facilitator.LastName + "," + Facilitator.Organization);
        csvcontent.AppendLine("\n");

        //Creates the second line of data in the CSV, regarding the Events info. Formatted as above.
        csvcontent.AppendLine("Event,Performer,Location,Date of Event,Start Time,End Time");
        csvcontent.AppendLine(theEvent.Description + "," + theEvent.Performer + "," + theEvent.Location + "," + theEvent.Date.ToShortDateString() + "," + theEvent.EventStart.ToLongTimeString() + "," + theEvent.EventEnd.ToLongTimeString());
        csvcontent.AppendLine("\n");

        //get start and end times for table.  Convert to local time
        DateTime eventStart        = theEvent.EventStart.ToLocalTime();
        DateTime eventEnd          = theEvent.EventEnd.ToLocalTime();
        double   secsBetweenPoints = 0.5; //iterate every 0.5 second

        //display timestamp for every 0.5 s
        List <string> timestamps = new List <string>();

        for (DateTime i = eventStart; i <= eventEnd; i = i.AddSeconds(secsBetweenPoints))
        {
            timestamps.Add(String.Format("{0}", (i - eventStart).ToString(@"hh\:mm\:ss\:fff")));
        }
        string tsLine = "ID #,Name,";

        foreach (Question q in questions)
        {
            tsLine += q.QuestionText + ",";
        }

        tsLine += "Voting Criteria,Time of First Rating, Time of Last Rating, TimeStamp (HH:MM:SS.mmm):,";

        for (int k = 0; k < timestamps.Count; k++)
        {
            if (k == timestamps.Count - 1)
            {
                tsLine += timestamps[k];
            }
            else
            {
                tsLine += (timestamps[k] + ",");
            }
        }

        csvcontent.AppendLine(tsLine);


        //Add all evaluator evaluations
        Evaluator  _evaluator  = new Evaluator();
        Evaluation _evaluation = new Evaluation();
        int        evalCount   = 0;
        string     insert;

        foreach (Evaluator eval in theEvent.Evaluators)
        {
            insert = eval.EvaluatorID.ToString() + "," + eval.Name + ",";

            //add q answers
            foreach (Question r in eval.Responses)
            {
                insert += r.ResponseText + ",";
            }

            insert += eval.Criteria + ",";

            if (eval.EvaluatorEvaluations.Count > 0)
            {
                insert += (eval.EvaluatorEvaluations.First().TimeStamp.ToLocalTime() - theEvent.EventStart).ToString() + ",";
                insert += (eval.EvaluatorEvaluations.Last().TimeStamp.ToLocalTime() - theEvent.EventStart).ToString() + ",";
            }
            else
            {
                insert += "--:--:--,--:--:--,,";
            }



            for (DateTime i = eventStart; i <= eventEnd; i = i.AddSeconds(secsBetweenPoints))
            {
                if (eval.EvaluatorEvaluations.Count > 0)
                {
                    if (eval.EvaluatorEvaluations[0].TimeStamp.ToLocalTime() <= i)
                    {
                        evalCount = 0;
                        while (evalCount < eval.EvaluatorEvaluations.Count - 1)
                        {
                            //get the last evaluation before time i
                            if (eval.EvaluatorEvaluations[evalCount].TimeStamp.ToLocalTime() <= i)
                            {
                                //ev = e.EvaluatorEvaluations[evalCount];
                                evalCount++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        //get time from the start of the event
                        //double timestamp = (i - eventStart).TotalMilliseconds;

                        insert += eval.EvaluatorEvaluations[evalCount].Rating.ToString() + " ,";
                    }
                    else
                    {
                        insert += " ,";
                    }
                }
            }
            csvcontent.AppendLine(insert);
        }

        //Clear the response and re package it as a downloadable CSV file
        Response.Clear();
        Response.ContentType = "text/csv";
        Response.AddHeader("Content-Disposition", "attachment;filename=EventData.csv");
        Response.Write(csvcontent.ToString());
        Response.End();
    }