//PatchUserComp public static async Task <UserCompetence> PatchUserCompetence(UserCompetence usercompetence, bool isTeacher) { string payload; if (isTeacher) { payload = JsonConvert.SerializeObject(new { isValidated = usercompetence.isValidated, teacherPercent = usercompetence.teacherPercent }); } else { payload = JsonConvert.SerializeObject(new { userPercent = usercompetence.userPercent }); } var request = new HttpRequestMessage(HttpMethod.Put, "http://" + host + "/usercompetences/" + usercompetence._id); var stringContent = new StringContent(payload, Encoding.UTF8, "application/json"); request.Content = stringContent; var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); response.EnsureSuccessStatusCode(); var usercomp = await response.Content.ReadAsAsync <UserCompetence>(); return(usercomp); }
public Form3(Competence competence, UserCompetence usercompetence, User user) { this.resources = competence.ressources; this.usercompetence = usercompetence; this.user = user; InitializeComponent(); //Affichage HideRessources(); ShowEvaluation(); //Informations labelCompetence.Text = competence.name; studentnumber = usercompetence.userPercent; labelEvaluationNumberStudent.Text = studentnumber.ToString() + "%"; teachernumber = usercompetence.teacherPercent; labelEvaluationNumberTeacher.Text = teachernumber.ToString() + "%"; //Bouton de validation de compétence if (this.usercompetence.isValidated) { buttonValidCompetence.BackColor = Color.ForestGreen; buttonValidCompetence.Text = "Invalider la compétence"; if (!(this.user is Teacher)) { buttonValidCompetence.Text = "Validée"; } } else { buttonValidCompetence.BackColor = Color.Firebrick; buttonValidCompetence.Text = "Valider la compétence"; if (!(this.user is Teacher)) { buttonValidCompetence.Text = "En attente de validation"; } } if (this.user is Teacher) { trackBarStudent.Value = Convert.ToInt32(teachernumber); } else { trackBarStudent.Value = Convert.ToInt32(studentnumber); buttonValidCompetence.Enabled = false; } this.usercompetence.doclist.ForEach((elem) => { listBoxProof.Items.Add(elem.link); }); //Ajout des ressource dans listBoxResources foreach (Resource res in competence.ressources) { listBoxResources.Items.Add(res.title); } //Pour éviter probleme si une listbox est vide if (resources.Count != 0) { listBoxResources.SelectedIndex = 0; } }