appirio-tech / lc1-project

Core challenge engine for Serenity Project
MIT License
6 stars 8 forks source link

Start/End Times aren't being set properly #452

Closed bryceglass closed 9 years ago

bryceglass commented 9 years ago

I'm testing this on [dev-lc1 environment]](http://dev-lc1-challenge-app.herokuapp.com/) and I seem to be getting weird results w/the setting of times.

Example 1

Challenge 140 was supposed to have a Start time of 12/25 @ 0100 hours and end on 1/26 @ 1200 hours. Instead, the final record reflects:

regStartAt: "2014-12-11T21:52:12.472Z",
subEndAt: "2014-12-21T21:52:12.472Z",

Which is just kind of wildly off — makes me suspect that maybe the javascript date / time pickers are screwy, and perhaps not actually applying requested date-changes back to the angular model?

Example 2

Challenge 141 worked as promised, however. In the GUI, I requested a start-time of 1/15/2015 @ 17:00 hours, and an end time of 11/15/2015 @ 17:00 hours. That's exactly what I got.

regStartAt: "2015-01-15T17:00:00.000Z",
subEndAt: "2015-11-15T17:00:00.000Z",

Example 3

Challenge 142 also did not work as expect. In this case, I set the challenge to start on 12/20 and end on 12/21, and instead I got a start time of today. (The end time does look accurate.):

regStartAt: "2014-12-11T22:06:40.798Z",
subEndAt: "2014-12-21T22:06:40.798Z",
kbowerma commented 9 years ago

Thanks Bryce, this is valuable info. So I understand the problem with example 1: If you go with the default times the UI resets the MM:SS but that user never opens that dropdown element so those '00:00' values never get sent to the controller. If you just open the drop down time picker and un-focus it works.

kbowerma commented 9 years ago

This screenshot shows the problem. When we create the new challenge we set the default time start and end to now but on the ui these values never get invoked.

screen shot 2014-12-12 at 10 43 34 am

kbowerma commented 9 years ago

ok it looks like we have isolated this to not saving before you launch, Bryce and I confirmed this with a test which is also the case for example 3.

There is also an issue that you can't save or launch a challenge with the subEndAt with the same day as today but that seems like an outlier.

kbowerma commented 9 years ago

The reason this was happening is that the launch was updating the challenge scope however due to some logic the time picker was not in the challenge scope and was handled in the save function:

line 39 of the create-challenge-contoller.js

    /*save current challenge and related info*/
    $scope.saveChallenge = function() {
      //reset the flag that shows the growl notification
      $scope.showSuccessGrowl = false;
      if ($scope.timeLine.complete) {
        $scope.challenge.regStartAt = concatenateDateTime($scope.timeLine.stdt, $scope.timeLine.timeSelectedStart);
        $scope.challenge.subEndAt = concatenateDateTime($scope.timeLine.enddt, $scope.timeLine.timeSelectedEnd);
      };

So I added those two lines that set the regStartAt and subEndAt also on the launch method at line 114

 /*launch a challenge*/
    $scope.launch = function() {
      // since the timelines are not in the challenge scope we need to set them here:
      $scope.challenge.regStartAt = concatenateDateTime($scope.timeLine.stdt, $scope.timeLine.timeSelectedStart);
      $scope.challenge.subEndAt = concatenateDateTime($scope.timeLine.enddt, $scope.timeLine.timeSelectedEnd);
    // check to see if the condtions are true to launch
     if ( $scope.publicBrowsing.complete && $scope.fileBrowsing.complete && $scope.requirements.complete && $scope.timeLine.complete && $scope.prizes.complete && challenge.title != 'Untitled Challenge'  ) {
      ChallengeService.launch($scope.challenge).then(function(actionResponse) {
        console.log('launched challenge: ', $scope.challenge.id);
        window.location.href = '/manage/#/challenges?launchSuccess='+$scope.challenge.id;
      });
    } else { console.log ('attmpted to launch a non ready challenge '); }
   };