private int GetTaskStatistic(SubjectRetriever retriever, SubjectTheme theme, Task task) { var taskData = retriever.GetTaskDBData(task, theme); int answered = taskData.RightAttempts; int overall = taskData.OverallAttempts; if (overall == 0) { return(0); } return((int)(((float)answered) / overall * 100)); }
protected void LoadStatistics() { var retriever = new SubjectRetriever(subjectType, this); var statistic = retriever.GetStatistic(); int overall = statistic.X; int right = statistic.Y; FindViewById <TextView> (Resource.Id.OverallTextView).Text = "Всего попыток: " + overall; FindViewById <TextView> (Resource.Id.RightTextView).Text = "Успешных попыток: " + right; int percent = overall == 0 ? 0 : (int)(((float)right / (float)overall) * 100); FindViewById <TextView> (Resource.Id.ProcentTextView).Text = "Процент правильных ответов: " + percent; }
protected void LoadTasksButtons() { var subjectRetriever = new SubjectRetriever(subjectType, this.ApplicationContext); var tasks = subjectRetriever.GetTasksInfo(theme.Num); int ai = 1; int bi = 1; int i = 0; foreach (var task in tasks) { Button taskButton = new Button(this); taskButton.Id = i; // var parameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent, 1); // parameters.SetMargins (16, 8, 16, 8); // taskButton.LayoutParameters = parameters; int level = 0; taskButton.Click += TaskButtonClick; if (task == typeof(ATask)) { level = GetTaskStatistic(subjectRetriever, theme, subjectRetriever.GetATask(theme, ai)); taskButton.Text = "A" + ai + "(" + level + "%)"; ai++; } else { level = GetTaskStatistic(subjectRetriever, theme, subjectRetriever.GetBTask(theme, bi)); taskButton.Text = "B" + bi + "(" + level + "%)"; bi++; } if (level <= 30) { taskButton.SetTextColor(Android.Graphics.Color.Red); } else { if (level <= 80) { taskButton.SetTextColor(Android.Graphics.Color.Goldenrod); } else { taskButton.SetTextColor(Android.Graphics.Color.Green); } } taskButtonsLayout.AddView(taskButton); i++; } subjectRetriever.DB.Close(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.ChooseTrainingLayout); Enum.TryParse <SubjectsEnumeration> (Intent.GetStringExtra("TestType"), out subjectType); subjectStringName = SubjectHelper.GetSubjectName(subjectType, this); FindViewById <TextView> (Resource.Id.SubjectNameTextView).Text = subjectStringName; themeButtonsLayout = FindViewById <LinearLayout> (Resource.Id.ThemesLinearLayout); subjectRetriever = new SubjectRetriever(subjectType, this.ApplicationContext); LoadThemesButtons(); }
protected void SetParameters() { Enum.TryParse <SubjectsEnumeration> (Intent.GetStringExtra("TestType"), out subjectType); themeNum = Intent.GetStringExtra("ThemeNum"); currentTaskToShow = Intent.GetIntExtra("TaskNum", 0); subjectStringName = SubjectHelper.GetSubjectName(subjectType, this); subjectRetriever = new SubjectRetriever(subjectType, ApplicationContext); theme = subjectRetriever.GetThemeByNum(themeNum); tasks = subjectRetriever.GetTasks(themeNum); taskImages = new Drawable[tasks.Count]; isAnswered = new List <bool> (tasks.Count); isRightAnswered = new List <bool> (tasks.Count); isShowAnswer = new List <bool> (tasks.Count); for (int i = 0; i < tasks.Count; i++) { isAnswered.Add(false); isRightAnswered.Add(false); isShowAnswer.Add(false); } }