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

Commit c43d48a

Browse files
committed
New: get open course list from the db
1 parent 53117d7 commit c43d48a

File tree

3 files changed

+85
-40
lines changed

3 files changed

+85
-40
lines changed

controllers/default.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ def user():
2121
if not request.args(0):
2222
redirect(URL("default", "user/login"))
2323

24+
library_list = []
2425
if "register" in request.args(0):
2526
# If we can't pre-populate, just set it to blank.
2627
# This will force the user to choose a valid course name
2728
db.auth_user.course_id.default = ""
28-
29+
library_list = db.executesql(
30+
"""select basecourse, title
31+
from library
32+
where for_classes = 'T' and is_visible = 'T'
33+
order by shelf_section, basecourse""",
34+
as_dict=True,
35+
)
2936
# Otherwise, use the referer URL to try to pre-populate
3037
ref = request.env.http_referer
3138
if ref:
@@ -85,7 +92,7 @@ def user():
8592
TypeError,
8693
): # not all auth methods actually have a submit button (e.g. user/not_authorized)
8794
pass
88-
return dict(form=form)
95+
return dict(form=form, library=library_list)
8996

9097

9198
# Can use db.auth_user._after_insert.append(make_section_entries)

views/default/user.html

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -296,30 +296,12 @@ <h4>Registration Hints</h4>
296296
<p>In the field for the <strong>Course Name</strong> please use the course name your instructor gave you. Or...</p>
297297
<p> If you are an <strong>instructor</strong> registering for the first time OR an <strong>independent learner</strong> use one of the following for our open, public courses.</p>
298298
<p>Runestone uses usernames to keep track of you. Please write it down somewhere if you're likely to forget it. </p>
299-
<h3>Open CS Textbooks</h3>
300-
<ul>
301-
<li><code>thinkcspy</code> for How to Think Like a Computer Scientist</li>
302-
<li><code>fopp</code> for Foundations of Python Programming</li>
303-
<li><code>pythonds</code> for Problem Solving with Algorithms and Data Structures using Python Second Edition</li>
304-
<li><code>pythonds3</code> for Problem Solving With Algorithms and Data Structures using Python Third Edition</li>
305-
<li><code>StudentCSP</code> for the AP CS Principles</li>
306-
<li><code>csawesome</code> AP CS A Java Course - its Awesome</li>
307-
<li><code>httlads</code> for How to Think like a Data Scientist</li>
308-
<li><code>cppds</code> for Problem Solving with Algorithms and Data Structures using C++</li>
309-
<li><code>cpp4python</code>C++ for Python Programmers</li>
310-
<li><code>java4python</code>Java for Python Programmers</li>
311-
<li><code>JS4python</code>Javascript for Python Programmers</li>
312-
<li><code>thinkcpp</code>How To Think Like A Computer Scientist C++ Edition</li>
313-
<li><code>MasteringDatabases</code>Mastering Relational Databases</li>
314-
<li><code>pythoned</code>Spanish Language Edition of <code>pythonds</code></li>
315-
<li><code>webfundamentals</code>Fundamentals of Web Programming</li>
316-
<li><code>learnwebgl2</code>Learn Computer Graphics using WebGL</li>
317-
</ul>
318-
<h3>Open Math Textbooks</h3>
299+
<h3>Open Textbooks</h3>
300+
319301
<ul>
320-
<li><code>fcla</code>A First course in Linear Algebra</li>
321-
<li><code>aata</code>Abstract Algebra, Theory and Applications</li>
322-
<li><code>orcca</code>Open Resources for Community College Algebra</li>
302+
{{ for course in library:}}
303+
<li><code>{{=course["basecourse"]}}</code> for {{=course["title"]}}
304+
{{pass}}
323305
</ul>
324306
</div>
325307
{{else:}} <!-- lti_only_mode -->

