Esempio n. 1
0
        //found the index of user in last session
        private void goToCurrent()
        {
            if (_eyeMusicModel.StepSession == null)
            {
                string map = Server.MapPath("~");
                StepFiles = new StepByStepClass(map, _eyeMusicModel.len);
                _eyeMusicModel.StepSession = StepFiles;
            }

            _eyeMusicModel.StepSession.changeLan(_eyeMusicModel.len);

            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    IQueryable <stepByStep_user> sdd = entities.stepByStep_user.Where(usr => usr.user_ID == _eyeMusicModel.userDAL.user_ID);

                    if (sdd.Any())
                    {
                        DateTime?TimeStep  = sdd.Max(usr => usr.Time);
                        int?     indexStep = sdd.Where(usr => usr.Time == (DateTime)TimeStep).FirstOrDefault().id;

                        if (indexStep != null && indexStep != THE_MAX)
                        {
                            _eyeMusicModel.StepSession.setindex((int)indexStep + 1);
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }
        }
Esempio n. 2
0
        public ActionResult feedbackfinish(ShelonFinish sf,
                                           string HardLesson, string EasyLesson, string ColorEasy, string ColorHard, string eyes, string musical, string playMusic)
        {
            sessionOrNot();

            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                ShelonFinish found = entities.ShelonFinishes.Where(usr => usr.user_id == _eyeMusicModel.userDAL.user_ID).SingleOrDefault();

                if (found == null)
                {
                    // User found in the database
                    if (eyes == " " || musical == " " || ColorEasy == " " || ColorHard == " " || sf.faces == null || sf.fun == null || sf.hard == null)
                    {
                        ModelState.AddModelError("", "please fill all ");
                        return(View("feedbackfinish"));
                    }
                    else
                    {
                        sf.user_id    = _eyeMusicModel.userDAL.user_ID;
                        sf.HardColor  = Int32.Parse(ColorHard);
                        sf.clearColor = Int32.Parse(ColorEasy);

                        if (eyes == "true")
                        {
                            sf.closeEyes = true;
                        }
                        else
                        {
                            sf.closeEyes = false;
                        }

                        if (musical == "true")
                        {
                            sf.musical = true;
                        }
                        else
                        {
                            sf.musical = false;
                        }

                        if (playMusic == "true")
                        {
                            sf.playMusic = true;
                        }
                        else
                        {
                            sf.playMusic = false;
                        }

                        sf.hard = HardLesson;
                        sf.easy = EasyLesson;
                        entities.ShelonFinishes.Add(sf);
                        entities.SaveChanges();
                    }
                }
            }
            return(View("menustepExp", _eyeMusicModel));
        }
Esempio n. 3
0
 public void addToDBStepByStep(object obj)
 {
     using (amedilab_dataEntities entities = new amedilab_dataEntities())
     {
         try
         {
             entities.stepByStep_user.Add((stepByStep_user)obj);
             entities.SaveChanges();
         }
         catch (Exception e)
         {
         }
     }
 }
Esempio n. 4
0
 public void addtoDBFunny(object obj)
 {
     using (amedilab_dataEntities entities = new amedilab_dataEntities())
     {
         try
         {
             entities.StepByStepHappies.Add((StepByStepHappy)obj);
             entities.SaveChanges();
         }
         catch (Exception e)
         {
         }
     }
 }
