Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DbScript,Title")] Exercises exercises)
        {
            if (id != exercises.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exercises);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExercisesExists(exercises.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(exercises));
        }
Ejemplo n.º 2
0
        public Boolean checkAnswer(int id, QueryResponse response)
        {
            People  currentStudent = _context.People.FirstOrDefault(p => p.PinCode == response.pinCode);
            Queries currentQuery   = _context.Queries.FirstOrDefault(q => q.Id == id);

            if (currentStudent == null || currentQuery == null)
            {
                return(false);
            }
            Scores score = _context.Scores.FirstOrDefault(s => s.PeopleId == currentStudent.Id && s.QuerieId == currentQuery.Id);

            // Check if response is good
            if (score == null)
            {
                score        = new Scores();
                score.People = currentStudent;
                score.Querie = currentQuery;
            }

            score.Attempts += 1;
            score.Success   = currentQuery.checkStatement(response.query, _configuration["ConnectionStrings:ExerciseConnection"]);
            _context.Update(score);
            _context.SaveChanges();
            return(score.Success);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Statement,Formulation,Rank,ExerciseId")] Queries queries)
        {
            if (id != queries.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(queries);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QueriesExists(queries.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExerciseId"] = new SelectList(_context.Exercises, "Id", "Title", queries.ExerciseId);
            return(View(queries));
        }