00001
00002
00003
00004
00005
00006
00007
00008
00009 #import "RootViewController.h"
00010 #import "WIRemoting.h"
00011 #import "MoodleResultViewController.h"
00012 #import "GetCoursesViewController.h"
00013 #import "LoginViewController.h"
00014 #import "LogoutViewController.h"
00015
00016 @implementation RootViewController
00017
00018 @synthesize views;
00019
00020 - (void) awakeFromNib
00021 {
00022 MoodleResultViewController *controller;
00023
00024 views = [[NSMutableArray alloc] init];
00025
00026
00027
00028 controller = [[GetCoursesViewController alloc] initWithTitle:@"All Courses"
00029 andDescription:@"Get all courses from Moodle"];
00030 [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
00031 @"All Courses", @"title",
00032 @"Retrieve all courses from the connected Moodle system.", @"description",
00033 controller, @"controller",
00034 nil]];
00035 [controller release];
00036
00037
00038 GetCoursesViewController *gcvc = [[GetCoursesViewController alloc] initWithTitle:@"My Courses"
00039 andDescription:@"Get my courses from Moodle"];
00040 gcvc.mineOnly = YES;
00041 [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
00042 @"My Courses", @"title",
00043 @"Retrieve my courses.", @"description",
00044 gcvc, @"controller",
00045 nil]];
00046 [gcvc release];
00047
00048
00049 LoginViewController *lvc = [[LoginViewController alloc] initWithTitle:@"Log In as Admin"
00050 andDescription:@"Log In as the admin user"];
00051 lvc.username = @"admin";
00052 lvc.password = @"1234";
00053 [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
00054 @"Admin", @"title",
00055 @"Log In as Admin User", @"description",
00056 lvc, @"controller",
00057 nil]];
00058 [lvc release];
00059
00060
00061 lvc = [[LoginViewController alloc] initWithTitle:@"Log In as Teacher"
00062 andDescription:@"Log In as the teacher user"];
00063 lvc.username = @"teacher";
00064 lvc.password = @"teacher";
00065 [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
00066 @"Teacher", @"title",
00067 @"Log In as Teacher User", @"description",
00068 lvc, @"controller",
00069 nil]];
00070 [lvc release];
00071
00072
00073 controller = [[LogoutViewController alloc] initWithTitle:@"Log Out"
00074 andDescription:@"Log out from Moodle"];
00075 [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
00076 @"Log Out", @"title",
00077 @"Log Out the System", @"description",
00078 controller, @"controller",
00079 nil]];
00080 [controller release];
00081
00082
00083 UIBarButtonItem *barItem = [[UIBarButtonItem alloc] init];
00084 barItem.title = @"Back";
00085 self.navigationItem.backBarButtonItem = barItem;
00086 [barItem release];
00087
00088
00089 self.title = @"Example Functions";
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 - (void)didReceiveMemoryWarning {
00131
00132 [super didReceiveMemoryWarning];
00133
00134
00135 }
00136
00137 - (void)viewDidUnload {
00138
00139
00140 }
00141
00142
00143 #pragma mark Table view methods
00144
00145 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
00146 {
00147 return 1;
00148 }
00149
00150
00151
00152 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
00153 {
00154 return [views count];
00155 }
00156
00157
00158
00159 - (UITableViewCell *)tableView:(UITableView *)tableView
00160 cellForRowAtIndexPath:(NSIndexPath *)indexPath
00161 {
00162
00163 static NSString *CellIdentifier = @"Cell";
00164
00165 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
00166 if (cell == nil) {
00167 cell = [[[UITableViewCell alloc]
00168 initWithStyle:UITableViewCellStyleSubtitle
00169 reuseIdentifier:CellIdentifier]
00170 autorelease];
00171 }
00172
00173
00174 cell.selectionStyle = UITableViewCellSelectionStyleGray;
00175 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
00176 cell.textLabel.text = [[views objectAtIndex:indexPath.row] valueForKey:@"title"];
00177 cell.textLabel.font = [UIFont boldSystemFontOfSize:14.0];
00178 cell.detailTextLabel.text = [[views objectAtIndex:indexPath.row] valueForKey:@"description"];
00179 cell.detailTextLabel.font = [UIFont systemFontOfSize:11.0];
00180
00181 return cell;
00182 }
00183
00184
00185 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
00186
00187
00188
00189
00190
00191 MoodleResultViewController *controller = [[views objectAtIndex:indexPath.row]
00192 objectForKey:@"controller"];
00193 if (nil != controller) {
00194 [self.navigationController pushViewController:controller
00195 animated:YES];
00196 }
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 - (void)dealloc {
00239 [views release];
00240 [super dealloc];
00241 }
00242
00243
00244 @end
00245