Esempio n. 5
0
        //check if aleardy have question for this exam
        //also create a new question
        private bool checkeifHaveQuestion()
        {
            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    _eyeMusicModel.num_question++;// = (int)maxQuestion + 1;

                    var exams_res = (from examq in entities.exam_QUESTION
                                     where examq.level == _eyeMusicModel.select_level &&
                                     examq.stage == _eyeMusicModel.select_stage &&
                                     examq.num_exam == _eyeMusicModel.exam_number &&
                                     examq.num_question == _eyeMusicModel.num_question
                                     select new full_question
                    {
                        answer_A = examq.A,
                        answer_B = examq.B,
                        answer_C = examq.C,
                        answer_D = examq.D,
                        realpath = examq.pic_path,
                        the_true = examq.the_true
                    }).SingleOrDefault();

                    if (exams_res == null)
                    {
                        return(false);
                    }
                    else
                    {
                        _eyeMusicModel.answers[0]  = vh.heb.returnStr(exams_res.answer_A);
                        _eyeMusicModel.answers[1]  = vh.heb.returnStr(exams_res.answer_B);
                        _eyeMusicModel.answers[2]  = vh.heb.returnStr(exams_res.answer_C);
                        _eyeMusicModel.answers[3]  = vh.heb.returnStr(exams_res.answer_D);
                        _eyeMusicModel.thePrevTrue = _eyeMusicModel.theTrue;
                        _eyeMusicModel.theTrue     = exams_res.the_true;
                        _eyeMusicModel.realpath    = exams_res.realpath;

                        return(true);
                    }
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        ///  Add new exam on specipic level and stage
        /// </summary>
        /// <param name="obj"></param>
        private void addExamToDBUser(object obj)
        {
            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    exam addThis = obj as exam;

                    //found level by level_ID
                    addThis.level1 = (from levels in entities.levels
                                      where levels.level1 == _eyeMusicModel.select_level
                                      select levels).SingleOrDefault();

                    //found stage by stage_ID
                    addThis.stage1 = (from stages in entities.stages
                                      where stages.stage1 == _eyeMusicModel.select_stage
                                      select stages).SingleOrDefault();

                    entities.exams.Add((DAL.exam)obj);
                    entities.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// add specipic question of question
        /// </summary>
        /// <param name="obj"></param>
        private void AddToDBExamQ(object obj)
        {
            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    pic_paths     the_path;
                    level         lvl;
                    stage         stg;
                    desacriptaion des;
                    desacriptaion des1;
                    desacriptaion des2;
                    desacriptaion des3;

                    int?maxlvl;
                    int?maxstg;
                    int?maxdes;
                    int?maxpath;

                    //check if this image already in DB
                    var picPathVar = entities.pic_paths.SingleOrDefault(usr => usr.pic_path == ((exam_q_levels)obj).pic_paths.pic_path);

                    if (picPathVar != null)
                    {
                        the_path = picPathVar;
                    }
                    else
                    {
                        //create row with image path
                        maxpath = entities.pic_paths.Max(usr => (int?)usr.id);

                        if (maxpath == null)
                        {
                            maxpath = 0;
                        }

                        the_path          = new pic_paths();
                        the_path.id       = (int)++maxpath;
                        the_path.pic_path = ((exam_q_levels)obj).pic_paths.pic_path;
                        //entities.levels.Add(lvl);
                        //entities.SaveChanges();
                    }

                    ((exam_q_levels)obj).pic_paths = the_path;

                    //check if this level already in DB
                    var levelsVar = entities.levels.SingleOrDefault(usr => usr.level1 == ((exam_q_levels)obj).level.level1);

                    if (levelsVar != null)
                    {
                        lvl = levelsVar;
                    }
                    else
                    {
                        //create row for level
                        maxlvl = entities.levels.Max(usr => (int?)usr.id);

                        if (maxlvl == null)
                        {
                            maxlvl = 0;
                        }

                        lvl        = new level();
                        lvl.id     = (int)++maxlvl;
                        lvl.level1 = ((exam_q_levels)obj).level.level1;
                        //entities.levels.Add(lvl);
                        //entities.SaveChanges();
                    }

                    ((exam_q_levels)obj).level = lvl;

                    //check if this stage already in DB
                    var stageVar = entities.stages.SingleOrDefault(usr => usr.stage1 == ((exam_q_levels)obj).stage.stage1);
                    if (stageVar != null)
                    {
                        stg = stageVar;
                    }
                    else
                    {
                        //add new row with stage
                        maxstg = entities.stages.Max(usr => (int?)usr.id);

                        if (maxstg == null)
                        {
                            maxstg = 0;
                        }

                        stg        = new stage();
                        stg.id     = (int)++maxstg;
                        stg.stage1 = ((exam_q_levels)obj).stage.stage1;
                        //entities.stages.Add(stg);
                        //entities.SaveChanges();
                    }
                    ((exam_q_levels)obj).stage = stg;

                    //check if this four descriptions already in DB
                    var descVar = entities.desacriptaions.SingleOrDefault(usr => usr.desacriptaion1 == ((exam_q_levels)obj).desacriptaion.desacriptaion1);
                    if (descVar != null)
                    {
                        des    = descVar;
                        maxdes = entities.desacriptaions.Max(usr => (int?)usr.id);
                    }
                    else
                    {
                        maxdes = entities.desacriptaions.Max(usr => (int?)usr.id);

                        if (maxdes == null)
                        {
                            maxdes = 0;
                        }

                        des                = new desacriptaion();
                        des.id             = (int)++maxdes;
                        des.desacriptaion1 = ((exam_q_levels)obj).desacriptaion.desacriptaion1;
                    }

                    ((exam_q_levels)obj).desacriptaion = des;

                    //1
                    var descVar1 = entities.desacriptaions.SingleOrDefault(usr => usr.desacriptaion1 == ((exam_q_levels)obj).desacriptaion2.desacriptaion1);
                    if (descVar1 != null)
                    {
                        des1 = descVar1;
                    }
                    else
                    {
                        des1                = new desacriptaion();
                        des1.id             = (int)++maxdes;
                        des1.desacriptaion1 = ((exam_q_levels)obj).desacriptaion1.desacriptaion1;
                    }

                    ((exam_q_levels)obj).desacriptaion1 = des1;

                    //2
                    var descVar2 = entities.desacriptaions.SingleOrDefault(usr => usr.desacriptaion1 == ((exam_q_levels)obj).desacriptaion2.desacriptaion1);
                    if (descVar2 != null)
                    {
                        des2 = descVar2;
                    }
                    else
                    {
                        des2                = new desacriptaion();
                        des2.id             = (int)++maxdes;
                        des2.desacriptaion1 = ((exam_q_levels)obj).desacriptaion2.desacriptaion1;
                    }

                    ((exam_q_levels)obj).desacriptaion2 = des2;

                    //3
                    var descVar3 = entities.desacriptaions.SingleOrDefault(usr => usr.desacriptaion1 == ((exam_q_levels)obj).desacriptaion3.desacriptaion1);
                    if (descVar3 != null)
                    {
                        des3 = descVar3;
                    }
                    else
                    {
                        des3                = new desacriptaion();
                        des3.id             = (int)++maxdes;
                        des3.desacriptaion1 = ((exam_q_levels)obj).desacriptaion3.desacriptaion1;
                    }

                    ((exam_q_levels)obj).desacriptaion3 = des3;

                    entities.exam_q_levels.Add((exam_q_levels)obj);
                    entities.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// the regular exam on specipic level stage
        /// </summary>
        /// <param name="selected_level"></param>
        /// <param name="selected_stage"></param>
        /// <returns></returns>
        public ActionResult exam(string selected_level, string selected_stage)
        {
            _eyeMusicModel =
                (eyemusic45.Models.ViewModels.eyeMusicModel)System.Web.HttpContext.Current.Session["Themodel"];
            vh = (eyeMusic2)System.Web.HttpContext.Current.Session["eyeMusic"];

            if (_eyeMusicModel == null || vh == null)
            {
                if (System.Web.HttpContext.Current.User.Identity.Name != "")
                {
                    session_dead(System.Web.HttpContext.Current.User.Identity.Name);
                }
                else
                {
                    not_session_dead();
                }
            }

            vh.startExam(selected_level, selected_stage);
            _eyeMusicModel.image_names    = vh._myManager.image_names;
            _eyeMusicModel.path_for_image = vh._myManager.path_for_image;
            _eyeMusicModel.select_level   = selected_level;
            _eyeMusicModel.select_stage   = selected_stage;

            _eyeMusicModel.num_question = 0;
            _eyeMusicModel.exam_number  = 1;


            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    examWithLevel foundmax = (from thisexam in entities.examWithLevels
                                              where thisexam.user_ID == _eyeMusicModel.userDAL.user_ID &&
                                              thisexam.level == selected_level &&
                                              thisexam.stage == selected_stage
                                              select thisexam).OrderByDescending(p => p.num_exam).First();

                    _eyeMusicModel.exam_number  = (int)foundmax.num_exam;
                    _eyeMusicModel.num_question = (int)foundmax.max_num_question;

                    if (_eyeMusicModel.num_question > 9)
                    {
                        _eyeMusicModel.num_question = 0;
                        _eyeMusicModel.exam_number++;
                    }
                }
                catch (Exception e)
                {
                }
            }


            if (!checkeifHaveQuestion())
            {
                askQuestion();
            }

            _eyeMusicModel.previos_path = "";

            return(View("exam", _eyeMusicModel));
        }
Esempio n. 9
0
        //show only grades of all exmas
        public ActionResult grades()
        {
            _eyeMusicModel = (eyemusic45.Models.ViewModels.eyeMusicModel)System.Web.HttpContext.Current.Session["Themodel"];
            vh             = (eyeMusic2)System.Web.HttpContext.Current.Session["eyeMusic"];

            if (_eyeMusicModel == null || vh == null)
            {
                if (System.Web.HttpContext.Current.User.Identity.Name != "")
                {
                    session_dead(System.Web.HttpContext.Current.User.Identity.Name);
                }
                else
                {
                    not_session_dead();
                }
            }

            System.Web.HttpContext.Current.Session["Themodel"] = _eyeMusicModel;

            List <resualt_exam_row> allRes = new List <resualt_exam_row>();

            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                //get object models from context
                ObjectContext objContext = ((IObjectContextAdapter)entities).ObjectContext;
                //get all full names types from object model
                var fullNameTypes = objContext.MetadataWorkspace.GetItems <EntityType>(DataSpace.OSpace);
                ///////////////////
                var conStr     = objContext.Connection.ConnectionString;
                var connection = new EntityConnection(conStr);
                var workspace  = connection.GetMetadataWorkspace();

                var    entitySets = workspace.GetItems <EntityContainer>(DataSpace.SSpace).First().BaseEntitySets;
                string schema     = entitySets[0].Schema;


                try
                {
                    var all = entities.Database.SqlQuery <resualt_exam_row>(
                        "Select * from (select ROW_NUMBER () OVER (ORDER BY [user_ID]) as row_num, " +
                        "*  " +
                        "FROM ( " +
                        "SELECT exam.[user_ID], " +
                        "exam.[num_exam], " +
                        "stg.stage, " +
                        "lvl.[level], " +
                        "count(*) as num_correct " +
                        "FROM  [" + schema + "].[exam] exam, " +
                        "[" + schema + "].[stages] stg, " +
                        "[" + schema + "].[levels] lvl " +
                        "WHERE exam.[correct] = 1 " +
                        "AND exam.[level] = lvl.id " +
                        "AND exam.[stage] = stg.id " +
                        "GROUP BY exam.[user_ID], " +
                        "exam.[num_exam], " +
                        "stg.stage, " +
                        "lvl.[level] " +
                        "union select exam.[user_ID], " +
                        "exam.[num_exam], " +
                        "stg.stage, " +
                        "lvl.[level], " +
                        "0 as num_correct " +
                        "FROM  [" + schema + "].[exam] exam, " +
                        "[" + schema + "].[stages] stg, " +
                        "[" + schema + "].[levels] lvl " +
                        "WHERE exam.[correct] = 0 " +
                        "AND exam.[level] = lvl.id " +
                        "AND exam.[stage] = stg.id " +
                        "GROUP BY exam.[user_ID], " +
                        "exam.[num_exam], " +
                        "stg.stage, " +
                        "lvl.[level] " +
                        "having count(*) = 10 ) as [rows_number]) as dd where user_ID = @p0 " +
                        "order by [level], [stage]", _eyeMusicModel.userDAL.user_ID);


                    /*var all = (from thisexam in entities.resualt_exam_row
                     *         where thisexam.user_ID == _eyeMusicModel.userDAL.user_ID
                     *         select thisexam).OrderBy(usr => usr.level).ThenBy(usr2 => usr2.stage);
                     */
                    foreach (resualt_exam_row rs in all)
                    {
                        resualt_exam_row rsnew = new resualt_exam_row();
                        rsnew.num_correct = rs.num_correct;
                        rsnew.num_exam    = rs.num_exam;
                        rsnew.user_ID     = rs.user_ID;

                        rsnew.level = vh.heb.returnStr(rs.level.Substring(2).Replace("_", " ").Trim());
                        rsnew.stage = vh.heb.returnStr(rs.stage.Substring(2).Replace("_", " ").Trim());
                        allRes.Add(rsnew);
                    }
                }
                catch (Exception e)
                {
                    resualt_exam_row rsnew = new resualt_exam_row();
                    rsnew.num_correct = 0;
                    rsnew.num_exam    = 1;
                    rsnew.user_ID     = 122;
                    rsnew.level       = e.Message;
                    rsnew.stage       = "";
                    allRes.Add(rsnew);
                }
            }

            ViewBag.len   = _eyeMusicModel.len;
            ViewBag.stage = _eyeMusicModel.select_stage;
            ViewBag.level = _eyeMusicModel.select_level;
            return(View(allRes));
        }
