예제 #1
0
파일: track_test.go 프로젝트: pjherring/ggc
func TestDeactivateActivate(t *T) {
	beforeTrackTest()

	now := time.Date(1986, 7, 2, 0, 0, 0, 0, time.UTC)

	err := table.DeactivateTrack(3, now)
	rdtest.Assert(t, err == nil, err)

	found, err := table.FindTrack(3)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, !found.Active(now))

	err = table.ActivateTrack(3, now)
	rdtest.Assert(t, err == nil, err)

	found, err = table.FindTrack(3)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, found.Active(now))
}
예제 #2
0
파일: track_test.go 프로젝트: pjherring/ggc
func TestFindTrack(t *T) {
	beforeTrackTest()

	track, err := table.FindTrack(1)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, len(track.QuestionIdOrder) == 3, len(track.QuestionIdOrder))
	rdtest.Assert(t, track.QuestionIdOrder[0] == 1, track)
	rdtest.Assert(t, track.QuestionIdOrder[1] == 2, track)
	rdtest.Assert(t, track.QuestionIdOrder[2] == 3, track)
}
예제 #3
0
파일: track.go 프로젝트: pjherring/ggc
func toggleTrackActivation(ctx *_Context) error {

	track, err := table.FindTrack(ctx.urlParams["track_id"].(int64))
	if err != nil {
		return err
	}

	now := time.Now()

	if track.Active(now) {
		err = table.DeactivateTrack(track.TrackId, now)
	} else {
		err = table.ActivateTrack(track.TrackId, now)
	}

	return err
}
예제 #4
0
파일: progress.go 프로젝트: pjherring/ggc
//advances the team to the next clue
func advanceProgress(c *record.Clue, t *record.Team) error {

	//mark progress as answered
	table.FinishProgressForClueTeam(time.Now(), c.ClueId, t.TeamId)

	//get next clue in track
	track, err := table.FindTrack(t.TrackId)
	if err != nil {
		return err
	}

	//get next clue id
	nextClueId, err := track.NextClue(c.ClueId)
	if err != nil {
		return err
	}

	//create new progress for the next clue id
	return table.StartProgress(nextClueId, t.TeamId)
}
예제 #5
0
파일: track.go 프로젝트: pjherring/ggc
//Start progress on a track for a team
func startTrackForTeam(team *record.Team) (*models.Clue, error) {

	track, err := table.FindTrack(team.TrackId)
	if err != nil {
		return nil, err
	}

	//find the clue
	clue, err := table.FindClue(track.QuestionIdOrder[0])
	if err != nil {
		return nil, err
	}

	_, err = table.CreateTeamProgress(team.TeamId, clue.ClueId)
	if err != nil {
		return nil, err
	}

	return models.ClueFromCurrentClue(clue), nil
}