Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Multiple Choice Feature
Fixed #82 (Level Bonus not reset).
Fixed #421 (hint points now subtracted only after scoring level).
Added #218 (multiple choice option for quizes).
As part of #218, added ability to set a "wrong answer penalty" to quizes and flags (required so could not spam multiple choice answers).
Enabled bonus and bonus dec to be set initially (fixed half of #19).
Updated to pass hh_client (test cases updated to handle new parameters)
Recommend a new test-case be added to validate multiple choice functionality.
  • Loading branch information
archang31 committed Sep 3, 2017
commit 650e7a198baa34913482bc25f27dd694e525b204
4 changes: 2 additions & 2 deletions src/language/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function tr(string $word): string {
/* HH_IGNORE_ERROR[2050] */
return $lang[$word];
} else {
error_log(
/*error_log(
"\nWarning: '{$word}' has no translation in the selected language. Using the English version instead.",
);
);*/
return $word;
}
}
2 changes: 1 addition & 1 deletion src/models/HintLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static function hintlogFromRow(Map<string, string> $row): HintLog {
public static async function genResetHints(): Awaitable<void> {
$db = await self::genDb();
await $db->queryf('DELETE FROM hints_log WHERE id > 0');
self::invalidateMCRecords(); // Invalidate Memcached HintLog data.
self::invalidateMCRecords(); // Invalidate Memcached HintLog data.
}

// Check if there is a previous hint.
Expand Down
58 changes: 32 additions & 26 deletions src/models/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,36 +758,42 @@ private static function levelFromRow(Map<string, string> $row): Level {
$ent_id = $entity_id;
}

await $db->queryf(
'UPDATE levels SET title = %s, description = %s, entity_id = %d, category_id = %d, points = %d, '.
'bonus = %d, bonus_dec = %d, bonus_fix = %d, flag = %s, hint = %s, penalty = %d, '.
'wrong_answer_penalty = %d, is_short_answer = %d, answer_choice_1 = %s, '.
'answer_choice_2 = %s, answer_choice_3 = %s, answer_choice_4 = %s WHERE id = %d LIMIT 1',
$title,
$description,
$ent_id,
$category_id,
$points,
$bonus,
$bonus_dec,
$bonus_fix,
$flag,
$hint,
$penalty,
$wrong_answer_penalty,
$is_short_answer,
$answer_choice_1,
$answer_choice_2,
$answer_choice_3,
$answer_choice_4,
$level_id,
);
$result = await $db->queryf(
'UPDATE levels SET title = %s, description = %s, entity_id = %d, category_id = %d, points = %d, '.
'bonus = %d, bonus_dec = %d, bonus_fix = %d, flag = %s, hint = %s, penalty = %d, '.
'wrong_answer_penalty = %d, is_short_answer = %d, answer_choice_1 = %s, '.
'answer_choice_2 = %s, answer_choice_3 = %s, answer_choice_4 = %s WHERE id = %d LIMIT 1',
$title,
$description,
$ent_id,
$category_id,
$points,
$bonus,
$bonus_dec,
$bonus_fix,
$flag,
$hint,
$penalty,
$wrong_answer_penalty,
$is_short_answer,
$answer_choice_1,
$answer_choice_2,
$answer_choice_3,
$answer_choice_4,
$level_id,
);

// Make sure entities are consistent
await Country::genUsedAdjust();

self::invalidateMCRecords(); // Invalidate Memcached Level data.
Control::invalidateMCRecords('ALL_ACTIVITY'); // Invalidate Memcached Control data.
if ($result->numRowsAffected() > 0) {
$country_id = await self::genCountryIdForLevel($level_id);
await ActivityLog::genAdminLog("updated", "Country", $country_id);
$country = await Country::gen($country_id);
await Announcement::genCreateAuto($country->getName()." updated!");
self::invalidateMCRecords(); // Invalidate Memcached Level data.
ActivityLog::invalidateMCRecords('ALL_ACTIVITY'); // Invalidate Memcached ActivityLog data.
}
}

// Delete level.
Expand Down
4 changes: 2 additions & 2 deletions src/static/css/scss/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
}

&.col-1-2 {
@include flex(0 1 50%);
@include flex(0 1 47%);
}

&.col-1-3 {
Expand All @@ -163,7 +163,7 @@
}

& > .col.col-1-2 {
flex-basis: 48%;
flex-basis: 47%;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/static/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function sendAdminRequest(request_data: any, refresh_page) {
request_data
).fail(function(data) {
// TODO: Make this a modal
console.log('ERROR');
console.log('SEND ADMIN REQUEST Fail Function');
}).done(function(data) {
var responseData = JSON.parse(data);
if (responseData.result == 'OK') {
Expand Down Expand Up @@ -128,7 +128,7 @@ function validateAdminForm($clicked) {

$required.removeClass(errorClass).each(function() {
var $self = $(this),
$requiredEl = $('input[type="text"], input[type="password"], textarea', $self),
$requiredEl = $('input[type="text"], input[type="password"], textarea, input[name="answer_choice_2"]', $self),
$logoName = $('.logo-name', $self);

// All the conditions that would make this element trigger an error
Expand Down