OpenLLM-France/wikimedia huggingface dataset:
# JavaScript/Constructors and prototypes
## Constructor

The new operator creates a new object based on a constructor and a prototype.
The constructor is a function matching the name of the object, and, when called by the new operator, has the keyword this assigned to the newly created instance of the object. The constructor can then assign any initial variables as required.
The constructor can accept parameters - however, it is not possible to overload the constructors by having multiple functions with a different number of parameters.
(The 'new' statement is the most common way to create a new JavaScript object from a constructor function, but a few JavaScript programmers sometimes use alternative techniques. )

## Prototypes

A prototype for an object is the set of auto-created fields and methods. It cannot operate by itself, and relies on an existing constructor.
When the object is created, the fields initialized in the prototype are copied to the newly created object.
Since the prototype of an object behaves as an object, you can use this to create inheritance.

## Dynamically extending objects

Objects within JavaScript are fully dynamic, and fields within an object can instantly be created if they do not already exist. If, for example, you discover that you now need to keep track of the thickness in the coin example, you can simply add the new field to the prototype.
Changing the prototype of an object allows existing instances of the object to gain access to that change.
When a property value has been assigned on a new object, that property takes precedence over the prototype property from its ancestor. If you delete the property from the new object, the chain of inheritance takes you back to the property from the parent object.
To demonstrate, an Animal constructor is used to create an object, a dog called Spot. After that creation, the constructor has a gender property added to it. That gender property is also accessible from the object for Spot.
The gender property can be updated, and if the gender property is deleted from the dog object, it will retrieve the desired property from its ancestor instead, the Animal constructor.

## References

* ↑ Greg Tatum. "Killing JavaScript's this". Examples of JavaScript supporting many alternatives to traditional object-oriented programming. One section "typical object-oriented JavaScript".
* ↑ Douglas Crockford. "Crockford on JavaScript -- Act III: Function the Ultimate" pdf "Crockford on JavaScript -- Act III: Function the Ultimate" video. Describes several different ways to make object constructors in JavaScript.
# JavaScript/Contributors

Those who are going to contribute please sign your name by adding four tildas (~~~~).
* cuckooman4 04:26, 20 December 2007 (UTC) -- Might make some contributions
* Cparker (talk) 18:26, 17 March 2008 (UTC) --
* Extremecircuitz 20:55, 29 September 2007 (UTC) -- Adding a page here and there
* Jaymac407 (talk) 20:35, 21 July 2008 (UTC) -- Hopefully going to do extensive changes.
* Jesdisciple (talk) 08:37, 11 May 2010 (UTC) -- Looking into a restructuring of the chapter order to be more newbie-friendly.
* Pmw57 (talk) 10:28, 21 February 2009 (UTC) -- Am performing extensive updates
* Pranakhan 16:39, 6 November 2007 (UTC) -- Slowly reworking and adding content to this book
* Sae1962 (discuss • contribs) 06:06, 10 March 2015 (UTC) -- Reworking & extending content of this book
# JavaScript/Cookies
## Intoduction

Cookies are used to store small amount of date in the browser, e.g. used to identify the user or settings or preferences of the user,
# JavaScript/Data types
## Introduction

Each variable in JavaScript has a certain data type (Number, String, Boolean, ...) - as long as a value is stored in the variable. The type of the value determines the type of the variable. In contrast to strongly typed languages, it is possible to assign - over time - values of different types to the variable so that the type of the variable may change. This is called weakly or loosely typing. The advantage is that JavaScript programmers have a wealth of possibilities and freedom to use (or abuse) variables. On the other hand, in strongly typed languages, a lot of formal errors can be detected during compile-time.
JavaScript knows seven primitive data types (Number, String, Boolean, BigInt, Symbol, Undefined, Null) and diverse other data types, which are all derived from Object (Array, Date, Error, Function, RegExp). Objects contain not only a value, they also have methods and properties. The same can happen with primitive data types. If they try to invoke methods, the JS engine 'wraps' them with a corresponding object wrapper and calls its methods instead. This technique is sometimes called boxing.
You may wonder why we describe data types and initialization in the same chapter. The reason is that they are very closely related to each other. The initialization (and subsequent assignments) of a value to a variable determines its type - as noted above. That's why there is no designation of a type during initialization, in contrast to some other languages private int i = 0; /* Java */
(Note: JSON is a text-based data format, not a data type. As such, it’s language-independent. It uses the JavaScript object syntax.)

