วันอังคารที่ 31 มีนาคม พ.ศ. 2558
C# Calculate Grade T-Score (Using List Object)
ไม่มีความคิดเห็น:
Posted by
Aagkasit Tontan
at
21:23
Labels:
c#,
Grade Calculator,
Grade Calculator Custom,
Grade Calculator Dynamic,
T-Score
สมมุติ มีคะแนนนักเรียนดังนี้ คนที่ 1 มี 1 คะแนน คนที่ 2 มี 2 คะแนน คนที่ 3 มี 4 คะแนน คนที่ 4 มี 6 คะแนน คนที่ 5 มี 8 คะแนน คนที่ 6 มี 9 คะแนน ให้ตัดเกรดของนักเรียนเหล่านี้ โดยวิธีตัดเกรดด้วย T-Score ที่มาของโจทย์ : http://www.stvc.ac.th/elearning/stat/csu3.htmlใช้การคำนวณ SD จากบทความที่แล้ว C# Calculate Standard Deviation (Using List Object)
class Program
{
static void Main(string[] args)
{
//Ex2.จากข้อมูลต่อไปนี้จงหาส่วนเบี่ยงเบนมาตรฐาน 1, 2, 4, 6, 8, 9
List listScore = new List();
listScore.Add(1d);// 1, 2, 4, 6, 8, 9
listScore.Add(2d);
listScore.Add(4d);
listScore.Add(6d);
listScore.Add(8d);
listScore.Add(9d);
//1.การหาส่วนเบี่ยงเบนมาตรฐาน(S.D.) ในกรณีข้อมูลไม่ได้มีการแจกแจงความถี่
StandardDeviation sd = new StandardDeviation(listScore);
//จาก สมการ T = 10Z + 50
//1 หา z = (14- ค่าเฉลี่ยเรขาคณิต ) / SD
double sd_ = sd.Calculator();//3.22
double xbar = average(listScore);//1.5
for (int i = 0; i < listScore.Count; i++) {
double z = (listScore[i] - xbar) / sd_; //14
//Console.WriteLine("Z Score : " + z);
double t = 10 * z + 50;
Console.WriteLine(listScore[i]+" To T Score : " + t);
}
Console.ReadLine();
}
static double average(List listScore)
{
double sum = 0.0d;
int n = listScore.Count;
for (int i = 0; i < listScore.Count; i++)
{
sum = sum + listScore[i];
}
double result = sum / n;
return result;
}
}
รันแล้วเราก็จะได้ คะแนนนักเรียนออกมาจากนั้นเอาโปรแกรมตัดเกรดจากบทความ c# Grade Calculator (Using List Object) มาใช้
static void Main(string[] args)
{
//Ex2.จากข้อมูลต่อไปนี้จงหาส่วนเบี่ยงเบนมาตรฐาน 1, 2, 4, 6, 8, 9
List listScore = new List();
listScore.Add(1d);// 1, 2, 4, 6, 8, 9
listScore.Add(2d);
listScore.Add(4d);
listScore.Add(6d);
listScore.Add(8d);
listScore.Add(9d);
//ตั้งค่าเกรด
List ls = new List();
ls.Add(new Grades(49f, "F"));
ls.Add(new Grades(49.5f, "D"));
ls.Add(new Grades(55f, "D+"));
ls.Add(new Grades(60f, "C"));
ls.Add(new Grades(65f, "P"));
ls.Add(new Grades(70f, "B"));
ls.Add(new Grades(75f, "B+"));
ls.Add(new Grades(80f, "A"));
//1.การหาส่วนเบี่ยงเบนมาตรฐาน(S.D.) ในกรณีข้อมูลไม่ได้มีการแจกแจงความถี่
StandardDeviation sd = new StandardDeviation(listScore);
//จาก สมการ T = 10Z + 50
//1 หา z = (14- ค่าเฉลี่ยเรขาคณิต ) / SD
double sd_ = sd.Calculator();//3.22
double xbar = average(listScore);//1.5
for (int i = 0; i < listScore.Count; i++)
{
double z = (listScore[i] - xbar) / sd_; //14
//Console.WriteLine("Z Score : " + z);
double t = 10 * z + 50;
//Console.WriteLine(listScore[i] + " To T Score : " + t);
Console.WriteLine(listScore[i] + " To T Score : " + t + " -> grade : " + CalGrade((float)t, ls));
}
Console.ReadLine();
}
จะได้ผลเกรดดังนี้อยากได้โค้ดทั้งหมด ติดต่อผมทางได้นี้นะครับ (ไม่มีค่าใช้จ่ายใดๆแค่อยากรู้ว่ามีคนเอาใช้จริงๆหรือเปล่า)
Facebook: https://www.facebook.com/DotNetUnderLine
E-mail: agkasit.ecp7@gmail.com
วันพฤหัสบดีที่ 26 กุมภาพันธ์ พ.ศ. 2558
elfinder Browser file use getFileCallback [worked]
elfinder Browser file use getFileCallback
//html
//script
$('#select-button').click(function () {
var f = $('#elfinder').elfinder({
url: '/connector', // connector route defined in \App_Start\RouteConfig.cs
lang: 'en',
onlyMimes: ["image"], // display all images
customData: { folder: "teacher", subFolder: null },
height: 490,
docked: false,
dialog: { width: 400, modal: true },
closeOnEditorCallback: true,
getFileCallback: function (url) {
console.log(url.url);
$('#new_file').val(url.url);
// CLOSE ELFINDER HERE
$('#elfinder').remove(); //remove Elfinder
location.reload(); //reload Page for second selection
}
}).elfinder('instance');
});
});
link: http://stackoverflow.com/questions/20400817/close-elfinder-programatically-after-file-selection?answertab=active#tab-top
วันจันทร์ที่ 16 กุมภาพันธ์ พ.ศ. 2558
c# Grade Calculator (Using List Object)
ไม่มีความคิดเห็น:
Posted by
Aagkasit Tontan
at
02:37
Labels:
c#,
Grade Calculator,
Grade Calculator Custom,
Grade Calculator Dynamic,
List,
List Object
//Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GradeCalculatorUsingListObject
{
class Program
{
static void Main(string[] args)
{
//add list Grade
List ls = new List();
ls.Add(new Grades(49f, "F"));
ls.Add(new Grades(49.5f, "D"));
ls.Add(new Grades(55f, "D+"));
ls.Add(new Grades(60f, "C"));
ls.Add(new Grades(65f, "P"));
ls.Add(new Grades(70f, "B"));
ls.Add(new Grades(75f, "B+"));
ls.Add(new Grades(80f, "A"));
//
//float point = 49f;
Console.WriteLine("49.5f : grade : " + CalGrade(49.5f, ls));
Console.WriteLine("0 : grade : " + CalGrade(0, ls));
Console.WriteLine("72 : grade : " + CalGrade(72, ls));
Console.WriteLine("70 : grade : " + CalGrade(70, ls));
Console.WriteLine("43 : grade : " + CalGrade(43, ls));
Console.WriteLine("28 : grade : " + CalGrade(28, ls));
Console.WriteLine("97 : grade : " + CalGrade(97, ls));
Console.WriteLine("23 : grade : " + CalGrade(23, ls));
Console.WriteLine("84 : grade : " + CalGrade(84, ls));
Console.WriteLine("64 : grade : " + CalGrade(64, ls));
Console.WriteLine("72 : grade : " + CalGrade(74, ls));
Console.ReadLine();
}
public static string CalGrade(float point, List list)
{
//int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
int current = 0;
int next = 0;
for (int write = 0; write < list.Count - 1; write++)
{
current = write;
next = current + 1;
//55 <= 56 <= 60
if (list[current].score <= point && point <= list[next].score)
{
if (list[current].score >= point)
{
return list[current].grade;
}
else if (list[next].score <= point)
{
return list[next].grade;
}
else if (list[next].score >= point)
{
return list[current].grade;
}
}
else if (list[current].score > point)
{
return list[current].grade;
}
else if (list[current].score <= point && point >= list[next].score)
{
if (current == (list.Count - 2))
{
return list[current + 1].grade;
}
}
}
return null;
}
public class Grades
{
public float score { set; get; }
public string grade { set; get; }
public Grades(float score, string grade)
{
this.score = score;
this.grade = grade;
}
}
}
}
download code full : https://www.dropbox.com/s/1e41ezbnxl0i5r0/GradeCalculatorUsingListObject.rar?dl=0
Asp.net Mvc4 Could not load file or assembly 'WebGrease"
ไม่มีความคิดเห็น:
Posted by
Aagkasit Tontan
at
00:38
Labels:
Asp.net Mvc4,
Could not load file or assembly
Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
answer worked : http://stackoverflow.com/questions/19851912/could-not-load-file-or-assembly-webgrease-version-1-5-1-25624-culture-neutral
answer worked : http://stackoverflow.com/questions/19851912/could-not-load-file-or-assembly-webgrease-version-1-5-1-25624-culture-neutral
วันจันทร์ที่ 28 เมษายน พ.ศ. 2557
How to Fix HTTP Error 500.21 - Internal Server Error
มีขั้นตอนดังนี้
ที่มา : http://www.codeproject.com/Questions/412385/i-get-HTTP-Error-500-21-when-i-access-a-web-site-p
- เปิด command prompt ขึ้นมา
- จากนั้นก็นำคำสั่งด้านล่างนี้ไปวางแล้ว กด Enter
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -iหรือ
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
ที่มา : http://www.codeproject.com/Questions/412385/i-get-HTTP-Error-500-21-when-i-access-a-web-site-p
วันพฤหัสบดีที่ 24 เมษายน พ.ศ. 2557
วันพุธที่ 18 ธันวาคม พ.ศ. 2556
[asp.net] set required field validator with DropDownList
ss
code:
<asp:DropDownList ID="DropDownList_newProduct" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList_newProduct_SelectedIndexChanged" Width="217px">
<asp:ListItem Selected="True" Value="-1" Text="–กรุณาเลือก–"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_DropDownList_newProduct" runat="server"
CssClass="field-validation-error" ErrorMessage="Please enter!" ControlToValidate="DropDownList_newProduct" InitialValue="-1"/>
สมัครสมาชิก:
ความคิดเห็น (Atom)
