From c619f3fe64a0965910122c5ddaaa39107361a42f Mon Sep 17 00:00:00 2001 From: chrqls Date: Thu, 2 Jan 2014 19:14:21 -0800 Subject: [PATCH 1/2] Changing version in the 'About' section --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 682a88f..5864273 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -66,7 +66,7 @@ TOP SCORER About - SMILE Teacher App 0.9.8b1: The activity management application for teachers, + SMILE Teacher App 0.9.9b1: The activity management application for teachers, called the SMILE Teacher, serves to manage and save data from the activity via an ad-hoc network. It is a Graphic User Interface-based application that can be From d15f01394f98cccdc98f530245d95489e1f8d533 Mon Sep 17 00:00:00 2001 From: chrqls Date: Sat, 4 Jan 2014 06:57:46 -0800 Subject: [PATCH 2/2] [#14] Teacher can change the limit of percent to succeed (default value is 70% of good answers to succeed) --- res/layout-large-land/students.xml | 21 ++++++------ res/values/percent_correct_array.xml | 12 +++++++ res/values/strings.xml | 1 + .../smile/bu/SmilePlugServerManager.java | 12 ++----- .../org/smilec/smile/ui/GeneralActivity.java | 33 +++++++++++++++++-- .../smile/ui/fragment/StudentsFragment.java | 25 ++++++++------ 6 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 res/values/percent_correct_array.xml diff --git a/res/layout-large-land/students.xml b/res/layout-large-land/students.xml index e194d00..ab0848e 100644 --- a/res/layout-large-land/students.xml +++ b/res/layout-large-land/students.xml @@ -261,16 +261,6 @@ - - - - - - - - - - + + + + + 50 + 60 + 70 + 75 + 80 + 90 + 100 + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 5864273..58b57c8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -52,6 +52,7 @@ Highest\nRating completed correct + Percent limit to succeed Send a report Please leave your report: diff --git a/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java b/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java index 690cad3..0f860f4 100644 --- a/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java +++ b/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java @@ -213,16 +213,10 @@ public List getIQSets(String ip, Context context) throws NetworkErrorExce try { String s = IOUtil.loadContent(is, "UTF-8"); iqsets = IQSetJSONParser.parseListOfIQSet(new JSONObject(s)); - - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - IOUtil.silentClose(is); } + catch (JSONException e) { e.printStackTrace(); } + catch (IOException e) { e.printStackTrace(); } + finally { IOUtil.silentClose(is); } return iqsets; } diff --git a/src/main/java/org/smilec/smile/ui/GeneralActivity.java b/src/main/java/org/smilec/smile/ui/GeneralActivity.java index 6140501..d8572c1 100644 --- a/src/main/java/org/smilec/smile/ui/GeneralActivity.java +++ b/src/main/java/org/smilec/smile/ui/GeneralActivity.java @@ -66,9 +66,13 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.RelativeLayout; +import android.widget.Spinner; import android.widget.TableLayout; import android.widget.TextView; @@ -127,7 +131,7 @@ public void onCreate(Bundle savedInstanceState) { tvTime = (TextView) findViewById(R.id.tv_time); tvRemaining = (TextView) findViewById(R.id.tv_remaining_time); tvStatus = (TextView) findViewById(R.id.tv_status); - + if (savedInstanceState != null) { Board tmp = (Board) savedInstanceState.getSerializable(PARAM_BOARD); @@ -245,7 +249,7 @@ private void updateCurrentFragment(Board newBoard) { @Override protected void onResume() { super.onResume(); - + btSolve.setOnClickListener(new SolveButtonListener()); btResults.setOnClickListener(new ResultsButtonListener()); @@ -611,6 +615,30 @@ private void showResults() { .findViewById(R.id.rl_top_scorers); rlTopScorersContainer.setVisibility(View.VISIBLE); + + Spinner spLimitToSucceed = (Spinner) findViewById(R.id.sp_limit_to_succeed); + ArrayAdapter adapterLimit = ArrayAdapter.createFromResource(this, R.array.percent_correct, android.R.layout.simple_spinner_item); + adapterLimit.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spLimitToSucceed.setAdapter(adapterLimit); + + // Initialize the spinner to 70% + spLimitToSucceed.setSelection(2); + + // If the teacher clicks on the spinner to set a different limit to succeed + spLimitToSucceed.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { + + String[] bases = getResources().getStringArray(R.array.percent_correct); + ((StudentsFragment)activeFragment).updatePercentCorrect(Integer.parseInt(bases[position])); + } + + @Override + public void onNothingSelected(AdapterView arg0) { } + }); + + // If the teacher clicks on "Send results" button Button btSendResults = (Button) GeneralActivity.this.findViewById(R.id.bt_send_results); btSendResults.setVisibility(View.VISIBLE); btSendResults.setOnClickListener(new OnClickListener() { @@ -619,7 +647,6 @@ private void showResults() { public void onClick(View v) { SendEmailResultsUtil.send(board, ip, GeneralActivity.this); } - }); } diff --git a/src/main/java/org/smilec/smile/ui/fragment/StudentsFragment.java b/src/main/java/org/smilec/smile/ui/fragment/StudentsFragment.java index cfa77fa..b4ce88d 100644 --- a/src/main/java/org/smilec/smile/ui/fragment/StudentsFragment.java +++ b/src/main/java/org/smilec/smile/ui/fragment/StudentsFragment.java @@ -54,6 +54,7 @@ import android.widget.ListView; import android.widget.RatingBar; import android.widget.RelativeLayout; +import android.widget.Spinner; import android.widget.TextView; public class StudentsFragment extends AbstractFragment { @@ -66,6 +67,8 @@ public class StudentsFragment extends AbstractFragment { private Results results; private boolean run; + + private int limitToSucceed; private String ip; @@ -106,9 +109,7 @@ public void onResume() { super.onResume(); ip = getActivity().getIntent().getStringExtra(GeneralActivity.PARAM_IP); - results = (Results) getActivity().getIntent().getSerializableExtra( - GeneralActivity.PARAM_RESULTS); - + results = (Results) getActivity().getIntent().getSerializableExtra(GeneralActivity.PARAM_RESULTS); adapter = new StudentListAdapter(getActivity(), students); ListView lvListStudents = (ListView) getActivity().findViewById(R.id.lv_students); @@ -190,7 +191,7 @@ public void run() { tvAnswers.setText(getString(R.string.answers) + ": " + countAnswers); if (results != null) { - setTopScorersArea(results, board); + setTopScorersArea(results); } } @@ -296,7 +297,7 @@ private String getPercentCorrect() { } } // if the student has 70+% of correct answers, we count it - nbStudentOver70 += nbQuestionsCorrect*100/questions.size() >= 70 ? 1:0; + nbStudentOver70 += nbQuestionsCorrect*100/questions.size() >= this.limitToSucceed ? 1:0; } float percent = !students.isEmpty()? (float) (nbStudentOver70/students.size())*100 : 0; @@ -306,8 +307,16 @@ private String getPercentCorrect() { " ("+ String.format("%.0f", nbStudentOver70)+"/"+students.size() +")"; return s; } + + public void updatePercentCorrect(int limitToSucceed) { + + this.limitToSucceed = limitToSucceed; + TextView tvPercentCorrect = (TextView) getActivity().findViewById(R.id.tv_percent_correct); + tvPercentCorrect.setText(this.getPercentCorrect()); + tvPercentCorrect.setVisibility(View.VISIBLE); + } - private void setTopScorersArea(Results results, Board board) { + private void setTopScorersArea(Results results) { try { TextView tvTopScorersTop = (TextView) getActivity().findViewById( R.id.tv_top_scorers_top); @@ -327,10 +336,6 @@ private void setTopScorersArea(Results results, Board board) { //TextView tvTopScorersRating = (TextView) getActivity().findViewById(R.id.tv_top_scorers_rating); //tvTopScorersRating.setText(getString(R.string.rating) + ": " + results.getWinnerRating()); - // Seems useless >> issues 14 - //final RatingBar rbRatingBar = (RatingBar) getActivity().findViewById(R.id.rb_ratingbar); - //rbRatingBar.setRating(results.getWinnerRating()); - } catch (JSONException e) { new SendEmailAsyncTask(e.getMessage(),JSONException.class.getName(),StudentsFragment.class.getName()).execute(); Log.e("StudentsFragment", "Error: " + e);