## Categories of data types

Data types are explained in the following chapters.
* Primitive data type
* Objects
* Arrays
* Dates
* Regular Expressions

## References

* ↑ MDN: Data Types
* ↑ MDN: Details on Data Types
# JavaScript/Control structures/Exercises

Topic: Conditional Branches
1. Write a script that allows a user to type in his name (prompt). The script shall answer depending on the length of the name.
* Up to 5 characters: "Hello, <name>. You have a short name."
* Up to 10 characters: "Hello, <name>. You have a name with a medium length."
* Greater than 10 characters: "Hello, <name>. Your name is very long."
2. Write a script that allows a user to type in a single character. The script shall decide whether it is a vocal ('a', 'e', 'i', 'o', 'u') or a consonant.
* "You typed in the vocal: <user's input>"
* "You typed in the consonant: <user's input>"
* "You typed in a digit or some other character (+, -, *, ...): <user's input>"
3. try / catch
* Write a script that calls a functionconnectToDatabase. This function does not exist in your script, which causes the JavaScript engine to generate a runtime error.
* Catch the error and produce a meaningful error.
* Terminate the script.
# KoBo Toolbox/KoBoForm/Validation Logic

On the previous page we discussed how we could direct a users responses by defining a certain question type. For example, we can limit the responses to numbers by choosing the question type decimal or even to only whole numbers by using the question type integer. However, sometime is is necessary to limit the range of possible responses even further, for example, to only positive numbers, for this we use validation logic.
In our survey we now wish to ask the age of the pet. We know a number of things about age, firstly, it is generally given as an integer (or whole) number, we therefore add an Integer Question. Secondly, age cannot be negative, lastly, no pet lives forever, therefore we will set an upper limit of 100 years.
Add the Integer Question and change the text to
Now click the Show Advanced Properties link underneath the question properties. Once the advanced properties appear, click the tab
We can now add the conditions, click the link
# KoBo Toolbox/KoBo External Resources

In this chapter, which consists only of this page, we mention a few external resources which will be useful for users of the KoBo Toolbox who want to further develop their understanding.
# KoBo Toolbox/KoBoCollect

After we have managed to create a survey form in the KoBoForm form designer, we will need to save the form to a file, and transfer this file to the Android device.
In this chapter, we will assume that the form has been created on a computer other than the Android device which we will use to administer the survey. There will therefore be two steps to this process:
* Save the form to an XML file
* Transfer the XML file to the correct location on the Android device
In addition to setting up the survey on the device, this chapter will also discuss:
* Filling out the survey on the device
* Saving the results on the device
* Transferring the results to a computer
# KoBo Toolbox/KoBoForm/Creating a Form

