public AsyncTask Start(Student student, Activity activity, bool resetActivityState = false)
        {
            return(activityService.LoadActivityState(student.Id, activity.Id, true)
                   .Then((prevResult, onCompleted, onError) =>
            {
                ActivityState activityState = prevResult.ResultAs <ActivityState>();
                if (resetActivityState || !activityState.CanResume)
                {
                    // Generate a new trace ID for restarts or new games that don't have saved state
                    activityState.TraceId = Guid.NewGuid().ToString();
                }

                DebugLog.Info("Start activity!");
//					startedEntry = TraceLog.Player(TraceLog.Action.Started, "Activity",
//					                               "Name", activity.Name,
//					                               "ActivityUri", activity.Uri,
//					                               "IsComplete", activityState.IsComplete,
//					                               "CanResume", activityState.CanResume,
//					                               "Restart", resetActivityState,
//					                               "StartDate", activityState.ModifiedDate.ToIso8601(),
//					                               "Username", student.Username,
//					                               "SubjectId", student.SubjectId,
//					                               "TraceId", activityState.TraceId);
//
//					if (activity.Uri.Contains("episode"))
//					{
//						LaunchEpisode(activityState, activity.Name, activity.Uri, resetActivityState);
//					}
//					else if (activity.Uri.Contains("assessment"))
//					{
//						LaunchAssessment(activityState, activity.Name, activity.Uri);
//					}
//					else if (activity.Uri.Contains("http"))
//					{
//						LaunchUrl(activityState, activity.Name, activity.Uri);
//					}
//					else
//					{
//						throw new Exception(String.Format("{0} has an unknown URI type: ", activity.Name, activity.Uri));
//					}

                onCompleted(viewModelFactory.Resolve <ActivityViewModel>(Resolve(activity.Uri), vm =>
                {
                    vm.Activity = activity;
                    vm.ActivityState = activityState;
                }));

//					promise.Resolve(viewModelFactory.Resolve<WebActivityViewModel>(web =>
//					{
//						web.Title = "Web Browser Launched";
//						web.Message = "Complete web viewer action for " + activity.Name;
//						web.URL = "http://www.google.com";
//					}));
            }));
        }
Exemplo n.º 2
0
 public void Transition(ViewModel from, Type toViewModelType)
 {
     Transition(from, viewModelFactory.Resolve(toViewModelType));
 }