hello this is the piece code (below) i want to calculate progress of chapter and subject...in this code use random method...but i want do manual...plz help..and give me sample code if possible....
thank u
public ActionResult GetSubjectProgress(string id)
{Guid stdid = new Guid(id);
var subjects = from s in db.Subjects
where s.Standard == stdid
select s;
List
Random rnd = new Random();
foreach (Subject s in subjects)
{
SubjectProgress subProg = new SubjectProgress();
subProg.id = s.Id;
subProg.name = s.Name;
subProg.chapters = new List
foreach (Chapter c in s.Chapters)
{
ChapterProgress chptProg = new ChapterProgress();
chptProg.id = c.Id;
chptProg.name = c.Name;
chptProg.progress = rnd.Next(1, 100);
subProg.chapters.Add(chptProg);
}
subProg.progress = rnd.Next(1, 100);
subjectPropgress.Add(subProg);
}
return View(subjectPropgress);
}
PrakashPosted May 22, 2015, 7:02 AM
//string userId = "FAA81C69-2D14-49EA-8C4C-6A440B2D78F6"; // get current user
var subjects = from s in db.Subjects
where s.Standard == stdid
select s;
List
//Random rnd = new Random();
foreach (Subject s in subjects)
{
SubjectProgress subProg = new SubjectProgress();
subProg.id = s.Id;
subProg.name = s.Name;
subProg.chapters = new List
foreach (Chapter c in s.Chapters)
{
ChapterProgress chptProg = new ChapterProgress();
chptProg.id = c.Id;
chptProg.name = c.Name;
var questions = from x in db.Questions
where x.Chapter.Equals(chptProg.id)
select x;
var que = questions.Count();
var readQuestions = from y in db.UserProgresses
where y.Chapter.Equals(chptProg.id)
select y.ReadQuestions;
List
foreach (var rdq in readQuestions)
{
string[] rdqGuids = rdq.Split('#');
//foreach (string rdqGuid in rdqGuids)
//{
// Guid tempGuid = new Guid(rdqGuid);
// var qu = from x in db.Questions
// where x.Id.Equals(tempGuid)
// select x;
// readQuestionGuid.Add(qu.ToList
var readq = rdqGuids.Count();
chptProg.progress = (readq / que) * 100;
}
subProg.chapters.Add(chptProg);
}
//subProg.progress = readq.Next(1, 100);
subjectPropgress.Add(subProg);
}
ViewBag.SubjectProgress_VB = subjectPropgress;
return View();
}
PrakashPosted May 22, 2015, 6:29 AM
Afzaal Ahmad ZeeshanPosted May 22, 2015, 5:06 AM
PrakashPosted May 22, 2015, 5:00 AM
Afzaal Ahmad ZeeshanPosted May 22, 2015, 4:44 AM