How do I create a new collection in VBS? [duplicate] - arraylist

This question already has answers here:
Lists in VBScript
(3 answers)
Closed 4 years ago.
I am trying to create an empty collection in VBS for xDX Designer. How do I create a collection object from scratch? I'm not interested in a dictionary, which is what I'm seeing others suggesting people use when I search the Internet.
Edit:
To the down-voters and people saying another topic answers my question, I am asking a different, though directly-related, question than that topic. A person might not know they are looking for a "list" (not a VBS object/type), as asked about in that question. In my case, I only knew I wanted a Collection). The answer is contained in that other topic, but that question/answer doesn't show up when you search for my question. This is a legitimate new question, though an answer can be found elsewhere in another line of questioning.

I did more research and found out that "Collection" is not enough detail, and that there are several classes of Collection. What I'm used to dealing with are of the ArrayList class, and that's what I'm looking for. So, one answer is:
Dim objColl
Set ojbColl = CreateObject("System.Collections.ArrayList")

Related

I want to create a quiz module. Which kind of database I should use SQL(Postgres) Or NoSQL(MongoDB)

I want to create a quiz module.
It will have tables like quiz details, quiz question and quiz answer.
Which kind of database I should use SQL(Postgres) Or NoSQL(MongoDB).
If NoSQL joins will be the problem then I have to store question and answers in one collection.
To keep question and answers (options) in the same collection is good approach?
For Quiz module, You will not get concurrent update\delete request for the same row. so i suggest to use NoSQL.
For NoSQL, you can use Question module as a separate collection and answer Collection with reference of Question's object_id. so structure will be normalized in good way.

How to programatically pickup list items from a word file and generate few others?