KoBo surveys are created using the standard Xform format, which is build on XML. In order to create these forms, we use KoBoForm (http://kobotoolbox.org/koboform).

## New Form

After the KoBoForm editor has loaded a menu bar is displayed. The Menu button on the left opens the file menu, using the option New form, a form can be created.

## Overview

The two panels is the bottom part of the screen are now populated, as seen in the Empty form image. On the left side the structure of the form is outlined. The new form is already populated with a few elements:
* New form 1: title of the form
* deviceid: automatic registration of Android device id number
* start: survey start date and time
* end: survey end date and time
* QuestionA01: first question, type single select
* OptionA01_1: first option to the first question
From the structure we can see that all elements are contained within the New form 1 element, and that OptionA01_1 is also contained within QuestionA01.
The right hand panel shows the contents of the element which is selected in the left panel. When the form is created the New form 1 element is active, and so this is displayed.
Since our survey will be on pets, we can change the title to Pet Survey as shown in the picture.
The form title in the structure is automatically updated to reflect the new title.

## User Accounts

Note that KoBoForm has the option to create a user account in order to save forms in between browser sessions. These accounts are stored offline, in the browser, which means that they will not synchronize across computers or browsers.
Creating a Question →
# KoBo Toolbox/KoBoForm/Creating a Question

As we save in Creating a form, when we create a new form, the first question, which is called QuestionA01 is already created for us.
We will begin by editing Question text, which is the text that the enumerator will read to the interviewee. Do to so, in the left pane, click QuestionA01. The content of QuestionA01 is now displayed in the right pane. The selected text should say QuestionA01, since our survey is about pets, we will change the text to:
The result should look like the image below.
KoBoForm supports different question types, the question that was automatically created for us when we created the form is of the type single select. A single select question is a multiple choice question, in which only one option can be chosen. This is made clear to the user by a round selection indicator (also known as the radio button, after pre-programmed frequency buttons on old radios) before the different options which are available. The single-select question is useful if we are asking the interviewee a question to which the answers are mutually exclusive. An example of such a question could be:
The answers to these questions could be:
The point of a mutually exclusive question, is that both answers cannot be correct at the same time, in this case, it cannot both be raining, as well as, not be raining, at the same time, in one location.
In addition to mutually exclusive, this question was also collectively exhausting, which is to say that if option 1 is not true, than option 2 has to be true. However, this is not a necessary property for single-select questions, since we can add an option other, as will be discussed below.
← Creating a Form · Various Question Types →
# KoBo Toolbox/KoBoForm

The first step in the survey administration life-cycle is to design the survey. The formulation of the questions and the answers is extremely important, however this fall outside of the scope of this wikibook. For more information on survey design see the chapter Surveys of the wikibook Social Research Methods.
Here we will assume that you have already formulated the questions and answers for your survey, this chapter will describe how to input these questions in the KoBo FormBuilder.
# KoBo Toolbox/Post Processing

This chapter will deal with the post processing of data collected using the KoBoCollect Android app.
The first step is to aggregate all the individual XML output files (instances) from one or more devices. Using the KoBoSync java application (which is also available through the KoBoForm website) these results XML files can be aggregated in to a single CSV (Comma Separated Values) file. CSV files can easily be imported in virtually all software used for data analysis, such as spreadsheets, R, or SPSS/PSPP.
In the part, we discuss how KoBoForm has the option to export the variable types and labels from the from to an SPSS/PSPP syntax file. Using SPSS or the free and open-source alternative PSPP, we can then use this syntax file to correctly encode and label the variables and data in SPSS/PSPP. From here it is possible to export the SPSS data file within which all variables are correctly encoded, this file can then also be imported in other statistical software such R.
# KoBo Toolbox/KoBoForm/Various Question Types

On the previous page we discussed questions of the type single select, in this page we will devote some space to discussing which other question types are available and when these can be useful.
When clicking the downward facing arrow, on the right side of the Add Question button, we are presented with a drop down menu with all available question types. All question types are briefly explained below.

## Text Question

Questions of type text are simply open boxes where text or numbers can be entered.

## Integer Question

Integer Questions provide the use with a box in which whole numbers can be entered (e.g. 1, 3, 6, 45, -99, etc.). The keyboard will be a number only keyboard, the keyboard does provide the ability to enter decimal numbers, but the program will not allow this.

## Decimal Question

Decimal Questions are similar to Integer Questions except that these questions do allow the user to enter decimal numbers (e.g. 1.5, 38.9, -12.3).

## MultiSelect Question

MultiSelect Questions provide the user with a list of tick-boxes (each option being a box). The user can select multiple options or one option.

## SingleSelect Question

SingleSelect Questions provide the use with a list of radio boxes, whereby each option has a radio box. The user can only select one option of the list, if an option is selected, all other options will be deselected.

## Time Question

This registers the time, note that the begin and end time (and date) are automatically registered.

## Date Question

This registers the date, note that the begin and end date (as well as time) are automatically registered.

## Date+Time Question

This registers the date and the time, this question type is used for begin and end date and time (default).

## Picture Question

A picture can be added from the device, this can either be done using a camera or from the storage on the device.

## Video Question

A video can be added from the device, this can either be done using a camera or from the storage on the device.

## Audio Question

Audio can be added from the device, this can either be done using a camera or from the storage on the device.

## GPS Question

This uses the built in GPS function to registed the location of the device. This might take some time. In order to minimize the time, this can be cached by activating the GPS once after the device was powered on.

## Barcode Question

This question allows the user to use a built in camera to scan a barcode or QR-code. Note that additional applications might have to be installed to use this functionality.

## Trigger Question

This questions type will be discussed in the advanced topics section.
← Creating a Question · Validation Logic →
# KoBo Toolbox

The purpose of this Wikibook is to provide an introduction to the mobile survey software suite called KoBo Toolbox (http://www.kobotoolbox.org/). Using the KoBo Toolbox, surveys for mobile Android devices, such as smartphones and tablets, can be created. The screenshot of the Android application shows a typical multiple-choice (single-select) question.
Although there are many mobile survey software suites, the KoBo Toolbox is particularly interesting for a number of reasons:
* open-source: free to use and change, fully transparent
* scalability: use multiple devices, aggregate results
* remote administration: results can be synchronized automatically
* robustness: works under difficult conditions, such as limited internet
The topics discussed in this Wikibook are listed below.

## KoBoForm

* Creating a Form
* Creating a Question
* Various Question Types
* Validation Logic
* Skip Logic

## KoBoCollect

* Exporting the form to an Xform XML file
* Loading the XML file into the KoBo Collect Android app
* Filling out a survey
* Saving the results
* Exporting the results to a computer

## Post Processing

* Aggregating the results to a CSV file
* Importing the CSV file into SPSS / PSPP

## Advanced Topics

* Trigger questions
* Group questions

## KoBo External Resources

* KoBo Toolbox website
* Official KoBo Toolbox User guide
* Official KoBo Toolbox YouTube Channel
* KoBoForm form builder
# KS3 Computing/Iteration
## Iteration

Iteration (looping) is a way of repeating a specific chunk of code several times. It might be a specific number of times, e.g. 10, or it might be until a certain condition is met.
For example, if you want to repeat a phrase 3 times, you could do:
This is called a for loop and would output the following:

## Types of loops

The different types of loops include those that:
* Repeat n times - where n is the number of times the code is executed
* Repeat until - where the code is repeated until a certain condition is true/false
* Repeat forever - where the code is repeated continuously until the end of the program
Loops in Python include:
Loops in Scratch include:

## Introducing the concept of looping

It is a good idea to let younger students write long sections of code first, then ask them how they might reduce the number of lines of code / make their code more 'efficient' (answer = by introducing a loop!).
A simple example of this would be asking them to print out the 3 times tables. At first they would manually print out all parts, e.g. print("1x3=3") written out 12 times. Once they have done this, show them how a loop can get the program to do all the hard work!
Example code in Python would be:
Here is an example of introducing loops in Scratch
# KS3 Computing/Logic/And
## AND

AND - True when all of the inputs are true
With AND, the result is TRUE only when both A AND B are TRUE
| A | B | A AND B |
| true | true | true |
| true | false | false |
| false | true | false |
| false | false | false |

### Example

Cpt Jean-Luc Janeway is about to go on a space walk.
* To leave the space ship Cpt Janeway must leave through the airlock, which contains an inner door and an outer door.
* The inner door will only open when the outer door is closed AND the Airlock is pressurised.
Which of scenarios below results in Cpt Janeway being able to open the inner door?
| Scenario | Outer Door Closed | Airlock Pressurised |
| A | False | True |
| B | False | False |
| C | True | True |
| D | True | False |
Answer:
Scenario C

### Extra

Cpt Janeway is now inside the airlock...
* The Outer Door can only be opened once the airlock is de-pressurised
* The airlock can only be de-pressurised once the inner door is closed
Challenge 1: Create a truth table (see above) to see how many scenarios meet the above criteria so Cpt Janeway can exit the airlock
Challenge 2: How many scenarios allow Cpt Janeway to leave the spaceship?
Answer:
1, The airlock is depressurised AND the inner door is closed
# KS3 Computing/Logic/OR

OR - True when one or more input is true
With the Boolean operator 'OR', the result Q is TRUE when at least one of its inputs are true. So the result is TRUE when either A is true, or B is true, or both are true. The result is FALSE when both A and B are false.
A OR B
| A | B | A OR B |
| true | true | true |
| true | false | true |
| false | true | true |
| false | false | false |
# KS3 Computing/Logic/UsefulLogicLinks
## Useful Links

Youtube Video on Boolean operators
Computational Fairy Tales - Boolean Logic
KS3 Intro to Boolean Values - CAS Resource
Logic Gates and Boolean Logic - CAS Resource
# KS3 Computing/Measuring the size of things

Measuring the size of things
To measure different types of things around us, there is a need to use suitable equipment such as rulers, measuring beakers, tape measures, etc.
It is important to learn how to measure and read scales which is the skill needed.
Bits
Bytes
Kilobytes
Megabytes
Gigabytes
Terrabytes
# KS3 Computing/Logic/NOT
## Not
### What is Not?

| A | NOT A |
| False | True |
| True | False |
# KS3 Computing/Numbers
## Numbers
### Introduction

Numbers are the lifeblood of computers. On computers, numbers are stored using binary representations where the ones and zeros are interpreted by computer programs using patterns [add link to data representation] based on conventions of whatever programming language the program is written in.

### Videos

Unplugged computing video on binary numbers on
# KS3 Computing/Logic
#### What is Logic?

When we talk about logic in computing we normally mean a variety of logic called Boolean Logic, named for George Boole,
an English mathematician. It is only concerned with whether things are True or False. This matches well onto digital computers which have circuits that are either on or off. Logic is used in the design of computer chips as well in programs written to run on computers. Other areas where logic might be used are in the operation of traffic lights (you don't want traffic flowing both ways across a junction at the same time) and in many safety systems (e.g. operation of a spaceship's airlock) where the logic may be implemented mechanically rather than electronically.
Use the following pages to learn more.
** Boolean
** AND
** OR
** NOT
** Useful Links
** Physical Computing
# KS3 Computing/Logic/Boolean
## What is Boolean Logic?

Boolean logic is used to help us create more complex programs. They allow us to trigger actions depending on whether certain conditions are met. Consider what you would wear if it was sunny AND warm. What about if it was cold OR raining? And if it was NOT more than 2 degrees? Boolean logic has two states: True (denoted by 1) or False (denoted by 0).

## Activity: going to the cinema

Four friends are planning a trip to the cinema. Each of them has a different preference:
* Armina wants to see an animated film
* Boris does NOT want to see a high school movie
* Cody wants to see a film with hero kids OR superheroes
* Derren wants to see a film with action AND comedy
Here are the films playing at their local cinema:
* Big Hero 6: action, comedy, animated, hero kids
* Frozen: animated
* Hunger Games: Mockingjay: action, hero kids
* The Hobbit: action
* Night at the Museum: comedy, action
* The DUFF: high school, comedy
* Captain America: superheroes, action

### Questions

Would Armina watch The Hobbit?
Answer:
No.
Would Boris watch The Hobbit?
Answer:
Yes.
Would Cody watch Captain America?
Answer:
Yes.
Which film(s) would Derren watch?
Answer:
Big Hero 6, Night at the Museum.
Would Armina and Boris watch Frozen?
Answer:
Yes.
Would Boris and Cody watch Hunger Games: Mockingjay?
Answer:
Yes.
Would Cody and Derren watch Hunger Games: Mockingjay?
Answer:
No.
Can you draw a truth table for each of the friends? (See KS3_Computing/Logic/And, KS3_Computing/Logic/OR, KS3_Computing/Logic/NOT for help
Write a simple program or algorithm that decides whether all four kids will watch a film.
Use your program to identify which film(s) will they all watch
Answer:
Big Hero 6.