我一直在尋找關於如何創建一個進度條,通知用戶他們已完成多少工作的互聯網。我瞭解如下Bootstrap's website.上顯示的HTML部分然而,我不明白我應該如何使用JavaScript中檢索到的用戶數據(來自view code api
(表示採用的和剩餘的類))來顯示用戶進度的進度條。實現引導進度條來通知用戶課程進度
任何幫助/解釋(什麼是你的思考過程?有沒有什麼好的教程?)這個noob非常讚賞!我仍然想學習最好的實踐和表現。謝謝!
我在看Stacks問題有user input改變進度條(不太正確),time incrementation,另一個使用checkboxes改變進度條(焦點是JS代碼在這裏)。
目前正在使用:Python 2.7版,金字塔(Web框架),自舉/ Jinja2的模板
查看代碼:
@view_config(route_name='assessments', request_method='GET', renderer='templates/unique_assessments.jinja2', permission='create')
def view_unique_microseries_group(request):
logged_in_userid = authenticated_userid(request)
if logged_in_userid is None:
raise HTTPForbidden()
all_assessments = api.retrieve_assessments() #all assessments in a list
#url = HTTPSeeOther(location=request.route_url('microseries'))
return {'logged_in': logged_in_userid, 'all_assessments': all_assessments}
@view_config(route_name='microseries', request_method='GET', renderer='templates/assessments.jinja2', permission='create')
def view_microseries_subseries(request):
logged_in_userid = authenticated_userid(request) #Authenticated User
if logged_in_userid is None:
raise HTTPForbidden()
microseries = int(request.matchdict['id']) #grabs class no. from link in assessments
microseries_list = api.retrieve_assessment(microseries=microseries)
#print 'microseries_list', microseries_list #prints all the matching number of microseries
all_assessments = api.retrieve_assessments() #all assessments in a list
user_results = api.retrieve_assessment_results() #all user results in a list
completed_assessments = []
pending_assessments = []
for assessment in all_assessments:
if assessment is None: # assumes None
continue
found_assessment_result = False
for result in user_results:
if result.owner.username == logged_in_userid and result.assessment == assessment:
found_assessment_result = True # assign Boolean statement
break # no need to check further
if found_assessment_result:
completed_assessments.append(assessment)
else:
pending_assessments.append(assessment)
message = 'Completed'
return {'completed_assessments': completed_assessments, 'pending_assessments': pending_assessments, 'logged_in': logged_in_userid, 'message': message, 'all_assessments':all_assessments, 'microseries_list': microseries_list}
HTML用於顯示的課程,整個目錄主頁 模板:unique_assessments.jinja2
<!-- Stats Gallery Section with Progress bar in each thumbnail-->
<div class="container">
<div class= 'gallery'>
<div class="row">
<div class="col-sm-8 col-md-3 ">
<div class="thumbnail">
<a href="{{request.application_url}}/microseries/1">
<img src="{{request.static_url('img.png')}}" alt="Training" class="img-responsive" style="width: 200px; height: 100px;"/>
</a>
<h4>Video Series 1</h4>
<p class="tag">Contains Episodes 1A-1F </p>
<div class="progress">
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> 100%
</div>
</div>
<p class="text_column"></p>
</div>
</div><!-- /.col-->
<div class="col-sm-8 col-md-3 ">
<div class="thumbnail">
<a href="{{request.application_url}}/microseries/2">
<img src="{{request.static_url('img.png')}}" alt="Training" class="img-responsive" style="width: 200px; height: 100px;"/>
</a>
<h4>Video Series 2</h4>
<p class="tag">Contains Episodes 2A-2E </p>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%"> 20%
</div>
</div>
<p class="text_column"></p>
</div>
</div><!-- /.col-->
<div class="col-sm-8 col-md-3 ">
<div class="thumbnail">
<a href="{{request.application_url}}/microseries/3">
<img src="{{request.static_url('img.png')}}" alt="Training" class="img-responsive" style="width: 200px; height: 100px;"/>
</a>
<h4>Video Series 3</h4>
<p class="tag">Contains Episodes 3A-3G </p>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%"> 60%
</div>
</div>
<p class="text_column"></p>
</div>
</div><!-- /.col-->
<div class="col-sm-8 col-md-3 ">
<div class="thumbnail">
<a href="{{request.application_url}}/microseries/4">
<img src="{{request.static_url('img.png')}}" alt="Training" class="img-responsive" style="width: 200px; height: 100px;"/>
</a>
<h4>Video Series 4</h4>
<p class="tag">Contains Episodes 4A-4E </p>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%"> 80%
</div>
</div>
<p class="text_column"></p>
</div>
</div><!-- /.col-->
<div class="col-sm-8 col-md-3 ">
<div class="thumbnail">
<a href="{{request.application_url}}/microseries/5">
<img src="{{request.static_url('img.png')}}" alt="Training" class="img-responsive" style="width: 200px; height: 100px;"/>
</a>
<h4>Video Series 5</h4>
<p class="tag">Contains Episodes 5A-5G </p>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%"> 80%
</div>
</div>
<p class="text_column"></p>
</div>
</div><!-- /.col-->
</div><!-- /.row-->
</div><!-- Gallery Container Ends -->
JS代碼: 不確定如何得到這個與來自視圖代碼