Skip to content

Commit

Permalink
Added dialog for reviewing incorrect characters
Browse files Browse the repository at this point in the history
  • Loading branch information
doubt72 committed Mar 20, 2013
1 parent 448b3c3 commit 4e78882
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
30 changes: 22 additions & 8 deletions Sokudoku/Interface/DrillWindow.m
Expand Up @@ -57,6 +57,16 @@ - (void)finish {
[alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(sessionFinished:returnCode:contextInfo:) contextInfo:nil];
}

- (void)finishAnswer:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
if (timeLeft < 0) {
[self finish];
} else {
[testString setTextColor:[NSColor blackColor]];
[answerField setStringValue:@""];
[self nextQuestion];
}
}

- (IBAction)answer:(id)sender {
// Elapsed time is negative (time relative to "now")
NSTimeInterval elapsed = [time timeIntervalSinceNow];
Expand All @@ -66,17 +76,21 @@ - (IBAction)answer:(id)sender {
if ([package test:literals:answer:-elapsed]) {
correctAnswers++;
status = [NSString stringWithFormat:@"Answer %@ correct (in %.2f seconds)",
answer, -elapsed];
answer, -elapsed];
[statusField setStringValue:status];
[self finishAnswer:nil returnCode:0 contextInfo:nil];
} else {
incorrectAnswers++;
status = [NSString stringWithFormat:@"Answer %@ incorrect", answer];
}
[statusField setStringValue:status];
if (timeLeft < 0) {
[self finish];
} else {
[answerField setStringValue:@""];
[self nextQuestion];
[statusField setStringValue:status];
[testString setTextColor:[NSColor redColor]];
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Continue"];
[alert setMessageText:@"Incorrect Answer"];
[alert setInformativeText:[NSString stringWithFormat:@"Answer %@ incorrect",
answer]];
[alert setAlertStyle:NSInformationalAlertStyle];
[alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(finishAnswer:returnCode:contextInfo:) contextInfo:nil];
}
}

Expand Down
4 changes: 1 addition & 3 deletions Sokudoku/Interface/GraphWindow.m
Expand Up @@ -38,7 +38,6 @@ - (IBAction)changeDataSet:(id)sender {
}

- (IBAction)changeGraphType:(id)sender {
NSLog(@"graphType: %ld", [graphType indexOfSelectedItem]);
[graphView setGraphType:(int)[graphType indexOfSelectedItem]];
[parent setGraphType:(int)[graphType indexOfSelectedItem]];
[graphView setNeedsDisplay:YES];
Expand All @@ -47,8 +46,7 @@ - (IBAction)changeGraphType:(id)sender {
- (IBAction)changeTimeFrame:(id)sender {
// Day ranges (1 week, 1 month, 3 months, 6 months, 1 year, 2 years)
int array[] = {7, 30, 90, 180, 365, 730};

NSLog(@"timeFrame: %ld", [timeFrame indexOfSelectedItem]);

[graphView setTimeFrame:array[[timeFrame indexOfSelectedItem]]];
[parent setGraphTime:(int)[timeFrame indexOfSelectedItem]];
[graphView setNeedsDisplay:YES];
Expand Down
2 changes: 0 additions & 2 deletions Sokudoku/Interface/MainWindow.m
Expand Up @@ -42,7 +42,6 @@ @implementation MainWindow
@synthesize characterOrder, graphTime, graphType;

- (void)settingsFromSaveDict:(NSDictionary *)dict {
NSLog(@"dict: %@", dict);
characterOrder = [[dict objectForKey:@"characterOrder"] boolValue];
graphTime = [[dict objectForKey:@"graphTime"] intValue];
graphType = [[dict objectForKey:@"graphType"] intValue];
Expand All @@ -66,7 +65,6 @@ - (NSDictionary *)saveDictFromSettings {
forKey:@"sessionLength"];
[rc setObject:[NSNumber numberWithInt:(int)[weightHistory state]]
forKey:@"weightHistory"];
NSLog(@"rc: %@", rc);
return [NSDictionary dictionaryWithDictionary:rc];
}

Expand Down

0 comments on commit 4e78882

Please sign in to comment.