Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit a86e029

Browse files
committed
New: question bank search updates
* add selection for language * display author on search preview
1 parent 6dec9e6 commit a86e029

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

controllers/admin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,15 @@ def questionBank():
11271127
query_clauses = []
11281128

11291129
# should we search the question by term?
1130+
term_list = []
11301131
if request.vars.term:
11311132
term_list = [x.strip() for x in request.vars.term.split()]
1133+
1134+
# this will not be perfect but is an ok start.
1135+
if request.vars["language"] != "python" and request.vars["language"] != "any":
1136+
term_list.append(f':language: {request.vars["language"]}')
1137+
1138+
if term_list:
11321139
query_clauses.append(db.questions.question.contains(term_list, all=True))
11331140

11341141
if request.vars["chapter"]:

static/js/admin.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ function assignmentInfo() {
14331433
$("#nopause").val(assignmentData.nopause);
14341434
$("#nofeedback").val(assignmentData.nofeedback);
14351435
$("#assign_is_peer").val(assignmentData.is_peer);
1436-
$("#peer_async_visible").val(assignmentData.peer_async_visible);
1436+
$("#peer_async_visible").val(assignmentData.peer_async_visible);
14371437
if (assignmentData.visible === true) {
14381438
$("#assign_visible").prop("checked", true);
14391439
} else {
@@ -1897,6 +1897,11 @@ async function renderRunestoneComponent(componentSrc, whereDiv, moreOpts) {
18971897
if (typeof moreOpts === "undefined") {
18981898
moreOpts = {};
18991899
}
1900+
var author = null;
1901+
if ("author" in moreOpts) {
1902+
author = moreOpts.author;
1903+
delete moreOpts.author;
1904+
}
19001905
patt = /..\/_images/g;
19011906
componentSrc = componentSrc.replace(
19021907
patt,
@@ -1911,7 +1916,7 @@ async function renderRunestoneComponent(componentSrc, whereDiv, moreOpts) {
19111916
let componentKind = $($(`#${whereDiv} [data-component]`)[0]).data("component");
19121917
// webwork problems do not have a data-component attribute so we have to try to figure it out.
19131918
//
1914-
if (! componentKind &&
1919+
if (! componentKind &&
19151920
(componentSrc.indexOf("handleWW") >= 0) || (componentSrc.indexOf("webwork") >= 0)) {
19161921
componentKind = "webwork";
19171922
}
@@ -1963,6 +1968,11 @@ async function renderRunestoneComponent(componentSrc, whereDiv, moreOpts) {
19631968
"orig_divid",
19641969
opt.acid || moreOpts.acid || opt.orig.id
19651970
); // save the original divid
1971+
if (author) {
1972+
let authorInfo = document.createElement("p");
1973+
authorInfo.innerHTML = `Written by: ${author}`
1974+
$(`#${whereDiv}`).append(authorInfo);
1975+
}
19661976
let editButton = document.createElement("button");
19671977
let constrainbc = document.getElementById("qbankform").constrainbc.checked;
19681978
$(editButton).text("Edit Question");
@@ -2038,6 +2048,7 @@ function questionBank(form) {
20382048
var cbc = form.constrainbc.checked;
20392049
var obj = new XMLHttpRequest();
20402050
var url = "/runestone/admin/questionBank";
2051+
var qlanguage = form.language.value;
20412052
var data = {
20422053
variable: "variable",
20432054
chapter: chapter,
@@ -2049,6 +2060,7 @@ function questionBank(form) {
20492060
term: term,
20502061
competency: competency,
20512062
isprim: isprim,
2063+
language: qlanguage,
20522064
};
20532065
jQuery.post(url, data, function (resp, textStatus, whatever) {
20542066
if (resp == "Error") {
@@ -2135,6 +2147,7 @@ function getQuestionInfo() {
21352147

21362148
await renderRunestoneComponent(data.htmlsrc, "component-preview", {
21372149
acid: question_name,
2150+
author: data.author,
21382151
});
21392152

21402153
var q_author = document.getElementById("q_author");

views/admin/assignments.html

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{extend 'admin/instructors.html'}}
1+
{{extend 'admin/instructors.html'}}
22

33
{{ block tabcontent }}
44

@@ -63,9 +63,9 @@ <h4 style="text-align: center;">Assignment</h4>
6363
</div>
6464
<div class="form-group form-check peer-group">
6565
<label for="assign_is_peer" class="form-check-label">Peer Instruction Activity</label>
66-
<input id="assign_is_peer" class="form-check-input" type="checkbox" name="is_peer" value="T" /> (Do not use with timed exam!)
66+
<input id="assign_is_peer" class="form-check-input" type="checkbox" name="is_peer" value="T" /> (Do not use with timed exam!)
6767
<label for="peer_async_visible">Show Async </label>
68-
<input id="peer_async_visible" class="form-check-input" type="checkbox" name="peer_async_visible" value="F" />
68+
<input id="peer_async_visible" class="form-check-input" type="checkbox" name="peer_async_visible" value="F" />
6969
<br />
7070
</div>
7171
<label for="assignment_description">Description: </label>
@@ -246,6 +246,19 @@ <h5 style="text-align: center">Search Question Bank</h5>
246246
</label>
247247
</div>
248248
</div>
249+
<div class="form-group">
250+
<labael for="language">Language</labael>
251+
<select name="language" id="language">
252+
<option value="any">Any</option>
253+
<option value="c">C</option>
254+
<option value="cpp">C++</option>
255+
<option value="html">HTML</option>
256+
<option value="java">Java</option>
257+
<option value="javascript">Javascript</option>
258+
<option value="python">Python</option>
259+
<option value="sql">SQL</option>
260+
</select>
261+
</div>
249262
<div class="form-group">
250263
<label for="competencyselector">Competency</label>
251264
<div id="competencyselector">

0 commit comments

Comments
 (0)