public ActionResult Create([Bind(Include = "ClassUnitID,ClassName")] ClassUnit classunit) { if (ModelState.IsValid) { addFolder(classunit.ClassName + "Shared"); addFolder(classunit.ClassName + "Submission"); List <Folder> ClassFolders = new List <Folder>(); ClassFolders.Add(_ctx.Folders.Single(x => x.FolderName == classunit.ClassName + "Shared")); ClassFolders.Add(_ctx.Folders.Single(x => x.FolderName == classunit.ClassName + "Submission")); _ctx.Classunits.Add( new ClassUnit() { ClassName = classunit.ClassName, Folders = ClassFolders }); _ctx.SaveChanges(); return(RedirectToAction("Index")); } return(View(classunit)); }
//更新数据 protected void btnUpdate_Click(object sender, EventArgs e) { ClassUnit updateStudyingInform = new ClassUnit(); updateStudyingInform.stuId = lblstuId.Text; if (j == "low") { updateStudyingInform.designLow = Convert.ToInt32(txtscore.Text); } else if (j == "mid") { updateStudyingInform.designMid = Convert.ToInt32(txtscore.Text); } else { updateStudyingInform.designHigh = Convert.ToInt32(txtscore.Text); } int n = ClassUnitManager.UpdateStudyingInform2(updateStudyingInform, j); txtscore.Text = ""; lblstuId.Text = "stuId"; lblfilename.Text = "filename"; //提示更改的数据行数 if (n > 0) { RegisterClientScriptBlock("", string.Format("<script type = 'text/javascript'> alert('成功更新数据,有{0}行收到更新!'); </script>", n.ToString())); } }
/// <summary> /// 从数据库中获取数据 /// </summary> public static ClassUnit GetStudyingInform(string stuId) { SQLHelper dbAccess = new SQLHelper(); //实例化一个SQLHelper类 string sql = "Select * from [ClassUnit] where stuId = @stuId"; SqlParameter[] para = { new SqlParameter("@stuId", stuId) }; //利用参数para进行动态定义 SqlDataReader dr = dbAccess.GetDRWithPara(sql, para); //获取查询数据流 //根据查询得到的数据,对成员赋值 //数据流中是否有数据 if (dr.Read()) { ClassUnit stuNews = new ClassUnit(); stuNews.stuId = dr["stuId"].ToString(); stuNews.pretest = int.Parse(dr["pretest"].ToString()); stuNews.low = int.Parse(dr["low"].ToString()); stuNews.mid = int.Parse(dr["mid"].ToString()); stuNews.high = int.Parse(dr["high"].ToString()); stuNews.designLow = int.Parse(dr["designlow"].ToString()); stuNews.designMid = int.Parse(dr["designmid"].ToString()); stuNews.designHigh = int.Parse(dr["designhigh"].ToString()); stuNews.totalScore = int.Parse(dr["totalScore"].ToString()); //关闭SqlDataReader对象,此时连接同时关闭 dr.Close(); return(stuNews); } else { dr.Close(); return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["stuId"] != null) { //GridView显示 string stuId = Session["stuId"].ToString(); //调用ShowData方法,返回DataSet数据集 infor = Manage.ShowData2("ClassUnit", stuId); GridView1.DataSource = infor; GridView1.DataBind(); //折线图显示 stuNews1 = ClassUnitManager.GetStudyingInform(stuId); int pre = int.Parse(ClassUnitManager.GetStudyingInformpre()); int low = int.Parse(ClassUnitManager.GetStudyingInformlow()); int mid = int.Parse(ClassUnitManager.GetStudyingInformmid()); int high = int.Parse(ClassUnitManager.GetStudyingInformhigh()); int designlow = int.Parse(ClassUnitManager.GetStudyingInformdelow()); int designmid = int.Parse(ClassUnitManager.GetStudyingInformdemid()); int designhigh = int.Parse(ClassUnitManager.GetStudyingInformdehigh()); int total = int.Parse(ClassUnitManager.GetStudyingInformtotal()); double[] yval = { stuNews1.pretest, stuNews1.low, stuNews1.mid, stuNews1.high, stuNews1.designLow, stuNews1.designMid, stuNews1.designHigh, stuNews1.totalScore }; string[] xval = { "前测", "初级测试", "中级测试", "高级测试", "初级设计题", "中级设计题", "高级设计题", "总成绩" }; double[] yval2 = { pre, low, mid, high, designlow, designmid, designhigh, total }; string[] xval2 = { "前测", "初级测试", "中级测试", "高级测试", "初级设计题", "中级设计题", "高级设计题", "总成绩" }; Chart1.Series["Series1"].Points.DataBindXY(xval, yval); Chart1.Series["Series2"].Points.DataBindXY(xval2, yval2); Chart1.Series["Series1"].IsValueShownAsLabel = true; Chart1.Series["Series2"].IsValueShownAsLabel = true; } else { Response.Redirect("Login.aspx"); } }
/// <summary> /// 向数据库更新数据 /// </summary> public static int UpdateStudyingInform(ClassUnit AClassUnit) { SQLHelper dbAccess = new SQLHelper(); string sql = "Update [ClassUnit] Set totalScore="; sql += AClassUnit.totalScore + " where stuId = '" + AClassUnit.stuId + "'"; return(dbAccess.doSql(sql)); }
// Update an existing classunit // PUT /api/classunits/ public HttpResponseMessage Put([FromBody] ClassUnit classunit) { //Uow.Classunits.Update(classunit); var cu = _uow.Classunits.Get(classunit.ClassUnitID); _uow.Complete(); return(new HttpResponseMessage(HttpStatusCode.NoContent)); }
// Create a new classunit // POST /api/classunits public HttpResponseMessage Post(ClassUnit classunit) { Uow.Classunits.Add(classunit); Uow.Commit(); var response = Request.CreateResponse(HttpStatusCode.Created, classunit); return(response); }
public void Trace(ClassUnit @class, string method, string message) { if (!IsTracing(@class)) { return; } SendMessage(@class, method, message); }
// GET: ClassUnits/Details/5 public ActionResult Details(int id) { ClassUnit classunit = _uow.Classunits.Get(id); if (classunit == null) { return(HttpNotFound()); } return(View(classunit)); }
//数据选择 protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { ClassUnit stuNews = new ClassUnit(); stuId = GridView1.Rows[e.NewSelectedIndex].Cells[1].Text; stuNews = ClassUnitManager.GetStudyingInform(stuId); //用户数据显示 lblstuId.Text = Convert.ToString(stuNews.stuId); txtTotalscore.Text = Convert.ToString(stuNews.totalScore); }
public static ClassUnit GetClass(Type type, bool create = true) { var @class = classes.GetValue(type); if (@class == null && create) { var @namespace = GetNamespace(type.Namespace); @class = new ClassUnit(type); } return(@class); }
public void TraceValues(ClassUnit @class, string method, string[] names, object[] values) { if (names != null) { TraceNamedValues(@class, method, names, values); } else { TraceUnnamedValues(@class, method, values); } }
public ActionResult Edit([Bind(Include = "ClassUnitId,ClassUnitName")] ClassUnit classunit) { if (ModelState.IsValid) { //classunit.ObjectState = ObjectState.Modified; //_uow.update(classunit); //await _uow.SaveAsync(); return(RedirectToAction("Index")); } return(View(classunit)); }
public void TraceNamedValues(ClassUnit @class, string method, IEnumerable namesAndValues) { if (!IsTracing(@class)) { return; } var message = Strings.NamedValues(namesAndValues); SendMessage(@class, method, message); }
public void Trace(ClassUnit @class, string method, string format, object[] args) { if (!IsTracing(@class)) { return; } var message = String.Format(format, args); SendMessage(@class, method, message); }
public void TraceProperties(ClassUnit @class, string method, object target, IEnumerable <string> names) { if (!IsTracing(@class)) { return; } var message = Strings.Properties(target, names); SendMessage(@class, method, message); }
public void TraceMethodArgs(ClassUnit @class, string method, IEnumerable args) { var names = Reflection.ParametersNames(@class.Type, method, false); if (names == null) { return; } var message = Strings.NamedValues(names, args); SendMessage(@class, method, message); }
// GET: ClassUnits/Delete/5 public ActionResult Delete(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} ClassUnit classunit = _ctx.Classunits.SingleOrDefault(c => c.ClassUnitID == id);//_uow.Classunits.Get(id); if (classunit == null) { return(HttpNotFound()); } return(View(classunit)); }
public ClassUnit(Type type, ClassUnit parent = null) { Debug.Assert(type != null); Type = type; Namespace = CompilationUnit.GetNamespace(type.Namespace); if (parent != null) { Parent = parent; } else { Parent = Namespace; } classes.Add(type, this); }
// GET: ClassUnits/Edit/5 public ActionResult Edit(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} ClassUnit classunit = _uow.Classunits.Get(id); if (classunit == null) { return(HttpNotFound()); } return(View(classunit)); }
public void AddFileToClassUnitShared(ApplicationUser user, Dossier file, ClassUnit _class = null) { if (_class == null) { /*var folder = Ctx.Folders.Find(user.ClassUnits.FirstOrDefault().Shared.FolderID); * file.Folder = folder; * folder.Files.Add(file);*/ } else { //var MyClassUnit = user.ClassUnits; //var folder = Ctx.Folders.Find(MyClassUnit.Find(_class.ClassUnitID).Shared.FolderID); //file.Folder = folder; //folder.Files.Add(file); } Ctx.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { ClassUnit classunit = _ctx.Classunits.Where(c => c.ClassUnitID == id).Include(x => x.Folders).First(); //var temp = _ctx.Folders.Where(x => x.) //_uow.Classunits.Remove(classunit); //List<Folder> temp = new List<Folder>(); var temp2 = classunit.Folders[0]; var temp3 = classunit.Folders[1]; _ctx.Folders.Remove(temp2); _ctx.Folders.Remove(temp3); _ctx.Classunits.Remove(classunit); _ctx.SaveChanges(); return(RedirectToAction("Index")); }
//数据更新 protected void btnUpdate_Click(object sender, EventArgs e) { ClassUnit updateStudyingInform = new ClassUnit(); updateStudyingInform.stuId = lblstuId.Text; updateStudyingInform.totalScore = Convert.ToInt32(txtTotalscore.Text); int n = ClassUnitManager.UpdateStudyingInform(updateStudyingInform); //提示更改的数据行数 if (n > 0) { RegisterClientScriptBlock("", string.Format("<script type = 'text/javascript'> alert('成功更新数据,有{0}行收到更新!'); </script>", n.ToString())); } lblstuId.Text = "label"; txtTotalscore.Text = ""; //数据更改后,再次绑定并显示更新后的数据 GridView1.DataSource = Manage.ShowData1("ClassUnit"); GridView1.DataBind(); }
public static int UpdateStudyingInform2(ClassUnit AClassUnit, string j) { SQLHelper dbAccess = new SQLHelper(); if (j == "low") { string sql = "Update [ClassUnit] Set designLow="; sql += AClassUnit.designLow + " where stuId = '" + AClassUnit.stuId + "'"; return(dbAccess.doSql(sql)); } else if (j == "mid") { string sql = "Update [ClassUnit] Set designMid="; sql += AClassUnit.designMid + " where stuId = '" + AClassUnit.stuId + "'"; return(dbAccess.doSql(sql)); } else { string sql = "Update [ClassUnit] Set designHigh="; sql += AClassUnit.designHigh + " where stuId = '" + AClassUnit.stuId + "'"; return(dbAccess.doSql(sql)); } }
//[ValidateAntiForgeryToken] public ActionResult Upload(string uploadTo, string classunit) { //var folder = Database.Folders.SingleOrDefault(x => x.FolderID == _folder.FolderID); string message = "The file was not uploaded"; var files = Request.Files; if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { if (files[i] != null && files[i].ContentLength > 0) { var fileName = Path.GetFileName(files[i].FileName); //if (folder.Files.SingleOrDefault(x => x.FileName == fileName) == null) //{ int uploadTo1 = new int(); int classunitID = new int(); if (classunit != null && classunit != "") { classunitID = int.Parse(classunit); } else { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var tempUser = database.Users.Include(p => p.ClassUnits).SingleOrDefault(x => x.UserName == user.UserName); ClassUnit tempClass = tempUser.ClassUnits.FirstOrDefault(); classunitID = tempClass.ClassUnitID; } if (uploadTo == "Submission") { uploadTo1 = 1; } else { uploadTo1 = 0; } var path = System.Web.Hosting.HostingEnvironment.MapPath("~/Files/") + fileName; if (classunit != null) { Dossier newFile = new Dossier(); newFile.FileName = fileName; newFile.FilePath = path; List <ClassUnit> tempList = database.Classunits.Include(x => x.Participants).Include(x => x.Folders).ToList(); ClassUnit temp = database.Classunits.SingleOrDefault(x => x.ClassUnitID == classunitID); List <Folder> folders = temp.Folders; Folder ChangedFolder = new Folder(); if (folders.Count > 0) { ChangedFolder = folders[uploadTo1]; } newFile.Folder = ChangedFolder; database.Dossiers.Add(newFile); } files[i].SaveAs(path); //Database.Folders.SingleOrDefault(x => x.FolderID == _folder.FolderID) //.Files.Add(new Dossier { FileName = files[i].FileName, FilePath = path }); database.SaveChanges(); message = "The file was uploaded"; //} //else //{ // message = "Filename allredy taken."; //} } else { message = "You can not upload an empty file."; } } } else { message = "No file selected!"; } return(RedirectToAction("UploadDocument", new { uploadMessage = message })); }
// [ValidateAntiForgeryToken] public ActionResult TeacherIndex(int?ClassUnitID) { Func <List <FileInfo>, List <FileViewModel> > FileInfoToFileViews = (fileInfo) => { List <FileViewModel> fileViews = new List <FileViewModel>(); foreach (var item in fileInfo) { byte[] byteArr; try { Image image = Image.FromFile(item.FullName); ImageConverter converter = new ImageConverter(); byteArr = (byte[])converter.ConvertTo(image, typeof(byte[])); } catch (Exception) { Icon icon = Icon.ExtractAssociatedIcon(item.FullName); Image image = new Icon(icon, 32, 32).ToBitmap(); ImageConverter converter = new ImageConverter(); byteArr = (byte[])converter.ConvertTo(image, typeof(byte[])); } var base64 = Convert.ToBase64String(byteArr); var imgSrc = String.Format("data:image/gif;base64,{0}", base64); fileViews.Add(new FileViewModel() { IconImg = imgSrc, File = item }); } return(fileViews); }; DirectoryInfo directory = new DirectoryInfo(Server.MapPath(@"~\Files")); ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); ClassUnit classUnit = database.Classunits.Include(z => z.Folders).SingleOrDefault(x => x.ClassUnitID == ClassUnitID); Folder SharedFolder = new Folder(); Folder SubmissionFolder = new Folder(); if (classUnit != null) { SharedFolder = classUnit.Folders.ToList()[0]; SubmissionFolder = classUnit.Folders.ToList()[1]; } var tem6p = database.Folders.Include(x => x.Files).ToList(); List <FileInfo> filesShared = new List <FileInfo>(); foreach (var file in SharedFolder.Files) { filesShared.Add(new FileInfo(file.FilePath)); } List <FileInfo> filesSubmission = new List <FileInfo>(); foreach (var file in SubmissionFolder.Files) { filesSubmission.Add(new FileInfo(file.FilePath)); } return(View(new MyViewModel() { ClassUnits = database.Classunits.ToList(), Shared = FileInfoToFileViews(filesShared), Submission = FileInfoToFileViews(filesSubmission) })); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) //防止点保存后,页面再一次刷新,和验证码一样 { if (Session["stuId"] != null) { int score1 = 0; int score2 = 0; int score3 = 0; string stuId = Session["stuId"].ToString(); stuNews1 = ClassUnitManager.GetStudyingInform(stuId); score1 = stuNews1.pretest; score2 = stuNews1.low; score3 = stuNews1.mid; if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 1) //不是第一次做题,读取断点 { BreakingPointRadio bpr = new BreakingPointRadio(); bpr = BreakingPointManager.LoadBreakingPointRadio(Session["stuId"].ToString()); r1 = TestMidManager.GetRadio(bpr.r1); TestMidManager.ShowQuestionRadio(r1, rdolistS1, lblS1); r2 = TestMidManager.GetRadio(bpr.r2); TestMidManager.ShowQuestionRadio(r2, rdolistS2, lblS2); r3 = TestMidManager.GetRadio(bpr.r3); TestMidManager.ShowQuestionRadio(r3, rdolistS3, lblS3); r4 = TestMidManager.GetRadio(bpr.r4); TestMidManager.ShowQuestionRadio(r4, rdolistS4, lblS4); r5 = TestMidManager.GetRadio(bpr.r5); TestMidManager.ShowQuestionRadio(r5, rdolistS5, lblS5); BreakingPointJudge bpj = new BreakingPointJudge(); bpj = BreakingPointManager.LoadBreakingPointJudge(Session["stuId"].ToString()); j1 = TestMidManager.GetJudge(bpj.j1); TestMidManager.ShowQuestionJudge(j1, rdolistJ1, lblJ1); j2 = TestMidManager.GetJudge(bpj.j2); TestMidManager.ShowQuestionJudge(j2, rdolistJ2, lblJ2); j3 = TestMidManager.GetJudge(bpj.j3); TestMidManager.ShowQuestionJudge(j3, rdolistJ3, lblJ3); j4 = TestMidManager.GetJudge(bpj.j4); TestMidManager.ShowQuestionJudge(j4, rdolistJ4, lblJ4); BreakingPointBlank bpb = new BreakingPointBlank(); bpb = BreakingPointManager.LoadBreakingPointBlank(Session["stuId"].ToString()); b1 = TestMidManager.GetBlank(bpb.b1); TestMidManager.ShowQuestionBlank(b1, lblB1, lblB12); b2 = TestMidManager.GetBlank(bpb.b2); TestMidManager.ShowQuestionBlank(b2, lblB2, lblB22); b3 = TestMidManager.GetBlank(bpb.b3); TestMidManager.ShowQuestionBlank(b3, lblB3, lblB32); BreakingPointDesign bpd = new BreakingPointDesign(); bpd = BreakingPointManager.LoadBreakingPointDesign(Session["stuId"].ToString()); d1 = TestMidManager.GetDesign(bpd.d1); TestMidManager.ShowQuestionDesign(d1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); TestMidManager.ShowRadioBreakingpoint(bpr, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5); TestMidManager.ShowJudgeBreakingpoint(bpj, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4); TestMidManager.ShowBlankBreakingpoint(bpb, txtB11, txtB21, txtB31); } else if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 0) { if (score1 >= 75 || score2 >= 60) { //随机出题(加入错题的权重,原先的题号不变,多余的错题作为普通题目放到最后进行随机) long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); int iDown = 1; int iUp = TestMidManager.CountRadio(); int[] rr = new int[iUp + 1]; for (int mn = 1; mn <= TestMidManager.CountRadio(); mn++) { rr[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongRadio"); iUp = iUp + rr[mn]; } int[] n = new int[5]; while (true) { int i; n[0] = ran.Next(iDown, iUp); n[1] = ran.Next(iDown, iUp); n[2] = ran.Next(iDown, iUp); n[3] = ran.Next(iDown, iUp); n[4] = ran.Next(iDown, iUp); //对随机选出的5个数重映射题号 for (i = 0; i <= 4; i++) { if (n[i] > TestMidManager.CountRadio()) { int temp; temp = n[i] - TestMidManager.CountRadio(); int p; for (p = 1; p <= TestMidManager.CountRadio(); p++) { temp = temp - rr[p]; if (temp <= 0) { break; } } n[i] = p; } } if (n[0] != n[1] && n[0] != n[2] && n[0] != n[3] && n[0] != n[4] && n[1] != n[2] && n[1] != n[3] && n[1] != n[4] && n[2] != n[3] && n[2] != n[4] && n[3] != n[4]) { i = 4; } if (i == 4) { break; } } r1 = TestMidManager.GetRadio(n[0]); TestMidManager.ShowQuestionRadio(r1, rdolistS1, lblS1); r2 = TestMidManager.GetRadio(n[1]); TestMidManager.ShowQuestionRadio(r2, rdolistS2, lblS2); r3 = TestMidManager.GetRadio(n[2]); TestMidManager.ShowQuestionRadio(r3, rdolistS3, lblS3); r4 = TestMidManager.GetRadio(n[3]); TestMidManager.ShowQuestionRadio(r4, rdolistS4, lblS4); r5 = TestMidManager.GetRadio(n[4]); TestMidManager.ShowQuestionRadio(r5, rdolistS5, lblS5); //随机出题 int iUp1 = TestMidManager.CountJudge(); int[] jj = new int[iUp1 + 1]; for (int mn = 1; mn <= TestHighManager.CountJudge(); mn++) { jj[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongJudge"); iUp1 = iUp1 + jj[mn]; } int[] j = new int[4]; while (true) { int i; j[0] = ran.Next(iDown, iUp1); j[1] = ran.Next(iDown, iUp1); j[2] = ran.Next(iDown, iUp1); j[3] = ran.Next(iDown, iUp1); //对随机选出的4个数重映射题号 for (i = 0; i <= 3; i++) { if (j[i] > TestMidManager.CountJudge()) { int temp; temp = j[i] - TestMidManager.CountJudge(); int p; for (p = 1; p <= TestMidManager.CountJudge(); p++) { temp = temp - jj[p]; if (temp <= 0) { break; } } j[i] = p; } } if (j[0] != j[1] && j[0] != j[2] && j[0] != j[3] && j[1] != j[2] && j[1] != j[3] && j[2] != j[3]) { i = 3; } if (i == 3) { break; } } j1 = TestMidManager.GetJudge(j[0]); TestMidManager.ShowQuestionJudge(j1, rdolistJ1, lblJ1); j2 = TestMidManager.GetJudge(j[1]); TestMidManager.ShowQuestionJudge(j2, rdolistJ2, lblJ2); j3 = TestMidManager.GetJudge(j[2]); TestMidManager.ShowQuestionJudge(j3, rdolistJ3, lblJ3); j4 = TestMidManager.GetJudge(j[3]); TestMidManager.ShowQuestionJudge(j4, rdolistJ4, lblJ4); //随机出题 int iUp2 = TestMidManager.CountBlank(); int[] kk = new int[iUp2 + 1]; for (int mn = 1; mn <= TestMidManager.CountBlank(); mn++) { kk[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongBlank"); iUp2 = iUp2 + kk[mn]; } int[] k = new int[3]; while (true) { int i; k[0] = ran.Next(iDown, iUp2); k[1] = ran.Next(iDown, iUp2); k[2] = ran.Next(iDown, iUp2); //对随机选出的3个数重映射题号 for (i = 0; i <= 2; i++) { if (k[i] > TestMidManager.CountBlank()) { int temp; temp = k[i] - TestMidManager.CountBlank(); int p; for (p = 1; p <= TestMidManager.CountBlank(); p++) { temp = temp - kk[p]; if (temp <= 0) { break; } } k[i] = p; } } if (k[0] != k[1] && k[0] != k[2] && k[1] != k[2]) { i = 2; } if (i == 2) { break; } } b1 = TestMidManager.GetBlank(k[0]); TestMidManager.ShowQuestionBlank(b1, lblB1, lblB12); b2 = TestMidManager.GetBlank(k[1]); TestMidManager.ShowQuestionBlank(b2, lblB2, lblB22); b3 = TestMidManager.GetBlank(k[2]); TestMidManager.ShowQuestionBlank(b3, lblB3, lblB32); //随机出题 int iUp3 = TestMidManager.CountDesign(); int[] m = new int[2]; m[0] = ran.Next(iDown, iUp3); d1 = TestMidManager.GetDesign(m[0]); TestMidManager.ShowQuestionDesign(d1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); } else { lblTitle.Visible = false; PanelAll.Visible = false; PanelDesign.Visible = false; btnSubmit.Visible = false; btnOk.Visible = false; btnSave.Visible = false; //Response.Write("<script type = 'text/javascript'> alert('你未通过低等级测试,不能进行该等级测试!'); </script>"); RegisterClientScriptBlock("", "<script>alert('你未通过前测或低等级测试,不能进行中级测试!')</script>"); } } } else { Response.Redirect("Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["stuId"] != null) { int score1 = 0; int score2 = 0; string stuId = Session["stuId"].ToString(); stuNews1 = ClassUnitManager.GetStudyingInform(stuId); score1 = stuNews1.pretest; //获取前测分数 score2 = stuNews1.low; //获取初级测试分数 //不是第一次做题,读取断点 if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 1) { BreakingPointRadio bpr = new BreakingPointRadio(); bpr = BreakingPointManager.LoadBreakingPointRadio(Session["stuId"].ToString()); rLow1 = TestLowManager.GetLowRadio(bpr.r1); //读取用户单选题断点记录 TestLowManager.ShowQuestionRadioLow(rLow1, rdolistS1, lblS1); //显示单选题题目 rLow2 = TestLowManager.GetLowRadio(bpr.r2); TestLowManager.ShowQuestionRadioLow(rLow2, rdolistS2, lblS2); rLow3 = TestLowManager.GetLowRadio(bpr.r3); TestLowManager.ShowQuestionRadioLow(rLow3, rdolistS3, lblS3); rLow4 = TestLowManager.GetLowRadio(bpr.r4); TestLowManager.ShowQuestionRadioLow(rLow4, rdolistS4, lblS4); rLow5 = TestLowManager.GetLowRadio(bpr.r5); TestLowManager.ShowQuestionRadioLow(rLow5, rdolistS5, lblS5); BreakingPointJudge bpj = new BreakingPointJudge(); bpj = BreakingPointManager.LoadBreakingPointJudge(Session["stuId"].ToString()); jLow1 = TestLowManager.GetLowJudge(bpj.j1); //读取用户判断题断点记录 TestLowManager.ShowQuestionJudgeLow(jLow1, rdolistJ1, lblJ1); //显示判断题题目 jLow2 = TestLowManager.GetLowJudge(bpj.j2); TestLowManager.ShowQuestionJudgeLow(jLow2, rdolistJ2, lblJ2); jLow3 = TestLowManager.GetLowJudge(bpj.j3); TestLowManager.ShowQuestionJudgeLow(jLow3, rdolistJ3, lblJ3); jLow4 = TestLowManager.GetLowJudge(bpj.j4); TestLowManager.ShowQuestionJudgeLow(jLow4, rdolistJ4, lblJ4); BreakingPointBlank bpb = new BreakingPointBlank(); bpb = BreakingPointManager.LoadBreakingPointBlank(Session["stuId"].ToString()); bLow1 = TestLowManager.GetLowBlank(bpb.b1); //读取用户填空题断点记录 TestLowManager.ShowQuestionBlankLow(bLow1, lblB1, lblB12); //显示填空题题目 bLow2 = TestLowManager.GetLowBlank(bpb.b2); TestLowManager.ShowQuestionBlankLow(bLow2, lblB2, lblB22); bLow3 = TestLowManager.GetLowBlank(bpb.b3); TestLowManager.ShowQuestionBlankLow(bLow3, lblB3, lblB32); BreakingPointDesign bpd = new BreakingPointDesign(); bpd = BreakingPointManager.LoadBreakingPointDesign(Session["stuId"].ToString()); dLow1 = TestLowManager.GetLowDesign(bpd.d1); //读取用户设计题断点记录 TestLowManager.ShowQuestionDesignLow(dLow1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); //显示填空题题目 TestLowManager.ShowRadioLowBreakingpoint(bpr, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5); //显示单选题的断点自选选项 TestLowManager.ShowJudgeLowBreakingpoint(bpj, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4); //显示判断题的断点自选选项 TestLowManager.ShowBlankLowBreakingpoint(bpb, txtB11, txtB21, txtB31); //显示填空题的断点自选选项 } //第一次做题 else if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 0) { //判断前测分数是否到60分 if (score1 >= 60) { //随机出题(加入错题的权重,原先的题号不变,多余的错题作为普通题目放到最后进行随机) long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); int iDown = 1; int iUp = TestLowManager.CountRadioLow(); int[] rr = new int[iUp + 1]; for (int mn = 1; mn <= TestLowManager.CountRadioLow(); mn++) { rr[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Low", "WrongRadio"); iUp = iUp + rr[mn]; } int[] n = new int[5]; while (true) { int i; n[0] = ran.Next(iDown, iUp); n[1] = ran.Next(iDown, iUp); n[2] = ran.Next(iDown, iUp); n[3] = ran.Next(iDown, iUp); n[4] = ran.Next(iDown, iUp); //对随机选出的5个数重映射题号 for (i = 0; i <= 4; i++) { if (n[i] > TestLowManager.CountRadioLow()) { int temp; temp = n[i] - TestLowManager.CountRadioLow(); int p; for (p = 1; p <= TestLowManager.CountRadioLow(); p++) { temp = temp - rr[p]; if (temp <= 0) { break; } } n[i] = p; } } //题目不重复 if (n[0] != n[1] && n[0] != n[2] && n[0] != n[3] && n[0] != n[4] && n[1] != n[2] && n[1] != n[3] && n[1] != n[4] && n[2] != n[3] && n[2] != n[4] && n[3] != n[4]) { i = 4; } if (i == 4) { break; } } rLow1 = TestLowManager.GetLowRadio(n[0]); //获取判断题题目 TestLowManager.ShowQuestionRadioLow(rLow1, rdolistS1, lblS1); //显示判断题题目 rLow2 = TestLowManager.GetLowRadio(n[1]); TestLowManager.ShowQuestionRadioLow(rLow2, rdolistS2, lblS2); rLow3 = TestLowManager.GetLowRadio(n[2]); TestLowManager.ShowQuestionRadioLow(rLow3, rdolistS3, lblS3); rLow4 = TestLowManager.GetLowRadio(n[3]); TestLowManager.ShowQuestionRadioLow(rLow4, rdolistS4, lblS4); rLow5 = TestLowManager.GetLowRadio(n[4]); TestLowManager.ShowQuestionRadioLow(rLow5, rdolistS5, lblS5); //随机出题 int iUp1 = TestLowManager.CountJudgeLow(); int[] jj = new int[iUp1 + 1]; for (int mn = 1; mn <= TestLowManager.CountJudgeLow(); mn++) { jj[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Low", "WrongJudge"); iUp1 = iUp1 + jj[mn]; } int[] j = new int[4]; while (true) { int i; j[0] = ran.Next(iDown, iUp1); j[1] = ran.Next(iDown, iUp1); j[2] = ran.Next(iDown, iUp1); j[3] = ran.Next(iDown, iUp1); //对随机选出的4个数重映射题号 for (i = 0; i <= 3; i++) { if (j[i] > TestLowManager.CountJudgeLow()) { int temp; temp = j[i] - TestLowManager.CountJudgeLow(); int p; for (p = 1; p <= TestLowManager.CountJudgeLow(); p++) { temp = temp - jj[p]; if (temp <= 0) { break; } } j[i] = p; } } if (j[0] != j[1] && j[0] != j[2] && j[0] != j[3] && j[1] != j[2] && j[1] != j[3] && j[2] != j[3]) { i = 3; } if (i == 3) { break; } } jLow1 = TestLowManager.GetLowJudge(j[0]); TestLowManager.ShowQuestionJudgeLow(jLow1, rdolistJ1, lblJ1); jLow2 = TestLowManager.GetLowJudge(j[1]); TestLowManager.ShowQuestionJudgeLow(jLow2, rdolistJ2, lblJ2); jLow3 = TestLowManager.GetLowJudge(j[2]); TestLowManager.ShowQuestionJudgeLow(jLow3, rdolistJ3, lblJ3); jLow4 = TestLowManager.GetLowJudge(j[3]); TestLowManager.ShowQuestionJudgeLow(jLow4, rdolistJ4, lblJ4); //随机出题 int iUp2 = TestLowManager.CountBlankLow(); int[] kk = new int[iUp2 + 1]; for (int mn = 1; mn <= TestLowManager.CountBlankLow(); mn++) { kk[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Low", "WrongBlank"); iUp2 = iUp2 + kk[mn]; } int[] k = new int[3]; while (true) { int i; k[0] = ran.Next(iDown, iUp2); k[1] = ran.Next(iDown, iUp2); k[2] = ran.Next(iDown, iUp2); //对随机选出的3个数重映射题号 for (i = 0; i <= 2; i++) { if (k[i] > TestLowManager.CountBlankLow()) { int temp; temp = k[i] - TestLowManager.CountBlankLow(); int p; for (p = 1; p <= TestLowManager.CountBlankLow(); p++) { temp = temp - kk[p]; if (temp <= 0) { break; } } k[i] = p; } } if (k[0] != k[1] && k[0] != k[2] && k[1] != k[2]) { i = 2; } if (i == 2) { break; } } bLow1 = TestLowManager.GetLowBlank(k[0]); TestLowManager.ShowQuestionBlankLow(bLow1, lblB1, lblB12); bLow2 = TestLowManager.GetLowBlank(k[1]); TestLowManager.ShowQuestionBlankLow(bLow2, lblB2, lblB22); bLow3 = TestLowManager.GetLowBlank(k[2]); TestLowManager.ShowQuestionBlankLow(bLow3, lblB3, lblB32); //随机出题 int iUp3 = TestLowManager.CountDesignlow(); int[] m = new int[2]; m[0] = ran.Next(iDown, iUp3); dLow1 = TestLowManager.GetLowDesign(m[0]); TestLowManager.ShowQuestionDesignLow(dLow1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); } else { lblTitle.Visible = false; PanelAll.Visible = false; PanelDesign.Visible = false; btnSubmit.Visible = false; btnOk.Visible = false; btnSave.Visible = false; //Response.Write("<script type = 'text/javascript'> alert('你未通过前测,不能进行该等级测试!'); </script>"); RegisterClientScriptBlock("", "<script>alert('你未通过前测,不能进行初级测试!')</script>"); } } } else { Response.Redirect("Login.aspx"); } } }
protected override void Seed(LMS.Models.ApplicationDbContext context) { //Update-Database -ConfigurationTypeName LMS.Migrations.User.Configuration if (!context.Roles.Any(r => r.Name == "Teacher")) { var roleStore = new RoleStore <IdentityRole>(context); var roleManager = new RoleManager <IdentityRole>(roleStore); var role = new IdentityRole { Name = "Teacher" }; roleManager.Create(role); } if (!context.Roles.Any(r => r.Name == "Student")) { var roleStore = new RoleStore <IdentityRole>(context); var roleManager = new RoleManager <IdentityRole>(roleStore); var role = new IdentityRole { Name = "Student" }; roleManager.Create(role); } var userStore = new UserStore <ApplicationUser>(context); var userManager = new UserManager <ApplicationUser>(userStore); var user1 = new ApplicationUser { UserName = "******", Email = "*****@*****.**" }; var user2 = new ApplicationUser { UserName = "******", Email = "*****@*****.**" }; userManager.Create(user1, "Test123!"); userManager.Create(user2, "Test123!"); // ClassUnit Seed var klass1 = new ClassUnit { ClassName = "Grund1A" }; var klass3 = new ClassUnit { ClassName = "Grund3A" }; var klass2 = new ClassUnit { ClassName = "Grund5B" }; context.MyClassUnit.AddOrUpdate(c => c.ClassUnitID, klass1); context.MyClassUnit.AddOrUpdate(c => c.ClassUnitID, klass2); context.MyClassUnit.AddOrUpdate(c => c.ClassUnitID, klass3); ApplicationUser user1a = context.Users.FirstOrDefault(u => u.Email == "testLä[email protected]"); if (user1a != null) { userManager.AddToRole(user1.Id, "Teacher"); } ApplicationUser user2a = context.Users.FirstOrDefault(u => u.Email == "*****@*****.**"); if (user2a != null) { userManager.AddToRole(user2.Id, "Student"); } context.SaveChanges(); }
// Update an existing classunit // PUT /api/classunits/ public HttpResponseMessage Put([FromBody] ClassUnit classunit) { Uow.Classunits.Update(classunit); Uow.Commit(); return(new HttpResponseMessage(HttpStatusCode.NoContent)); }