Skip to content

Commit

Permalink
Merge pull request #29 from QuantumStack/#26
Browse files Browse the repository at this point in the history
Fix for #26
  • Loading branch information
Aditya Pillai committed Mar 9, 2020
2 parents 18c660c + 03f5f5e commit abfaa1e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions server/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ router.post('/writeconfig', (req, res, next) => {
// for flagAttempts, convert checkbox + selection to string
if (key === 'flagAttempts') v = v.length === 3 ? v[2] : '';

if (key === 'possibleScores') {
v = v.split(',').map(x => Number(x));
}

// for sections data, parse csv file
if (key === 'sections') {
if (value) {
Expand Down
7 changes: 5 additions & 2 deletions server/routes/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ router.get('/:student_id', authRequired, (req, res) => {
let section;
const flags = {};

const possibleScores = config.get('possibleScores');

// render page with queried data and relevant configs
function renderPage() {
res.render('checkin', {
Expand All @@ -43,8 +45,9 @@ router.get('/:student_id', authRequired, (req, res) => {
radio: config.get('radioInput'),
lab: config.get('manualLab'),
allowOverride: config.get('allowOverride'),
minscore: Number.parseInt(config.get('minScore'), 10),
maxscore: Number.parseInt(config.get('maxScore'), 10),
minscore: Math.min.apply(null, possibleScores),
maxscore: Math.max.apply(null, possibleScores),
possibleScores,
flags,
});
}
Expand Down
2 changes: 1 addition & 1 deletion server/util/version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios');

// current version
const current = 'v1.4.3';
const current = 'v1.4.4';
let latest;

// look for a new release on github
Expand Down
6 changes: 3 additions & 3 deletions server/views/checkin.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
<div class="field">
<label class="label">Score: {{> asterisk}}</label>
{{#if radio}}
<input id="score" class="is-hidden" name="score" type="number" required />
<input id="score" class="is-hidden" name="score" type="number" step="0.1" required />
<div class="columns is-multiline is-mobile">
{{#each (range minscore maxscore)}}
{{#each possibleScores}}
<div class="column">
<a id="score-{{this}}" onclick="setScore({{this}});" class="button is-fullwidth is-large score-button">
{{this}}
Expand All @@ -84,7 +84,7 @@
<script src="/javascripts/score-buttons.js"></script>
{{else}}
<div class="control">
<input class="input" name="score" type="number" step="0.5" placeholder="Example: 3" min="{{minscore}}" max="{{maxscore}}" required>
<input class="input" name="score" type="number" step="0.1" placeholder="Example: 3" min="{{minscore}}" max="{{maxscore}}" required>
</div>
{{/if}}
</div>
Expand Down
15 changes: 6 additions & 9 deletions server/views/partials/config.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
</div>
</div>
</div>
<p class="help">This is a comma-separated string of scores.</p>
<div class="field is-horizontal">
<div class="field-body">
<div class="field">
<label class="label">Min score:</label>
<label class="label">Possible Scores:</label>
<div class="control">
<input class="input" name="minScore" type="number" value="{{config.minScore}}" placeholder="Example: 0" required>
</div>
</div>
<div class="field">
<label class="label">Max score:</label>
<div class="control">
<input class="input" name="maxScore" type="number" value="{{config.maxScore}}" placeholder="Example: 100" required>
<input class="input" name="possibleScores" type="text" value="{{config.possibleScores}}" placeholder="Example: 1.5,3,4"
required>
</div>
</div>
</div>
</div>
<p class="help">This is the offset from the course timezone to UTC.</p>
<p class="help">This is the offset from the course timezone to UTC</p>
<p class="help">(e.g. Eastern Standard Time is +4 hours)</p>
<div class="field is-horizontal">
<div class="field-body">
<div class="field">
Expand Down

0 comments on commit abfaa1e

Please sign in to comment.