badges / achievements [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i'm looking to implement a similar thing to stackoverflow badges. you could also equate them to achievements in games.
but am not sure how to design the database/code/tracking for them.
i get what i should do for badges such as:
Altruist × 1456 First bounty you manually awarded on another person's question
because they are a one time event, but how to handle others such as:
Analytical × 16389 Visited every section of the FAQ
Electorate × 1783 Voted on 600 questions and 25% or more of total votes are on questions
Outspoken × 188 Posted 10 messages in chat that were starred by 10 different users
etc...
how to handle them, how to keep track of progress for each, etc... is there a tutorial or something that can help me figure out a design pattern for them?

For the given examples, there are essentially two mechanisms you are going to need.
I don't know how it's done on SO, this is just a suggestion of a solution.
Let's look at 'Analytical' first. You are going to have to record by means of a simple flag when a user visits a particular area in the FAQ. Let's envisage a DB table with a field for each FAQ section and a user ID. This starts off as "N" (or 0, or however you want to represent your flag). When a user visits that area, you call code to flip that field to "Y". When all fields are "Y" then you can award that badge.
As for 'electorate' and 'Outspoken', you can retrieve this information by means of a query on your existing data, assuming the queries themseves are not too burdensome. You are going to need to consider when to run these checks. This essentially boils down to two options.
1) When the an action is performed that might get a badge awarded (i.e. visit section of FAQ, Vote on a Question, Question starred by someone else)
2) Periodically (hourly, daily, etc) run a check for all your badges against current data.
Bear in mind that badges are one-way in Stackoverflow, so if you are wanting to be equivalent then you don't have to consider logic to 'un-award' badges.

Related