Esempio n. 10
0
        public ActionResult examResualt(string id)
        {
            int theanswer  = int.Parse(id);
            int if_currect = 0;

            _eyeMusicModel = (eyemusic45.Models.ViewModels.eyeMusicModel)System.Web.HttpContext.Current.Session["Themodel"];
            vh             = (eyeMusic2)System.Web.HttpContext.Current.Session["eyeMusic"];

            string prev_des = _eyeMusicModel.answers[_eyeMusicModel.theTrue];

            if (_eyeMusicModel == null || vh == null)
            {
                if (System.Web.HttpContext.Current.User.Identity.Name != "")
                {
                    session_dead(System.Web.HttpContext.Current.User.Identity.Name);
                }
                else
                {
                    not_session_dead();
                }
            }

            _eyeMusicModel.previos_path = _eyeMusicModel.currImagePath;

            Thread addExamToDB = new Thread(addExamToDBUser);
            exam   curEx       = new DAL.exam();

            curEx.datetime = DateTime.Now;
            curEx.answer   = theanswer;
            curEx.num_exam = _eyeMusicModel.exam_number;
            curEx.num_q    = _eyeMusicModel.num_question;
            curEx.user_ID  = _eyeMusicModel.userDAL.user_ID;

            if (curEx.answer == _eyeMusicModel.theTrue)
            {
                if_currect    = 1;
                curEx.correct = true;
            }
            else
            {
                if_currect    = 0;
                curEx.correct = false;
            }

            curEx.session = 1;
            addExamToDB.Start(curEx);



            _eyeMusicModel.exam_number++;
            _eyeMusicModel.num_question = 0;

            System.Web.HttpContext.Current.Session["Themodel"] = _eyeMusicModel;


            //Get the result for all exmas
            List <resualt_exam> allRes = new List <resualt_exam>();

            using (amedilab_dataEntities entities = new amedilab_dataEntities())
            {
                try
                {
                    var all = (from thisexam in entities.resualt_exam
                               where thisexam.user_ID == _eyeMusicModel.userDAL.user_ID &&
                               thisexam.level == _eyeMusicModel.select_level &&
                               thisexam.stage == _eyeMusicModel.select_stage &&
                               thisexam.num_exam == _eyeMusicModel.exam_number - 1
                               select thisexam);

                    foreach (resualt_exam rs in all)
                    {
                        allRes.Add(rs);
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(Json(new { the_stage = allRes[0].stage, the_level = allRes[0].level, num_correct = allRes[0].num_correct, num_exam = allRes[0].num_exam, ifCorrect = if_currect }));
        }