views/designer/index.html

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
1+
{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
22

3-
{{extend 'layout.html'}}
3+
{{extend 'layout.html'}}
44
<style>
55
h3 {
66
color: #ab1059;
@@ -26,7 +26,7 @@ <h1>{{=message}}</h1>
2626
var basecourse = document.forms["mainform"]["coursetype"].value;
2727
let instid = document.forms["mainform"]["institution"].value;
2828
let level = document.forms["mainform"]["courselevel"].value;
29-
29+
3030

3131
if (basecourse == "") {
3232
alert('Error: You must select a book for your course')
@@ -37,7 +37,7 @@ <h1>{{=message}}</h1>
3737
alert('Error: You must provide the name of your Institution. This is used for help your students find the correct course')
3838
return false;
3939
}
40-
40+
4141
if (level == "unknown") {
4242
alert("Please tell us approximately what level your course is at this is important for recommending questions as well as educational research.")
4343
return false;
@@ -47,7 +47,7 @@ <h1>{{=message}}</h1>
4747
alert('Error: Your Project Name may not contain spaces or /')
4848
return false;
4949
}
50-
50+
5151
if (!/^([\x30-\x39]|[\x41-\x5A]|[\x61-\x7A]|[_-])*$/.test(x)) {
5252
alert("Error: Your project name can only contain ASCII letters digits and - or _");
5353
return false;
@@ -57,28 +57,28 @@ <h1>{{=message}}</h1>
5757
unhide_img('spinner');
5858
return true
5959
}
60-
60+
6161
function suggested_course_name() {
6262
let d = new Date();
6363
const getSeason = d => Math.floor(((d.getMonth()+1) / 12 * 4)) % 4
6464
let season = ['winter', 'spring', 'summer', 'fall'][getSeason(d)]
65-
65+
6666
var basecourse = document.forms["mainform"]["coursetype"].value;
6767
let instid = document.forms["mainform"]["institution"].value;
6868
let suggestedCourse = ""
69-
69+
7070
if ( instid ) {
7171
suggestedCourse += instid.toLowerCase().replace(/ /g,'');
7272
}
7373
if (basecourse) {
7474
suggestedCourse += "_" + basecourse.toLowerCase();
7575
}
7676
suggestedCourse += "_" + season + (d.getYear() - 100)
77-
77+
7878
document.forms["mainform"]["projectname"].value = suggestedCourse;
79-
79+
8080
}
81-
81+
8282

8383
</script>
8484
<div class="col-md-8 col-md-offset-2">
@@ -87,9 +87,65 @@ <h1>{{=message}}</h1>
8787
<div class="form-group row">
8888
<div class="col-md-8">
8989
<h3>Step 1</h3>
90-
<p><i>Tell us the name of your Institution. We may use this to verify your status as an instructor.</i></p>
90+
<p><i>Tell us the name of your Institution and your US State. We may use this to verify your status as an instructor. The state is required by non-profit tax codes.</i></p>
9191
<label for="institution">Institution (required)</label>
9292
<input type="text" class="form-control" placeholder="Your school" name="institution" id="institution" onchange="suggested_course_name()" />
93+
<label for="state">United States - State</label>
94+
<select id="state" name="state" required>
95+
<option value="">Choose</option>
96+
<option value="NA">Not in the United States</option>
97+
<option value="AL">Alabama</option>
98+
<option value="AK">Alaska</option>
99+
<option value="AZ">Arizona</option>
100+
<option value="AR">Arkansas</option>
101+
<option value="CA">California</option>
102+
<option value="CO">Colorado</option>
103+
<option value="CT">Connecticut</option>
104+
<option value="DE">Delaware</option>
105+
<option value="DC">District Of Columbia</option>
106+
<option value="FL">Florida</option>
107+
<option value="GA">Georgia</option>
108+
<option value="HI">Hawaii</option>
109+
<option value="ID">Idaho</option>
110+
<option value="IL">Illinois</option>
111+
<option value="IN">Indiana</option>
112+
<option value="IA">Iowa</option>
113+
<option value="KS">Kansas</option>
114+
<option value="KY">Kentucky</option>
115+
<option value="LA">Louisiana</option>
116+
<option value="ME">Maine</option>
117+
<option value="MD">Maryland</option>
118+
<option value="MA">Massachusetts</option>
119+
<option value="MI">Michigan</option>
120+
<option value="MN">Minnesota</option>
121+
<option value="MS">Mississippi</option>
122+
<option value="MO">Missouri</option>
123+
<option value="MT">Montana</option>
124+
<option value="NE">Nebraska</option>
125+
<option value="NV">Nevada</option>
126+
<option value="NH">New Hampshire</option>
127+
<option value="NJ">New Jersey</option>
128+
<option value="NM">New Mexico</option>
129+
<option value="NY">New York</option>
130+
<option value="NC">North Carolina</option>
131+
<option value="ND">North Dakota</option>
132+
<option value="OH">Ohio</option>
133+
<option value="OK">Oklahoma</option>
134+
<option value="OR">Oregon</option>
135+
<option value="PA">Pennsylvania</option>
136+
<option value="RI">Rhode Island</option>
137+
<option value="SC">South Carolina</option>
138+
<option value="SD">South Dakota</option>
139+
<option value="TN">Tennessee</option>
140+
<option value="TX">Texas</option>
141+
<option value="UT">Utah</option>
142+
<option value="VT">Vermont</option>
143+
<option value="VA">Virginia</option>
144+
<option value="WA">Washington</option>
145+
<option value="WV">West Virginia</option>
146+
<option value="WI">Wisconsin</option>
147+
<option value="WY">Wyoming</option>
148+
</select>
93149
<hr />
94150
<h3>Step 2</h3>
95151
<p><i>Tell us approximately what level you are teaching at. This is important for research and providing you with appropriate questions.</i></p>
@@ -119,7 +175,7 @@ <h4>{{=section}}</h4>
119175
<input type="radio" name="coursetype" value="{{=course["basecourse"]}}" />
120176
{{=course["title"]}}
121177
{{ if course["subtitle"]:}}
122-
: {{=course["subtitle"]}}
178+
: {{=course["subtitle"]}}
123179
{{ pass }}
124180
{{ if course["authors"]: }}
125181
by {{=course["authors"]}}
@@ -137,7 +193,7 @@ <h4>{{=section}}</h4>
137193
for (var i = 0; i < rad.length; i++) {
138194
rad[i].addEventListener('change', suggested_course_name);
139195
}
140-
</script>
196+
</script>
141197
<hr />
142198
<h3>Step 4</h3>
143199

@@ -216,6 +272,6 @@ <h3>Step 6</h3>
216272
$('#startdate').datepicker();
217273
</script>
218274

219-
{{pass}}
275+
{{pass}}
220276

221277
{{block right_sidebar}} {{end}}

0 commit comments

Comments
 (0)