Porter stemmer algorithm in information-retrieval [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to create simple search engine for my application. Let's simplify it to the following: we have some texts (a lot) and i need to search and show relevant results.
I've based on this great article extend some things and it works pretty well for me.
But i have problem with stemming words to terms. For example words "annotation", "annotations" etc. will be stemmed to "annot", but imagine you try search something, and you will see unexpected results:
"anno" - nothing
"annota" - nothing
etc.
Only word "annot" will give relevant result. So, how should i improve my search to give expected results? Because "annot" contains "anno" and "annota" is slightly more than "annot". Using contains all the time obviously isn't the solution
If in first case i can use some Ternary search tree, in second case i don't know what to do.
Any ideas would be very helpful.
UPDATE
oleksii has pointed me to n-grams here, which may works for me, but i don't know how to properly index n-grams.
So the Question:
Which data structure would be the best for my needs
How properly index my n-grams
Stemming perhaps isn't much relevant here. Stemming will convert a plural to a singular form.
Given you have a tokeniser, a stemmer and a cleaner (to remove stop words, perhaps punctuation and numbers, short words etc) what you are looking at is a full-text search. I would advice you to get an off-the-shelf solution (like Elasticsearch, Lucene, Solr), but if you fancy a DIY approach I can suggest the following naive implementation.
Step 1
Create a search-orientated tokeniser. One example would be an n-gram tokeniser. It will take your word and split into the following sequences:
annotation
1 - [a, n, o, t, a, i]
2 - [an, nn, no, ot, ...]
3 - [ann, nno, not, ota, ...]
4 - [anno, nnot, nota, otat, ...]
....
Step 2
Sort n-grams for more efficient look-up
Step 3
Search n-grams for exact match using binary search

figuring out whether submissions were made on time or late [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a set of requirements which I can't yet decide the best way to implement.
I have a table in the database for submissions, including the date a submission was made (Submission.Name, Submission.Date).
Each year, we want the user to make 2 submissions, one by April 1, and one by December 1
The requirements indicate that we show the user a notification on the home page, which can be one of three:
- submission completed for current period (green)
- submission pending by end of current period (blue)
- submission outstanding from previous period (red)
There is one additional rule which is that if a submission is overdue by more than 3 months, then
we should display the submission pending notification (blue) for the upcoming deadline instead of the red one.
The problem is when trying to determine if a submission that is in the first 3 months of the current period should be counted towards the current period or if it was just a late submission for the period before (which would have been overdue).
Checking previous periods for whether or not they were overdue might also require checking their previous
period ...etc. making it more complicated than I hoped.
The options so far look like either to query the table using EntityFramework to calculate the state, or to implement this logic in code, however, both options appear non-trivial so far.
Can anyone see a better approach to this kind of problem? Or does anyone have any Linq tricks to do this in one shot?
Edit: we want 2 submissions per year, but the user is free to make more than 1 submission per period, and hence why it's difficult trying to interpret how the submissions correlate back to overdue periods
Thanks in advance
Can't you just add a new field to your database, "LastSubmissionPeriod" and set it to
April 1, or December 1 so you know which period has been filled?

Creating an application for Math Practice with ASP.NET [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying a develop a Math Practice web application using ASP.NET (not MVC), which allows Users to perform Multiple choice or simply type an answer, click a button and see answer.
The first idea that comes to mind is simply get permission to use a book, grab all the questions and answers using a DB and display the right answer. But how would I display the answer or the show me how the answer was derived.
My confusion is; how does this work?:
Do I have to write all the formulas and answer myself?
Are there programs for this?
I do not even know where to start.
What I would like to do is have the user select an answer, if the answer is wrong, they can click the show me button.
I am looking to either write this in C#, Visual Basic using JQuery on the front end.
Just need some direction.
Thanks my friends.
When I was in college I had to do something very similar.
What I did is stored expressions 4 + 5; 1 * 6 in database and then pushed those expressions to evaluate on run-time because it is pretty easy in C#.
It takes expression from database 2 + 2
It evaluates the expression on run-time producing result 4
You get your result and show it to user or do whatever with it
More info on how exactly to do that: http://www.c-sharpcorner.com/UploadFile/mgold/CodeDomCalculator08082005003253AM/CodeDomCalculator.aspx
I don't think you need to evaluate a stored expression. Since you just want the user to enter multiple choice or the answer itself, just set up your database as follows:
QuestionAnswers:
ID (uniqueidentifier) (primary)
QuestionText (varchar)
QuestionAnswer (varchar)
ShowMeHowEquation (varchar)
Then, display the ShowMeHowEquation via jQuery like so:
Show Me How
<div class="showMeHowEquation">Database driven contents here...</div>
<script>
$(document).ready(function() {
$('.showMeHow')click(function() {
$(this).next('.showMeHowEquation').slideDown();
});
});
</script>

How do I track a repeating calendar event in C# / SQL Server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events.
What is the best way to handle tracking this event that can repeat?
For example: Should the event be stored once in the database and projected out / repeated several times in the display code? Should the event be stored several times and then just rendered?
I did something like this before and I based my schema off of SQL Servers sysschedules table.
http://technet.microsoft.com/en-us/library/ms178644.aspx
The schema linked above will allow you to store the schedule for a job (event). Then you can calculate what dates the event occurs on based off of the schedule. This may be a lengthy calculation, so I would try to cache that result somewhere.
I think it depends on type of event it is. Is it like Christmas where once it comes along and happens you really aren't interested in it until the next occurrence? Or is it a task like, "Make sure I call my mom every month", where if it happens and you missed it you wouldn't want it to go away?
One way I recently implemented the latter was to have a record that had next_occurrence (date), reoccurence_period (weekly, monthly, yearly, etc) columns. So that as the next occurence approched it would show up in the list. Once it passed the list item would have a recycle icon that once pressed would update the record to the next future occurence.
Again, i'm not sure if this applies to your situation, but it worked well for mine.

What is the best way to represent a large field of objects while using minimal resources? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
all I am looking to develop a project in unity, it is for android! I was wondering if I could get some clarity on a few things. My problem involves me trying to creating a universe of stars, 150,000 individual stars to be exact, granted there would only be a certain percentage in view at any one time. What is the most efficient structure for being able to convince the user of a realistic environment while keeping the overhead to a minimum since it will be on a phone?
What type of objects do I want to use to represent the masses of stars vs. the likes of stars in close proximity that require finer details?
What sort of threading structures should I consider while planning this project?
How easily does a project port from unity to android, in such scenarios?
Any help is much appreciated as I am looking to better develop with unity, cheers
I would suggest not tracking all 150,000 stars, but only the ones that are in view. When the field of view changes, use a random number generator to define the stars that have just entered it, and drop from memory the ones that have left. To preserve consistency, you might want to retain the stars for a short period around the current field of view, if the user can do rapid switches in direction.
As for threading, that's less a function of the number of stars you are tracking, and more a function of what it is that you are doing with them - something you didn't mention.
1) This question is mainly a game development question and not unity regarding. I just point you in the direction, as a complete answer would be to much. Normally if you need to know where you are in a 3D scene with infinite objects or close (150k is close), you would use a octree for orientation. Constructed like a map, each node of the tree points a direction (West, South, Nord, East, NNW, ...) Then you each of your stars gets 1 node, and you can calculate what is where and how much do you want to see. More information can be found on google. (Quite complicated topic jfyi)
2) Dedicated to 1) with a mix of entity/component design. You will know what I mean after 1) is clear to you.
3) Absolutly Multithreaded Asynchron. 1 Thread Update, 1 Thread Draw, Few Worker Threads (position, ...)
4) The port of Unity Engine is actually working really good. Of course you should have an android peripherial to test and debug on, but most of the time, it will work for you.

Categories