public static List <int[]> DBCountItemGroupByModule(Level lv) { IUx[] IUs_by_Lv = MultiChoiceItem.GetIUs(lv); int[] n_difficultItems = new int[IUs_by_Lv.Length]; int[] n_allItems = new int[IUs_by_Lv.Length]; int j = -1; foreach (IUx i in IUs_by_Lv) { n_allItems[++j] = DBConnect.Count("sqz_question", "id", "moid=" + (int)i + " AND del=0"); if (n_allItems[j] < 0) { n_allItems[++j] = 0; } n_difficultItems[j] = DBConnect.Count("sqz_question", "id", "moid=" + (int)i + " AND diff=1 AND del=0"); if (n_difficultItems[j] < 0) { n_difficultItems[j] = 0; } } List <int[]> n = new List <int[]>(); n.Add(n_allItems); n.Add(n_difficultItems); return(n); }
public List <QuestSheet> GenQPack3(int n, int[] vn, int[] vndiff) { //string emsg; Random rand = new Random(); List <QuestSheet> l = new List <QuestSheet>(); QuestSheet qs0 = new QuestSheet(); //qs0.bAlt = bAlt; int j = -1; foreach (IUx i in MultiChoiceItem.GetIUs(Lv)) { ++j; if (qs0.DBSelect(rand, i, vn[j] - vndiff[j], Difficulty.Easy)) { //WPopup.s.ShowDialog(emsg); return(new List <QuestSheet>()); } if (qs0.DBSelect(rand, i, vndiff[j], Difficulty.Difficult)) { //WPopup.s.ShowDialog(emsg); return(new List <QuestSheet>()); } } while (0 < n) { --n; QuestSheet qs = qs0.RandomizeDeepCopy(rand); qs.Lv = Lv; if (!qs.UpdateCurQSId())//todo: better error handle { Sheets.Add(qs.uId, qs); l.Add(qs); } } if (DBIns(mDt, l) == null) { return(l); } return(new List <QuestSheet>()); }
public List <int[]> CountItemGroupByModule() { IUx[] IUs_by_Lv = MultiChoiceItem.GetIUs(Lv); int[] n_difficultItems = new int[IUs_by_Lv.Length]; int[] n_allItems = new int[IUs_by_Lv.Length]; foreach (MultiChoiceItem i in Questions) { int module; switch (i.mIU) { case IUx._7: module = 0; break; case IUx._8: module = 1; break; case IUx._9: module = 2; break; default: module = (int)i.mIU; break; } ++n_allItems[module]; if (i.IsDifficult) { ++n_difficultItems[module]; } } List <int[]> n = new List <int[]>(); n.Add(n_allItems); n.Add(n_difficultItems); return(n); }
public List <QuestSheet> Genegrate2(int n, int[] vn, int[] vndiff) { List <QuestSheet> l = new List <QuestSheet>(); int i; for (i = 0; i < n; ++i) { l.Add(new QuestSheet()); } //foreach (QuestSheet qs in l) // qs.bAlt = bAlt; i = 0; Random rand = new Random(); foreach (IUx iu in MultiChoiceItem.GetIUs(Lv)) { // QuestSheet qs0 = new QuestSheet(); //qs0.bAlt = bAlt; qs0.DBSelect(iu, Difficulty.Easy); // foreach (QuestSheet qs in l) { List <MultiChoiceItem> vq = qs0.ShallowCopy(); int ni = vn[i] - vndiff[i]; while (0 < ni) { int idx = rand.Next() % ni; qs.Add(vq.ElementAt(idx).DeepCopy()); vq.RemoveAt(idx); --ni; } } // qs0 = new QuestSheet(); //qs0.bAlt = bAlt; qs0.DBSelect(iu, Difficulty.Difficult); // foreach (QuestSheet qs in l) { List <MultiChoiceItem> vq = qs0.ShallowCopy(); int ni = vndiff[i]; while (0 < ni) { int idx = rand.Next() % ni; qs.Add(vq.ElementAt(idx).DeepCopy()); vq.RemoveAt(idx); --ni; } } // ++i; } List <int> eidx = new List <int>(); i = -1; foreach (QuestSheet qs in l) { qs.Lv = Lv; qs.Randomize(rand); if (!qs.UpdateCurQSId())//todo: better error handle { Sheets.Add(qs.uId, qs); } else { eidx.Add(++i); } } foreach (int idx in eidx) { l.RemoveAt(idx); } if (DBIns(mDt, l) == null) { return(l); } return(new List <QuestSheet>()); }