public void setTestsToAssign(string compId, LineIds line, [FromBody]evaluator[] newToDo) { var db = driverLow.create(); var toEvals = AzureData.HumanEval.readAllForLine(db, compId, line).ToArray(); //uzivatele s testem k vyhodnoceni var tests = toEvals.SelectMany(te => { foreach (var st in te.dataObj) st.email = te.email; return te.dataObj; }).ToArray(); //testy k vyhodnoceni if (newToDo.Sum(t => t.num) != tests.Length) throw new Exception("newToDo.Sum(t => t.num) != tests.Length"); var freeTests = tests.Where(t => t.evaluator == null).ToList(); //neprirazene testy //vsichni evaluatori var all = newToDo.Select(e => e.email).Concat(tests.Where(t => t.evaluator != null).Select(t => t.evaluator)).Distinct().ToDictionary(ev => ev, ev => new tempInfo { email = ev, tests = new List<testItem>(), newNum = 0 }); foreach (var newEv in newToDo) all[newEv.email].newNum = newEv.num; foreach (var tst in tests.Where(t => t.evaluator != null)) all[tst.evaluator].tests.Add(tst); //uber testy foreach (var ev in all.Values.Where(e => e.tests.Count() > e.newNum)) { var toDel = ev.tests.Count() - ev.newNum; freeTests.AddRange(ev.tests.Take(toDel)); ev.tests.RemoveRange(0, toDel); } //pridej testy foreach (var ev in all.Values.Where(e => e.tests.Count() < e.newNum)) { var toAdd = ev.newNum - ev.tests.Count(); ev.tests.AddRange(freeTests.Take(toAdd)); freeTests.RemoveRange(0, toAdd); } //kontrola if (freeTests.Count != 0) throw new Exception("freeTests.Count != 0"); //aktualizuj evaluatory HashSet<string> changed = new HashSet<string>(); foreach (var kv in all) foreach (var st in kv.Value.tests) { if (st.evaluator != kv.Key) { changed.Add(st.email); st.evaluator = kv.Key; st.assigned = LowUtils.nowToNum(); } st.email = null; } //save foreach (var toEval in toEvals.Where(t => changed.Contains(t.email))) db.attach(toEval, TableOperationType.Replace); db.SaveChanges(); }
public static string lineToText(LineIds line) { switch (line) { case LineIds.English: return "Angličtina"; case LineIds.German: return "Němčina"; case LineIds.French: return "Francouzština"; default: return "unknown line"; } }
/// <summary> /// Add OrderItem model. /// <param name="orderItem">OrderItem></param> /// <returns>OrderItemListBackOrderRequest</returns> /// </summary> public OrderItemListBackOrderRequest AddOrderItem(OrderItem orderItem) { if (orderItem.LineId > 0) { LineIds.Add(orderItem.LineId); } return(this); }
public evalLineResult getTestsToAssign(string compId, LineIds line) { var db = driverLow.create(); var toEvals = AzureData.HumanEval.readAllForLine(db, compId, line).ToArray().SelectMany(ce => ce.dataObj).ToArray(); var assigned = toEvals.Where(e => e.evaluator != null).GroupBy(e => e.evaluator).ToDictionary(e => e.Key, e => e.Count()); var evaluators = db.compReadForEdit<AzureData.Company_User>(compId).usersObj.Users.Where(u => u.Roles != null && u.Roles.HumanEvalatorInfos != null && u.Roles.HumanEvalatorInfos.Any(he => he.lang == line)).ToArray(); return new evalLineResult { evaluators = evaluators.Select(ev => { int cnt; if (!assigned.TryGetValue(ev.EMail, out cnt)) cnt = 0; return new evaluator { email = ev.EMail, num = cnt }; }).ToArray(), toEvaluateNum = toEvals.Length, }; }
/// <summary> /// Add Line_IDs. /// - lineId: Int /// - Returns: Self /// </summary> public OrderItemListBackOrderRequest AddLineId(int lineId) { LineIds.Add(lineId); return(this); }
public static CourseIds LineIdToCourseId(LineIds crs) { switch (crs) { case LineIds.English: return CourseIds.English; case LineIds.German: return CourseIds.German; case LineIds.Spanish: return CourseIds.Spanish; case LineIds.French: return CourseIds.French; case LineIds.Italian: return CourseIds.Italian; case LineIds.Russian: return CourseIds.Russian; default: return CourseIds.no; } }
public static Langs LineIdToLang(LineIds line) { switch (line) { #region EuroTalk4 case LineIds.Afrikaans: return Langs.af_za; case LineIds.Albanian: return Langs.sq_al; case LineIds.Arabic: return Langs.ar_sa; case LineIds.Armenian: return Langs.hy_am; case LineIds.Assamese: return Langs.as_in; case LineIds.Azerbaijani: return Langs.az_latn_az; case LineIds.Basque: return Langs.eu_es; case LineIds.Bengali: return Langs.bn_in; case LineIds.Portuguese_Brazilian: return Langs.pt_br; case LineIds.Breton: return Langs.br_fr; case LineIds.Bulgarian: return Langs.bg_bg; case LineIds.Bossna: return Langs.bs; case LineIds.French: return Langs.fr_fr; case LineIds.Cantonese: return Langs.zh_hk; case LineIds.Catalan: return Langs.ca_es; case LineIds.Corsican: return Langs.co_fr; case LineIds.Croatian: return Langs.hr_hr; case LineIds.Czech: return Langs.cs_cz; case LineIds.Danish: return Langs.da_dk; case LineIds.Dutch: return Langs.nl_nl; case LineIds.English: return Langs.en_gb; case LineIds.Estonian: return Langs.et_ee; case LineIds.Farsi: return Langs.fa_ir; case LineIds.Finnish: return Langs.fi_fi; case LineIds.Galician: return Langs.gl_es; case LineIds.Georgian: return Langs.ka_ge; case LineIds.German: return Langs.de_de; case LineIds.Greek: return Langs.el_gr; case LineIds.Hausa: return Langs.ha_latn_ng; case LineIds.Hebrew: return Langs.he_il; case LineIds.Hungarian: return Langs.hu_hu; case LineIds.Hindi: return Langs.hi_in; case LineIds.Chinese_Mandarin: return Langs.zh_cn; case LineIds.Icelandic: return Langs.is_is; case LineIds.Igbo: return Langs.ig_ng; case LineIds.Indonesian: return Langs.id_id; case LineIds.Irish: return Langs.ga_ie; case LineIds.Italian: return Langs.it_it; case LineIds.Japanese: return Langs.ja_jp; case LineIds.Khmer: return Langs.km_kh; case LineIds.Kirghiz: return Langs.ky_kg; case LineIds.Korean: return Langs.ko_kr; case LineIds.Spanish: return Langs.sp_sp; case LineIds.Latvian: return Langs.lv_lv; case LineIds.Lithuanian: return Langs.lt_lt; case LineIds.Macedonian: return Langs.mk_mk; case LineIds.Malay: return Langs.ms_my; case LineIds.Malayalam: return Langs.ml_in; case LineIds.Maltese: return Langs.mt_mt; case LineIds.Maori: return Langs.mi_nz; case LineIds.Mongolian: return Langs.mn_mn; case LineIds.Occitan: return Langs.oc_fr; case LineIds.Norwegian: return Langs.nb_no; case LineIds.Pashto: return Langs.ps_af; case LineIds.Persian: return Langs.fa_ir; case LineIds.Polish: return Langs.pl_pl; case LineIds.Portuguese: return Langs.pt_pt; case LineIds.Quechua: return Langs.quz_pe; case LineIds.Romanian: return Langs.ro_ro; case LineIds.Russian: return Langs.ru_ru; case LineIds.Serbian: return Langs.sr_latn_cs; case LineIds.Sesotho: return Langs.nso_za; case LineIds.Slovak: return Langs.sk_sk; case LineIds.Slovenian: return Langs.sl_si; case LineIds.Swahili: return Langs.sw_ke; case LineIds.Swedish: return Langs.sv_se; case LineIds.Thai: return Langs.th_th; case LineIds.Tibetan: return Langs.bo_cn; case LineIds.Tswana: return Langs.tn_za; case LineIds.Turkish: return Langs.tr_tr; case LineIds.Ukrainian: return Langs.uk_ua; case LineIds.Urdu: return Langs.ur_pk; case LineIds.Uzbek: return Langs.uz_latn_uz; case LineIds.Vietnamese: return Langs.vi_vn; case LineIds.Xhosa: return Langs.xh_za; case LineIds.Yoruba: return Langs.yo_ng; case LineIds.Zulu: return Langs.zu_za; #endregion default: return Langs.no; } }
public static HumanEval[] readAllForLine(azure.driverLow db, string compId, LineIds line) { return db.executeQuery(db.keyRangeQuery<HumanEval>(partitionKey(compId), azure.keyLib.createKeyLow(keys(line, null).Take(2)))).ToArray(); }
public static void refreshEvals(azure.driverLow db, string compId, LineIds line, string email, string productId, int testKeyId, AzureData.saveKeyDataObj[] pcEvals) { var res = readOrCreate(db, compId, line, email); //adjust test if (res.dataObj == null) res.dataObj = new List<azure.hmanEvalController.testItem>(); var test = res.dataObj.FirstOrDefault(t => t.productId == productId && t.testKeyId == testKeyId); if (test == null) res.dataObj.Add(test = new azure.hmanEvalController.testItem { productId = productId, testKeyId = testKeyId }); if (test.items == null) test.items = new List<azure.hmanEvalController.exItem>(); //zatrid pcEvals foreach (var eval in pcEvals) { if ((eval.flag & CourseDataFlag.testImpl_result) == CourseDataFlag.testImpl_result) test.flag = eval.flag; else { var item = test.items.FirstOrDefault(it => it.key == eval.key); if (item == null) test.items.Add(item = new azure.hmanEvalController.exItem { key = eval.key, flag = eval.flag }); item.flag = eval.flag; if ((item.flag & CourseDataFlag.needsEval) == 0) test.items.Remove(item); } } if ((test.flag & CourseDataFlag.needsEval) == 0) { if (test.items.Count > 0) throw new Exception("test.items.Count > 0"); res.dataObj.Remove(test); } //empty and attach if (res.isNew()) //new if (res.dataObj.Count == 0) { } else db.attach(res, TableOperationType.Insert); else //old db.attach(res, res.dataObj.Count == 0 ? TableOperationType.Delete : TableOperationType.Replace); }
public static HumanEval readOrCreate(azure.driverLow db, string compId, LineIds line, string email) { var example = new HumanEval(compId, line, email); return db.read(example) ?? example; }
static IEnumerable<object> keys(LineIds line, string email) { yield return new azure.keyLib.constString(typeof(HumanEval).Name.ToLower()); yield return line.ToString(); yield return email; }
public HumanEval(string compId, LineIds line, string email) : this() { this.compId = compId; this.line = line; this.email = email; }
public string[] getExerciseFromTest(string email, string compId, LineIds line, string productId, int testKeyId) { var db = driverLow.create(); var res = AzureData.HumanEval.readOrCreate(db, compId, line, email); if (res.isNew()) return null; var test = res.dataObj.FirstOrDefault(t => t.productId == productId && t.testKeyId == testKeyId); if (test == null) return null; var urls = test.items.Select(it => it.key).ToArray(); if (urls.Length == 0) return null; return urls; }
static void CreateEnglishMap(LineIds line, string basicPath) { ScanDir sd = new ScanDir(); sd.BasicPath = basicPath; sd.FileMask = @"(?i:\.xml)$"; QuestionPool res = new QuestionPool() { Line = line }; res.Pointers = sd.FileName(FileNameMode.RelPath).Select(fn => fn.ToLower()).Where(fn => !fn.StartsWith("map")).Select(fn => createPointer(basicPath, fn)).Where(p => p != null).ToArray(); XmlUtils.ObjectToFile(basicPath + "\\map.xml", res); }
static void CreateElementMap(string id, string title, string basicPath, LineIds line) { basicPath = basicPath + "\\" + id; DBQuestionPool res = new DBQuestionPool() { Title = title, Id = id, BasicPath = basicPath, Line = line, Modules = Directory.EnumerateDirectories(basicPath).Select(d => new dbSkill(Path.GetFileName(d))).Select(s => new DBQuestionPool.Module() { Skill = s.skill, AlowedTimeMinutes = 10, Groups = Directory.EnumerateDirectories(basicPath + "\\" + s.dir).Select(d => new dbGroup(Path.GetFileName(d))).OrderBy(g => g.order).Select(g => new DBQuestionPool.Group() { Order = g.order, SelectNum = 1, Pointers = Directory.EnumerateFiles(basicPath + "\\" + s.dir + "\\" + g.dir).Select(f => f.Substring(basicPath.Length + 1).Replace('\\', '/')).ToArray() }).ToArray() }).ToArray() }; XmlUtils.ObjectToFile(basicPath + "\\map.xml", res); }