Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="row">
	<div class="col-md-12">
		<div class="jumbotron w-75 mx-auto my-3">
			<h3>Grading Style Outcome Tool</h3>
			<form id="grade-checker">
				<div class="form-group row">
					<label class="col-sm-9 col-form-label" for="points">How many points is the question worth?</label>
					<div class="col-sm-3">
						<input type="number" class="form-control" id="points" value="10" required/>
					</div>
				</div>
				<fieldset class="form-group">
					<div class="row">
						<legend class="col-form-label col-sm-4 pt-0">Question Type</legend>
						<div class="col-sm-8">
							<div class="form-check">
								<input class="form-check-input" type="radio" id="MC-type" value="0" name="item-type" checked>
								<label class="form-check-label" for="MC-type">Multiple Choice</label>
							</div>
							<div class="form-check">
								<input class="form-check-input" type="radio" id="num-type" value="1" name="item-type">
								<label class="form-check-label" for="num-type">Numeric/Algebraic/Short Answer</label>
							</div>
						</div>
					</div>
				</fieldset>
				<div class="form-group row" id="choices-div">
					<label class="col-sm-9 col-form-label" for="choices">How many choices does the question have?</label>
					<div class="col-sm-3">
						<input type="number" class="form-control" id="choices" value="5" min="2" max="10" required/>
					</div>
				</div>
				<input type="button" class="btn btn-primary" onclick="pointsCalculator();" value="Submit" />
			</form>
		</div>
		<div class="w-75 mx-auto mb-3 card" id="results-div">
			<table class="table table-hover w-100 text-center">
				<thead class="thead-light">
					<tr>
						<th scope="col" class="w-25">Try</th>
						<th scope="col" class="w-25">Negative Points</th>
						<th scope="col" class="w-25">No Negative Points</th>
						<th scope="col" class="w-25">One Free Try</th>
					</tr>
				</thead>
				<tbody id="results">
				</tbody>
			</table>
		</div>
	</div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                document.getElementById('MC-type').addEventListener('change', choicesController);
document.getElementById('num-type').addEventListener('change', choicesController);

function choicesController() {
	let itemType = (document.getElementById('MC-type').checked) ? 0 : 1;
	
	if (itemType == 0) {
		document.getElementById('choices-div').innerHTML = '<label class="col-sm-9 col-form-label" for="choices">How many choices does the question have?</label><div class="col-sm-3"><input type="number" class="form-control" id="choices" value="5" min="2" max="10" required/></div>';
	} else {
		document.getElementById('choices-div').innerHTML = "";
	}
}

function pointsCalculator() {
	let points = Number(document.getElementById('points').value);
	let itemType = (document.getElementById('MC-type').checked) ? 0 : 1;
	let choices = (document.getElementById('MC-type').checked) ? Number(document.getElementById('choices').value) : 7;
	let output = "";
	let scoresNeg = [];
	let scoresPos = [];
	let scoresFree = [];

	if (itemType == 0) { // MC items
		for(let i = 0; i < choices; i++) {
			scoresNeg[i] = (points * (1 - 2 * (i/(choices - 1)))).toFixed(2); // negative points allowed
			scoresPos[i] = ((-points/(choices - 1) * i) + points).toFixed(2); // no negative points
		}
		for(let i = 0; i < choices; i++) { // one free try
			(i == 0) ? scoresFree[i] = (points).toFixed(2) : scoresFree[i] = ((-points/(choices - 2) * (i-1)) + points).toFixed(2);
		}

		for (let j = 0; j < choices-1; j++) {
			output += '<tr><th scope="row">'+(j+1)+'</th><td>'+scoresNeg[j]+'</td><td>'+scoresPos[j]+'</td><td>'+scoresFree[j]+'</td></tr>';
		}

		output += '<tr><th scope="row">Never Correct</th><td>'+scoresNeg[scoresNeg.length-1]+'</td><td>'+scoresPos[scoresPos.length-1]+'</td><td>'+scoresFree[scoresFree.length-1]+'</td></tr>';

	} else { // nfr, afr, short answer
		for (let i = 0; i < 7; i++) { // one free try
			if (i == 0) {
				scoresFree[i] = (points * Math.pow(0.93,i)).toFixed(2);
			} else {
				scoresFree[i] = (points * Math.pow(0.93,(i-1))).toFixed(2);
			}
		}
		for (let i = 0; i < 7; i++) { // not one free try
			scoresNeg[i] = (points * Math.pow(0.93,i)).toFixed(2);
			scoresPos[i] = (points * Math.pow(0.93,i)).toFixed(2);
		}

		for (let j = 0; j < 7; j++) {
			output += '<tr><th scope="row">'+(j+1)+'</th><td>'+scoresNeg[j]+'</td><td>'+scoresPos[j]+'</td><td>'+scoresFree[j]+'</td></tr>';
		}

		output += '<tr><th scope="row">Never Correct</th><td>0</td><td>0</td><td>0</td></tr>';
	}

	document.getElementById('results').innerHTML = output;
}
              
            
!
999px

Console