I don't know much MS Office VBA. I have tons (literally) of quiz questions in word files.
Task is to create question papers for students. Word file contains 900 quiz questions categorized chapter wise. Here is the structure of a word file:
H1: Chapter Name
H2: Level-1 questions
li: Questsions (numbered list)
H3: Answer key to Level-1 questions
li: Answers to level-1 questions (numbered list)
H2: Level-2 questions
H3: Answer key to level-2 questions
li: Answers to level-2 questions (numbered list)
H1: Another Chapter Name
...
...
I want to generate tests (other word files) randomy from my question bank. Few conditions are:
At least 1 question must be picked from each chapter and each level.
The question that is already picked must not be picked into any other test.
Also the answer key must be generated for that generated test.
Question:
Is it too much to expect from Office VBA? or can it be done?
How to do it? What all things do I need to look into?
I've no clue about what to do or how to proceed.
To be honest... using VBA for MS Word it would be torture... ;(
There are more efficient tools... You need to have a database for storing questions, answers of users, and correct answers. Then you need to write application which provides pseudo-random lottery system (see second condition: The question that is already picked must not be picked into any other test.)
Sample code:
Quiz Engine powered by Azure cloud
Online Quiz
Of course, you can treat MS Word document as a "database", but the code implementation would be very difficult. I see it in that way:
read paragraphs one by one
detect formatting
if formatting is Header 1 then add text to the collection (alternatively array or Dictionary) of chapters
if formatting is Header 2 then add text to the collection of questions
and so on... for the answers and correct answer
loop through the collection of chapters and randomly choose the question
save the chapter and question into other file untill the count of questions is not reached
return to point no. 3 till the count of quizes/exams is not reached
Conclusion: forget about VBA, choose .NET programming language (C#, VB.NET) or use free online solutions (for example: The internet quiz database).

Alphabetizing strings in an array [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to sort a NSArray alphabetically?
Hey I've looked all over this site and google for the answer to my question. I'm very new to iPhone programming and I'm figuring this question should be fairly easy to answer. In my app, I have an array that is filled with strings. I display the array in a UITableView with each string in its own cell. However, the strings are placed in a non-organized manner. Is there a way to organize an array's strings by alphabetizing the strings? ANY help is GREATLY appreciated. Thanks in advance.
In the future, post the code you having trouble with. Your question is too vague to answer, as written. But your comment fills in enough information to imply that you are trying to sort a mutable array.
For that, you can use any of the NSMutableArray sorting methods;
– sortUsingDescriptors:
– sortUsingComparator:
– sortWithOptions:usingComparator:
– sortUsingFunction:context:
– sortUsingSelector:
Take your pick as any one of them will sort the array itself (and not produce a new array).

Best practices for configuring a Solr schema

I'm currently configuring my schema.xml file and trying to figure out what's the best way to set up my documents. I use a RMDBS and thus many objects are relational.
Take this site for instance; a document typically consists of a question, followed by 0 or more answers. Say you'd want to set up fields for this, you would have to declare all question and answer fields in the same document, the way I see it. But given the fact that there can be more than one answer, you would have to create a document for each answer. So that means each question and each answer is stored in a separate document, which contains fields for both.
I don't see a different approach for this kind of problem, however I am relatively new to Solr and document DB's, so I may be wrong.
In short: what are the best practices if I would implement such a schema?
Another way to do it would be to have a question field and a multi-valued field for answers and have them in the same document. This is probably the best way to start unless you have specific requirements that favor the document-per-answer approach.
For example, if you needed to match individual answers as stand-alone search results, you may get better results and performance with the document-per-answer approach, as the "answer" documents will be scored, ranked and loaded in isolation.
But that would be an unconventional use of this type of data. Normally when you search a site like stack overflow, you are searching for a question and set of answers that cover a particular topic, so having everything in one document makes more sense.

What mysql database tables and relationships would support a Q&A survey with conditional questions? [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'm working on a fairly simple survey system right now. The database schema is going to be simple: a Survey table, in a one-to-many relation with Question table, which is in a one-to-many relation with the Answer table and with the PossibleAnswers table.
Recently the customer realised she wants the ability to show certain questions only to people who gave one particular answer to some previous question (eg. Do you buy cigarettes? would be followed by What's your favourite cigarette brand?, there's no point of asking the second question to a non-smoker).
Now I started to wonder what would be the best way to implement this conditional questions in terms of my database schema? If question A has 2 possible answers: A and B, and question B should only appear to a user if the answer was A?
Edit: What I'm looking for is a way to store those information about requirements in a database. The handling of the data will be probably done on application side, as my SQL skills suck ;)
Survey Database Design
Last Update: 5/3/2015
Diagram and SQL files now available at https://github.com/durrantm/survey
If you use this (top) answer or any element, please add feedback on improvements !!!
This is a real classic, done by thousands. They always seems 'fairly simple' to start with but to be good it's actually pretty complex. To do this in Rails I would use the model shown in the attached diagram. I'm sure it seems way over complicated for some, but once you've built a few of these, over the years, you realize that most of the design decisions are very classic patterns, best addressed by a dynamic flexible data structure at the outset.
More details below:
Table details for key tables
answers
The answers table is critical as it captures the actual responses by users.
You'll notice that answers links to question_options, not questions. This is intentional.
input_types
input_types are the types of questions. Each question can only be of 1 type, e.g. all radio dials, all text field(s), etc. Use additional questions for when there are (say) 5 radio-dials and 1 check box for an "include?" option or some such combination. Label the two questions in the users view as one but internally have two questions, one for the radio-dials, one for the check box. The checkbox will have a group of 1 in this case.
option_groups
option_groups and option_choices let you build 'common' groups.
One example, in a real estate application there might be the question 'How old is the property?'.
The answers might be desired in the ranges:
1-5
6-10
10-25
25-100
100+
Then, for example, if there is a question about the adjoining property age, then the survey will want to 'reuse' the above ranges, so that same option_group and options get used.
units_of_measure
units_of_measure is as it sounds. Whether it's inches, cups, pixels, bricks or whatever, you can define it once here.
FYI: Although generic in nature, one can create an application on top of this, and this schema is well-suited to the Ruby On Rails framework with conventions such as "id" for the primary key for each table. Also the relationships are all simple one_to_many's with no many_to_many or has_many throughs needed. I would probably add has_many :throughs and/or :delegates though to get things like survey_name from an individual answer easily without.multiple.chaining.
You could also think about complex rules, and have a string based condition field in your Questions table, accepting/parsing any of these:
A(1)=3
( (A(1)=3) and (A(2)=4) )
A(3)>2
(A(3)=1) and (A(17)!=2) and C(1)
Where A(x)=y means "Answer of question x is y" and C(x) means the condition of question x (default is true)...
The questions have an order field, and you would go through them one-by one, skipping questions where the condition is FALSE.
This should allow surveys of any complexity you want, your GUI could automatically create these in "Simple mode" and allow for and "Advanced mode" where a user can enter the equations directly.
one way is to add a table 'question requirements' with fields:
question_id (link to the "which brand?" question)
required_question_id (link to the "do you smoke?" question)
required_answer_id (link to the "yes" answer)
In the application you check this table before you pose a certain question.
With a seperate table, it's easy adding required answers (adding another row for the "sometimes" answer etc...)
Personally, in this case, I would use the structure you described and use the database as a dumb storage mechanism. I'm fan of putting these complex and dependend constraints into the application layer.
I think the only way to enforce these constraints without building new tables for every question with foreign keys to others, is to use the T-SQL stuff or other vendor specific mechanisms to build database triggers to enforce these constraints.
At an application level you got so much more possibilities and it is easier to port, so I would prefer that option.
I hope this will help you in finding a strategy for your app.