예제 #1
0
        public void callback()
        {
            string strongPath   = Android.OS.Environment.ExternalStorageDirectory.Path;
            string filePath     = System.IO.Path.Combine(strongPath, "Mahendra");
            var    path         = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Mahendra");
            var    jsontextfile = path + "/ST_" + langcode + "_" + TestId;

            if (Directory.Exists(jsontextfile))

            {
                string[] filelist   = Directory.GetDirectories(jsontextfile);
                var      filename   = filelist[0];
                var      myfilename = filename + "/testquestionsbylangCode.txt";
                myfilename1 = filename;
                //File file = new File(jsontextfile);
                //var filelist = file.ListFiles();
                //var filename="";
                //foreach (var innerfile in filelist)
                //{
                //     filename = innerfile.Name;
                //}
                //myfilename1 = jsontextfile + "/" + filename;
                //var myfilename = jsontextfile + "/" + filename+ "/testquestionsbylangCode.txt";
                try
                {
                    var filecontent = System.IO.File.ReadAllText(myfilename);
                    var jsonobject  = JsonObject.Parse(filecontent);
                    if (jsonobject is JsonArray)
                    {
                        var jarray = jsonobject as JsonArray;
                        foreach (var item in jarray)
                        {
                            questionmodel qmodal = new questionmodel
                            {
                                Correctans            = (item as JsonObject)["CorrectAns"].ToString().Trim('\"'),
                                Correctmarks          = (item as JsonObject)["CorrectMarks"],
                                Datatype              = (item as JsonObject)["DataType"],
                                Id                    = (item as JsonObject)["ID"],
                                Optionnumbering       = (item as JsonObject)["OptionNumbering"].ToString().Trim('\"'),
                                Optnseqno             = (item as JsonObject)["OptnSeqno"],
                                Passageid             = (item as JsonObject)["PassageID"],
                                Qdata                 = (item as JsonObject)["Qdata"].ToString().Trim('\"'),
                                Qid                   = (item as JsonObject)["QID"],
                                Qtype                 = (item as JsonObject)["QType"],
                                Seqno                 = (item as JsonObject)["Seqno"],
                                Subjectid             = (item as JsonObject)["SubjectID"],
                                Testqid               = (item as JsonObject)["TestQID"],
                                selectedoption        = 0,
                                colorcode             = Resource.Drawable.whitecircle1,
                                textcolor             = Resource.Color.black,
                                rightorwrongColorCode = Resource.Drawable.whitecircle1,
                                rightorwrongTextColor = Resource.Color.black,
                                markforreview         = 0
                            };
                            qestionlist.Add(qmodal);
                        }
                    }
                    groupedCustomerList = qestionlist.GroupBy(u => u.Qid).Select(grp => grp.ToList()).ToList();
                    txtTotalCount.Text  = groupedCustomerList.Count() + "";

                    //=================================fetch passage ==============================================//
                    var myfilenamepassage = filename + "/PassagebyTest.txt";
                    try
                    {
                        var filecontentpassage = System.IO.File.ReadAllText(myfilenamepassage);
                        var jsonobjectpassage  = JsonObject.Parse(filecontentpassage);
                        if (jsonobjectpassage is JsonArray)
                        {
                            var jarray = jsonobjectpassage as JsonArray;
                            foreach (var item in jarray)
                            {
                                questionpassagemodel questionpassagemodelobj = new questionpassagemodel
                                {
                                    id      = (item as JsonObject)["ID"],
                                    Passage = (item as JsonObject)["Passage"]
                                };

                                passagelist.Add(questionpassagemodelobj);
                            }
                        }
                        //=============================================================================================//



                        //var res = groupedCustomerList.ToDictionary(x => x);
                        //System.Console.WriteLine("deopanshu-->" + JsonConvert.SerializeObject(groupedCustomerList));

                        // DoTestAdapter dotestadapter = new DoTestAdapter(SupportFragmentManager, groupedCustomerList, passagelist,myfilename1);

                        // viewpager.Adapter = dotestadapter;
                    }
                    catch (Exception e)
                    {
                    }

                    //=============================================Fetch Instruction=======================================//
                    var    myfilenameinstruction = filename + "/InstructionbyTest.txt";
                    string instructiontitle      = "";
                    string instruction           = "";
                    try
                    {
                        var filecontentindtruction = System.IO.File.ReadAllText(myfilenameinstruction);
                        var jsonobjectindtruction  = JsonObject.Parse(filecontentindtruction);
                        if (jsonobjectindtruction is JsonArray)
                        {
                            var jarray = jsonobjectindtruction as JsonArray;
                            foreach (var item in jarray)
                            {
                                instructiontitle = (item as JsonObject)["Title"];
                                instruction      = (item as JsonObject)["Instruction"];
                            }
                        }
                        timeduration = timeduration * 60 * 1000;
                        bool timebondflag;
                        if (TestInstruction.testInfoList[0].Duration > 0)
                        {
                            timebondflag = true;
                        }
                        else
                        {
                            timebondflag = false;
                        }
                        DosTestFragment dotestfragment = DosTestFragment.NewInstance(JsonConvert.SerializeObject(groupedCustomerList), JsonConvert.SerializeObject(passagelist), myfilename1, position, TestId, negativemarks, timeduration, instructiontitle, instruction, true, 0, true, items, startingquestionposition, subjecttotalquestion, langcode, 0, testtype, timebondflag);
                        SupportFragmentManager.BeginTransaction().Replace(Resource.Id.testpaperviewpager, dotestfragment).Commit();
                    }
                    catch (Exception e)
                    {
                    }
                    //======================================================================================================//
                }
                catch (Exception)
                {
                }
            }

            else
            {
                System.Console.WriteLine("File NOt Exist");
            }
        }
예제 #2
0
 public override Fragment GetItem(int position)
 {
     return(DosTestFragment.NewInstance(JsonConvert.SerializeObject(questionlist[position]), JsonConvert.SerializeObject(passagelist), path, position + 1, 0, 0, 0, "", "", false, 0, false, "", "", "", "", 0, "", false));
 }