Example #1
0
 public IHttpActionResult DeleteProblem(int id, int problemid)
 {
     try
     {
         ProblemManager manager = new ProblemManager();
         Problem        temp    = manager.Obtener(problemid);
         if (temp.customer.id == id)
         {
             Problem result = manager.Eliminar(problemid);
             if (result != null)
             {
                 return(Ok());
             }
             else
             {
                 return(BadRequest());
             }
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
Example #2
0
    public void OnCorrectNumberHit()
    {
        this.messageHolderText.text = "CORRECT!";

        Destroy(this.currentlyActiveQuestObject.gameObject);
        this.currentlyActiveQuestObject = null;

        this.UpdatePlayerResources(1);

        this.spawnCount++;
        if (this.spawnCount > this.thisLevelSpawnCountGoal)
        {
            this.currentLevel++;

            if (!Player.playerProgressData[this.currentlySelectedProblem].levels.ContainsKey(this.currentLevel))
            {
                this.currentLevel--;
            }
            else
            {
                this.levelText.text = this.currentLevel.ToString();
                Player.playerProgressData[this.currentlySelectedProblem].levels[this.currentLevel] = true;
                Player.Save();
            }

            this.spawnCount = 1;
        }
        this.UpdateSpawnCount();

        this.SpawnNewQuestion(ProblemManager.GetNewQuestion(this.currentlySelectedProblem, this.currentLevel, this.spawnCount));
    }
Example #3
0
    public void StartNewGame()
    {
        if (this.currentlyActiveQuestObject != null)
        {
            Destroy(this.currentlyActiveQuestObject.gameObject);
            this.currentlyActiveQuestObject = null;
        }

        if (this.currentlyUsedBullet != null)
        {
            Destroy(this.currentlyUsedBullet.gameObject);
            this.currentlyUsedBullet           = null;
            this.weaponController.loadedBullet = null;
        }

        this.weaponController.Resume();
        this.currentlyUsedBullet = this.weaponController.LoadNewBullet().GetComponent <BulletComponent>();
        this.currentlyUsedBullet.AddListenerToBullet(this.OnBulletDeactivation);

        this.currentlyUsedBullet = this.weaponController.LoadNewBullet().GetComponent <BulletComponent>();
        this.currentlyUsedBullet.AddListenerToBullet(this.OnBulletDeactivation);

        this.thisLevelSpawnCountGoal = Player.playerProgressData[this.currentlySelectedProblem].levelsSpawnCount[this.currentLevel];
        this.spawnCount = 1;
        this.UpdateSpawnCount();

        this.SpawnNewQuestion(ProblemManager.GetNewQuestion(this.currentlySelectedProblem, this.currentLevel, this.spawnCount));

        this.isAGameRunning = true;
    }
Example #4
0
 public IHttpActionResult PutProblem(int id, int problemid, [FromBody] Problem problem)
 {
     try
     {
         ProblemManager manager = new ProblemManager();
         Problem        temp    = manager.Obtener(problemid);
         if (temp.customer.id == id)
         {
             problem.customer.id = id;
             Problem result = manager.Editar(problemid, problem);
             if (result != null)
             {
                 return(Ok());
             }
             else
             {
                 return(BadRequest());
             }
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
    void Start()
    {
        taskInfo.SetActive(false);
        mapButton.SetActive(true);
        spriteRenderer  = GetComponent <SpriteRenderer>();
        this.isUnlocked = false;

        if (Player.playerProgressData.ContainsKey(this.problem))
        {
            spriteRenderer.sprite = unlockedSprite;
            this.isUnlocked       = true;
        }
        else
        {
            if (Player.intelligenceAmount >= (int)this.problem * IntelliganceBetweenProblems)
            {
                Player.playerProgressData.Add(this.problem, ProblemManager.GenerateNewProblem(this.problem));
                Player.Save();

                spriteRenderer.sprite = unlockedSprite;
                this.isUnlocked       = true;
            }
            else
            {
                spriteRenderer.sprite = lockedSprite;
            }
        }
    }
Example #6
0
    public void OnClickStartGame()
    {
        // Mocking player data

        /*  Player.intelligenceAmount = 150;
         * Player.playerProgressData =
         * Player.playerProgressData.Add(Problem.Addition, ProblemManager.GenerateNewProblem(Problem.Addition));
         * Player.playerProgressData.Add(Problem.Subtraction, ProblemManager.GenerateNewProblem(Problem.Subtraction)); */
        // -------------

        if (!Player.Load())
        {
            Player.playerProgressData = new Dictionary <Problem, ProblemData>();
            Player.playerProgressData.Add(Problem.Addition, ProblemManager.GenerateNewProblem(Problem.Addition));
            Player.selectedProblem    = Problem.Addition;
            Player.intelligenceAmount = 0;

            if (!Player.Save())
            {
                Debug.LogError("Couldn't save player data!");
            }

            Debug.Log("New Player data was created and saved!");
        }
        else
        {
            Debug.Log("Player data loaded successfully!");
        }

        StartCoroutine(PlayButtonClickSound());

        GameStateManager.TransitionToScene(GameScene.Home);
    }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Student")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            //获取作业id
            id = Request.QueryString["AssignmentId"];
            header_text.Text = Request.QueryString["AssignmentTitle"];
            ProblemManager ProblemMan = new ProblemManager();

            stu         = (Student)Session["student"];
            ProblemList = ProblemMan.GetProblem(System.Int32.Parse(id));

            if (ProblemList.Count != 0)
            {
                //动态创建问题及回答区域
                //加载上次答案
                AnswerList = AnswerMan.GetAnswerList(stu.username, System.Int32.Parse(id));
                accessory  = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));

                for (int i = 0; i < ProblemList.Count; i++)
                {
                    string  pro = "<p>" + ProblemList[i].title + "</p>";
                    Control ct  = ParseControl(pro);
                    PlaceHolder1.Controls.Add(ct);

                    string an = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'></textarea></p>";

                    //加载已有答案
                    if (AnswerList != null)
                    {
                        an         = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'>" + AnswerList[i].content + "</textarea></p>";
                        submitFlag = false;
                    }

                    Control ct2 = ParseControl(an);
                    PlaceHolder1.Controls.Add(ct2);
                }

                //加载已有附件
                if (accessory != null)
                {
                    fileTips.Text       = "已有附件,无需再添加!";
                    FileUpload2.Enabled = false;
                }
            }
            else
            {
                header_text.Text    = "   逗你玩呢,哈哈哈哈。";
                submit.Enabled      = false;
                submit2.Enabled     = false;
                export.Enabled      = false;
                export2.Enabled     = false;
                fileTips.Enabled    = false;
                FileUpload2.Enabled = false;
            }
        }
Example #8
0
        public ActionResult Search(String type, String content)
        {
            List <ProblemEntity> list = ProblemManager.GetProblemBySearch(type, content);

            ViewBag.SearchType = type;
            ViewBag.Content    = content;

            return(View(list));
        }
Example #9
0
        public ActionResult Submit(Int32 id = -1)
        {
            ProblemEntity problem = ProblemManager.GetProblem(id);
            IEnumerable <SelectListItem> items = this.GetLanguageItems();

            ViewBag.Languages = items;

            return(View(problem));
        }
Example #10
0
 public static void Main()
 {
     ProblemManager.GenericBox();
     ProblemManager.GenericBoxOfString();
     ProblemManager.GenericBoxOfInteger();
     ProblemManager.GenericSwapMethodStrings();
     ProblemManager.GenericSwapMethodIntegers();
     ProblemManager.GenericCountMethodStrings();
     ProblemManager.GenericCountMethodDoubles();
 }
Example #11
0
        /// <summary>
        /// 后台欢迎页面
        /// </summary>
        /// <returns>操作后的结果</returns>
        public ActionResult Index()
        {
            ViewData["UserCount"]     = UserManager.CountUserRanklist();
            ViewData["ProblemCount"]  = ProblemManager.CountProblems();
            ViewData["SolutionCount"] = SolutionManager.CountSolutions();

            ViewData["SystemRunTime"] = this.GetSystemRunTime();
            ViewData["SystemVersion"] = ConfigurationManager.Version;

            ViewData["SystemPlatform"] = ConfigurationManager.Platform;
            ViewData["DataBaseType"]   = DatabaseManager.DataBaseType;

            ViewData["ServerName"]    = Server.MachineName.ToString() + "/" + Request.ServerVariables["LOCAL_ADDR"] + ":" + Request.ServerVariables["SERVER_PORT"];
            ViewData["DotNetVersion"] = ".NET CLR " + Environment.Version.ToString();

            ViewBag.IsSuperAdministrator = AdminManager.HasPermission(PermissionType.SuperAdministrator);
            ViewBag.IsAccessDatabase     = DatabaseManager.IsAccessDB;

            return(View());
        }
Example #12
0
 public IHttpActionResult PostProblem(int id, [FromBody] Problem problem)
 {
     try
     {
         ProblemManager manager = new ProblemManager();
         problem.customer.id = id;
         Problem result = manager.Insertar(problem);
         if (result != null)
         {
             return(Created(new Uri(Url.Link(ViewRouteName, new { id = result.customer.id })), result));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
Example #13
0
        public ActionResult Import(FormCollection form, HttpPostedFileBase file)
        {
            return(ResultToMessagePage(() =>
            {
                IMethodResult result = ProblemManager.AdminImportProblem(Request, form["filetype"], form["uploadtype"], form["content"], file);

                if (!result.IsSuccess)
                {
                    return new Tuple <IMethodResult, String>(result, String.Empty);
                }

                Dictionary <Int32, Boolean> importedItems = result.ResultObject as Dictionary <Int32, Boolean>;
                String successInfo = String.Format("{0} problem(s) have benn successfully imported!", importedItems.Count.ToString());

                StringBuilder nodataItems = new StringBuilder();
                Int32 nodataCount = 0;

                foreach (KeyValuePair <Int32, Boolean> pair in importedItems)
                {
                    if (!pair.Value)
                    {
                        if (nodataCount > 0)
                        {
                            nodataItems.Append(',');
                        }

                        nodataItems.Append(pair.Key.ToString());
                        nodataCount++;
                    }
                }

                if (nodataCount > 0)
                {
                    successInfo += String.Format("<br/>{0} problem(s) ({1}) have no data or fail to import these data!", nodataCount.ToString(), nodataItems.ToString());
                }

                return new Tuple <IMethodResult, String>(result, successInfo);
            }));
        }
Example #14
0
        protected void DetailsView7_ItemInserting(object sender, DetailsViewInsertEventArgs e)         //answer表插入判断
        {
            StudentManager stu = new StudentManager();
            ProblemManager p   = new ProblemManager();

            if (e.Values["student"] == null || e.Values["problem"] == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中Student,prob字段不能为空');", true);
                e.Cancel = true;
                return;
            }
            if (stu.GetStudent(e.Values["student"].ToString()) == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中外键student字段不存在');", true);
                e.Cancel = true;
                return;
            }
            if (p.GetProblemById(int.Parse(e.Values["problem"].ToString())) == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中外键problem字段不存在');", true);
                e.Cancel = true;
                return;
            }
        }
Example #15
0
        public ActionResult Set(Int32 id = 1)
        {
            PagedList <ProblemEntity> list = ProblemManager.GetProblemSet(id);

            return(ViewWithPager(list, id));
        }
        /// <summary>
        /// 获取评测列表的Json信息
        /// </summary>
        /// <param name="lanaugeSupport">评测机支持语言</param>
        /// <param name="count">评测机请求个数</param>
        /// <returns>评测列表Json信息</returns>
        public static Boolean TryGetPendingListJson(String lanaugeSupport, String count, out String result, out String error)
        {
            result = String.Empty;

            try
            {
                error = JudgeStatusManager.GetJudgeServerLoginStatus();

                if (!String.IsNullOrEmpty(error))
                {
                    return(false);
                }

                StringBuilder         ret          = new StringBuilder();
                Int32                 requestCount = Math.Max(1, count.ToInt32(1));
                List <SolutionEntity> pendingList  = SolutionManager.JudgeGetPendingSolution(requestCount, GetJudgeSupportLanguages(lanaugeSupport));

                Dictionary <Int32, ProblemEntity> problemCache        = new Dictionary <Int32, ProblemEntity>();
                Dictionary <Int32, String>        problemVersionCache = new Dictionary <Int32, String>();

                ProblemEntity  problem            = null;
                String         problemDataVersion = String.Empty;
                SolutionEntity solution           = null;
                Int32          listCount          = (pendingList == null ? 0 : pendingList.Count);

                ret.Append("[");

                for (Int32 i = 0; i < listCount; i++)
                {
                    if (i > 0)
                    {
                        ret.Append(",");
                    }

                    solution = pendingList[i];

                    if (!problemCache.TryGetValue(solution.ProblemID, out problem))
                    {
                        problem = ProblemManager.GetJudgeProblem(solution.ProblemID);
                        problemCache[solution.ProblemID] = problem;
                    }

                    if (!problemVersionCache.TryGetValue(solution.ProblemID, out problemDataVersion))
                    {
                        problemDataVersion = ProblemDataManager.GetProblemDataVersion(solution.ProblemID);
                        problemVersionCache[solution.ProblemID] = problemDataVersion;
                    }

                    if (problem != null)
                    {
                        Double scale       = solution.LanguageType.Scale;
                        Int32  timeLimit   = (Int32)(problem.TimeLimit * scale);
                        Int32  memoryLimit = (Int32)(problem.MemoryLimit * scale);

                        ret.Append("{");
                        ret.Append("\"sid\":\"").Append(solution.SolutionID.ToString()).Append("\",");
                        ret.Append("\"pid\":\"").Append(solution.ProblemID.ToString()).Append("\",");
                        ret.Append("\"username\":\"").Append(solution.UserName).Append("\",");
                        ret.Append("\"dataversion\":\"").Append(problemDataVersion).Append("\",");
                        ret.Append("\"timelimit\":\"").Append(timeLimit.ToString()).Append("\",");
                        ret.Append("\"memorylimit\":\"").Append(memoryLimit.ToString()).Append("\",");
                        ret.Append("\"language\":\"").Append(solution.LanguageType.Type).Append("[]\",");
                        ret.Append("\"sourcecode\":\"").Append(JsonEncoder.JsonEncode(solution.SourceCode)).Append("\"");
                        ret.Append("}");
                    }
                }

                ret.Append("]");

                result = ret.ToString();
                return(true);
            }
            catch (System.Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Example #17
0
 public ActionResult Show(Int32 id = -1)
 {
     return(View(ProblemManager.GetProblem(id)));
 }
    public bool hasToAnswer = false;        // Lets player answer a question

    // Start is called before the first frame update
    void Start()
    {
        instance = this;
    }