public async Task <IHttpActionResult> PutAddSubProblem(int id, AddSubProblem addSubProblem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != addSubProblem.AddSubProblemID) { return(BadRequest()); } db.Entry(addSubProblem).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddSubProblemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAddSubProblem(int id) { AddSubProblem addSubProblem = await db.AddSubProblems.FindAsync(id); if (addSubProblem == null) { return(NotFound()); } return(Ok(addSubProblem)); }
public async Task <IHttpActionResult> PostAddSubProblem(AddSubProblem addSubProblem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AddSubProblems.Add(addSubProblem); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = addSubProblem.AddSubProblemID }, addSubProblem)); }
public async Task <IHttpActionResult> DeleteAddSubProblem(int id) { AddSubProblem addSubProblem = await db.AddSubProblems.FindAsync(id); if (addSubProblem == null) { return(NotFound()); } db.AddSubProblems.Remove(addSubProblem); await db.SaveChangesAsync(); return(Ok(addSubProblem)); }
/// <summary> /// Sets the UI for the game screen. /// </summary> private void setUI(StudentProblem curProb) { AddSubProblem prob = curProb.Problem; Session["CurAnswer"] = prob.Result; string ord1 = prob.Operator1.ToString(); string ord2 = prob.Operator2.ToString(); // set the images for the UI imgOpSign.ImageUrl = "images/signs/plus.png"; imgOrd1.ImageUrl = "images/nums/" + ord1 + ".png"; imgOrd2.ImageUrl = "images/nums/" + ord2 + ".png"; // set alternate text imgOpSign.AlternateText = "+"; imgOrd1.AlternateText = ord1; imgOrd2.AlternateText = ord2; }
/// <summary> /// Constructor /// </summary> public StudentProblem(AddSubProblem p, Result r) { Problem = p; studentResult = r; }
// Randomly fill problem list with problems from the appropriate level and problem type // TODO: Query the Results table for id = StudentID, level = Level, and problem type = ProbType // This should return a list of the missed problems of this type in this level. // Use these values to start the PopulateProblemList list private void PopulateProblemList() { AddSubProblem thisAddSubProb = null; Result thisResult; // Open a connection to the DB using (DataClassesDataContext dc = new DataClassesDataContext()) { // RELEASE 2: // Remove the 0..55 range, and replace // it with a random selection where Level = desired level // NEWID() provides a randomization function. // See MSDN, Selecting Rows Randomly from a Large Table // https://msdn.microsoft.com/en-us/library/cc441928.aspx // Get list of *missed* problem IDs for this level // This will form the first part of the problem list var missedProbs = dc.GetMissedProblems(sid, (int)probType); List <int> missedProbIds = new List <int>(); foreach (GetMissedProblemsResult m in missedProbs) { missedProbIds.Add(m.ProblemID); } // Now get a list of *new* problem IDs for this level and problem type var problemQuery = dc.GetProblemIDs((int)probType, level); List <int> newProbIds = new List <int>(); foreach (GetProblemIDsResult i in problemQuery) { newProbIds.Add(i.AddSubProblemID); } // Finally, combine the lists. // For now, we will start with missed problem ids, // and fill the rest of the list with new problem ids // There will be problem ids that are not covered in this round // TODO: How to deal with more than NUM_PROBS_PER_ROUND missed problems? List <int> allProbIds = new List <int>(); // At most, the number of missed problems to be shown // is the number of problems in the current round int numMissedShown = Math.Min(missedProbIds.Count, NUM_PROBS_PER_ROUND); // If there are any problems not yet used, the slots will // be filled by new problems int numNewShown = NUM_PROBS_PER_ROUND - numMissedShown; for (int i = 0; i < numMissedShown; i++) { allProbIds.Add(missedProbIds[i]); } int newProbCount = 0; for (int i = numMissedShown; i < NUM_PROBS_PER_ROUND; i++) { allProbIds.Add(newProbIds[newProbCount++]); } // Get problems based on the list of ids var problems = dc.GetProblems(allProbIds); foreach (var prob in problems) { // Create the new Result thisResult = new Result(); // Pre-set values in the new Result thisResult.ProblemID = prob.AddSubProblemID; thisResult.Level = prob.Level; // Create a new StudentProblem StudentProblem sp = new StudentProblem(prob, thisResult); // new StudentProblem(thisAddSubProb, thisResult); // Add to problem list ProblemList.Add(sp); } } }
partial void DeleteAddSubProblem(AddSubProblem instance);
partial void UpdateAddSubProblem(AddSubProblem instance);
partial void InsertAddSubProblem(AddSubProblem instance);